2 * Copyright (c) 2013-2018, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of Intel Corporation nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #ifndef PT_INSN_DECODER_H
30 #define PT_INSN_DECODER_H
32 #include "pt_query_decoder.h"
34 #include "pt_retstack.h"
36 #include "pt_msec_cache.h"
41 struct pt_insn_decoder {
42 /* The Intel(R) Processor Trace query decoder. */
43 struct pt_query_decoder query;
45 /* The configuration flags.
47 * Those are our flags set by the user. In @query.config.flags, we set
48 * the flags we need for the query decoder.
50 struct pt_conf_flags flags;
52 /* The default image. */
53 struct pt_image default_image;
56 struct pt_image *image;
58 /* The current cached section. */
59 struct pt_msec_cache scache;
61 /* The current address space. */
64 /* The current Intel(R) Processor Trace event. */
65 struct pt_event event;
67 /* The call/return stack for ret compression. */
68 struct pt_retstack retstack;
70 /* The current instruction.
72 * This is only valid if @process_insn is set.
75 struct pt_insn_ext iext;
79 * If tracing is disabled, this is the IP at which we assume tracing to
84 /* The current execution mode. */
85 enum pt_exec_mode mode;
87 /* The status of the last successful decoder query.
89 * Errors are reported directly; the status is always a non-negative
90 * pt_status_flag bit-vector.
94 /* A collection of flags defining how to proceed flow reconstruction:
96 * - tracing is enabled.
100 /* - process @event. */
101 uint32_t process_event:1;
103 /* - instructions are executed speculatively. */
104 uint32_t speculative:1;
106 /* - process @insn/@iext.
108 * We have started processing events binding to @insn/@iext. We have
109 * not yet proceeded past it.
111 * We will do so in pt_insn_event() after processing all events that
114 uint32_t process_insn:1;
116 /* - a paging event has already been bound to @insn/@iext. */
117 uint32_t bound_paging:1;
119 /* - a vmcs event has already been bound to @insn/@iext. */
120 uint32_t bound_vmcs:1;
122 /* - a ptwrite event has already been bound to @insn/@iext. */
123 uint32_t bound_ptwrite:1;
127 /* Initialize an instruction flow decoder.
129 * Returns zero on success; a negative error code otherwise.
130 * Returns -pte_internal, if @decoder is NULL.
131 * Returns -pte_invalid, if @config is NULL.
133 extern int pt_insn_decoder_init(struct pt_insn_decoder *decoder,
134 const struct pt_config *config);
136 /* Finalize an instruction flow decoder. */
137 extern void pt_insn_decoder_fini(struct pt_insn_decoder *decoder);
139 #endif /* PT_INSN_DECODER_H */