Blame libipt/internal/include/pt_insn_decoder.h

Packit b1f7ae
/*
Packit b1f7ae
 * Copyright (c) 2013-2017, Intel Corporation
Packit b1f7ae
 *
Packit b1f7ae
 * Redistribution and use in source and binary forms, with or without
Packit b1f7ae
 * modification, are permitted provided that the following conditions are met:
Packit b1f7ae
 *
Packit b1f7ae
 *  * Redistributions of source code must retain the above copyright notice,
Packit b1f7ae
 *    this list of conditions and the following disclaimer.
Packit b1f7ae
 *  * Redistributions in binary form must reproduce the above copyright notice,
Packit b1f7ae
 *    this list of conditions and the following disclaimer in the documentation
Packit b1f7ae
 *    and/or other materials provided with the distribution.
Packit b1f7ae
 *  * Neither the name of Intel Corporation nor the names of its contributors
Packit b1f7ae
 *    may be used to endorse or promote products derived from this software
Packit b1f7ae
 *    without specific prior written permission.
Packit b1f7ae
 *
Packit b1f7ae
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit b1f7ae
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit b1f7ae
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit b1f7ae
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
Packit b1f7ae
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Packit b1f7ae
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Packit b1f7ae
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit b1f7ae
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Packit b1f7ae
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Packit b1f7ae
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Packit b1f7ae
 * POSSIBILITY OF SUCH DAMAGE.
Packit b1f7ae
 */
Packit b1f7ae
Packit b1f7ae
#ifndef PT_INSN_DECODER_H
Packit b1f7ae
#define PT_INSN_DECODER_H
Packit b1f7ae
Packit b1f7ae
#include "pt_query_decoder.h"
Packit b1f7ae
#include "pt_image.h"
Packit b1f7ae
#include "pt_retstack.h"
Packit b1f7ae
Packit b1f7ae
#include <inttypes.h>
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
struct pt_insn_decoder {
Packit b1f7ae
	/* The Intel(R) Processor Trace query decoder. */
Packit b1f7ae
	struct pt_query_decoder query;
Packit b1f7ae
Packit b1f7ae
	/* The configuration flags.
Packit b1f7ae
	 *
Packit b1f7ae
	 * Those are our flags set by the user.  In @query.config.flags, we set
Packit b1f7ae
	 * the flags we need for the query decoder.
Packit b1f7ae
	 */
Packit b1f7ae
	struct pt_conf_flags flags;
Packit b1f7ae
Packit b1f7ae
	/* The default image. */
Packit b1f7ae
	struct pt_image default_image;
Packit b1f7ae
Packit b1f7ae
	/* The image. */
Packit b1f7ae
	struct pt_image *image;
Packit b1f7ae
Packit b1f7ae
	/* The current address space. */
Packit b1f7ae
	struct pt_asid asid;
Packit b1f7ae
Packit b1f7ae
	/* The current Intel(R) Processor Trace event. */
Packit b1f7ae
	struct pt_event event;
Packit b1f7ae
Packit b1f7ae
	/* The call/return stack for ret compression. */
Packit b1f7ae
	struct pt_retstack retstack;
Packit b1f7ae
Packit b1f7ae
	/* The current IP. */
Packit b1f7ae
	uint64_t ip;
Packit b1f7ae
Packit b1f7ae
	/* The IP of the last disable.
Packit b1f7ae
	 *
Packit b1f7ae
	 * This is either zero or the IP of the first instruction that wasn't
Packit b1f7ae
	 * executed due to the disable event.
Packit b1f7ae
	 */
Packit b1f7ae
	uint64_t last_disable_ip;
Packit b1f7ae
Packit b1f7ae
	/* The current execution mode. */
Packit b1f7ae
	enum pt_exec_mode mode;
Packit b1f7ae
Packit b1f7ae
	/* The status of the last successful decoder query.
Packit b1f7ae
	 *
Packit b1f7ae
	 * Errors are reported directly; the status is always a non-negative
Packit b1f7ae
	 * pt_status_flag bit-vector.
Packit b1f7ae
	 */
Packit b1f7ae
	int status;
Packit b1f7ae
Packit b1f7ae
	/* A collection of flags defining how to proceed flow reconstruction:
Packit b1f7ae
	 *
Packit b1f7ae
	 * - tracing is enabled.
Packit b1f7ae
	 */
Packit b1f7ae
	uint32_t enabled:1;
Packit b1f7ae
Packit b1f7ae
	/* - process @event. */
Packit b1f7ae
	uint32_t process_event:1;
Packit b1f7ae
Packit b1f7ae
	/* - event processing may change the IP. */
Packit b1f7ae
	uint32_t event_may_change_ip:1;
Packit b1f7ae
Packit b1f7ae
	/* - instructions are executed speculatively. */
Packit b1f7ae
	uint32_t speculative:1;
Packit b1f7ae
Packit b1f7ae
	/* - a paging event has been bound to the current instruction. */
Packit b1f7ae
	uint32_t paging_event_bound:1;
Packit b1f7ae
Packit b1f7ae
	/* - a vmcs event has been bound to the current instruction. */
Packit b1f7ae
	uint32_t vmcs_event_bound:1;
Packit b1f7ae
};
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
/* Initialize an instruction flow decoder.
Packit b1f7ae
 *
Packit b1f7ae
 * Returns zero on success; a negative error code otherwise.
Packit b1f7ae
 * Returns -pte_internal, if @decoder is NULL.
Packit b1f7ae
 * Returns -pte_invalid, if @config is NULL.
Packit b1f7ae
 */
Packit b1f7ae
extern int pt_insn_decoder_init(struct pt_insn_decoder *decoder,
Packit b1f7ae
				const struct pt_config *config);
Packit b1f7ae
Packit b1f7ae
/* Finalize an instruction flow decoder. */
Packit b1f7ae
extern void pt_insn_decoder_fini(struct pt_insn_decoder *decoder);
Packit b1f7ae
Packit b1f7ae
#endif /* PT_INSN_DECODER_H */