|
Packit |
b1f7ae |
% PT_IMAGE_ADD_FILE(3)
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
! Copyright (c) 2015-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 |
# NAME
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
pt_image_add_file, pt_image_add_cached, pt_image_copy - add file sections to a
|
|
Packit |
b1f7ae |
traced memory image descriptor
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
# SYNOPSIS
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
| **\#include `<intel-pt.h>`**
|
|
Packit |
b1f7ae |
|
|
|
Packit |
b1f7ae |
| **int pt_image_add_file(struct pt_image \**image*, const char \**filename*,**
|
|
Packit |
b1f7ae |
| **uint64_t *offset*, uint64_t *size*,**
|
|
Packit |
b1f7ae |
| **const struct pt_asid \**asid*, uint64_t *vaddr*);**
|
|
Packit |
b1f7ae |
| **int pt_image_add_cached(struct pt_image \**image*,**
|
|
Packit |
b1f7ae |
| **struct pt_image_section_cache \**iscache*,**
|
|
Packit |
b1f7ae |
| **int *isid*, const struct pt_asid \**asid*);**
|
|
Packit |
b1f7ae |
| **int pt_image_copy(struct pt_image \**image*,**
|
|
Packit |
b1f7ae |
| **const struct pt_image \**src*);**
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
Link with *-lipt*.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
# DESCRIPTION
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
**pt_image_add_file**() adds a new section to a *pt_image* object. The *image*
|
|
Packit |
b1f7ae |
argument points to the *pt_image* object to which the new section is added. The
|
|
Packit |
b1f7ae |
*filename* argument gives the absolute or relative path to the file on disk that
|
|
Packit |
b1f7ae |
contains the section. The *offset* and *size* arguments define the section
|
|
Packit |
b1f7ae |
within the file. The *size* argument is silently truncated to end the section
|
|
Packit |
b1f7ae |
with the end of the underlying file. The *vaddr* argument gives the virtual
|
|
Packit |
b1f7ae |
address at which the section is being loaded.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
**pt_image_add_cached**() adds a new section from an image section cache. See
|
|
Packit |
b1f7ae |
**pt_iscache_add_file**(3). The *iscache* argument points to the
|
|
Packit |
b1f7ae |
*pt_image_section_cache* object containing the section. The *isid* argument
|
|
Packit |
b1f7ae |
gives the image section identifier for the desired section in that cache.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
The *asid* argument gives an optional address space identifier. If it is not
|
|
Packit |
b1f7ae |
NULL, it points to a *pt_asid* structure, which is declared as:
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
~~~{.c}
|
|
Packit |
b1f7ae |
/** An Intel PT address space identifier.
|
|
Packit |
b1f7ae |
*
|
|
Packit |
b1f7ae |
* This identifies a particular address space when adding file
|
|
Packit |
b1f7ae |
* sections or when reading memory.
|
|
Packit |
b1f7ae |
*/
|
|
Packit |
b1f7ae |
struct pt_asid {
|
|
Packit |
b1f7ae |
/** The size of this object - set to sizeof(struct pt_asid).
|
|
Packit |
b1f7ae |
*/
|
|
Packit |
b1f7ae |
size_t size;
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
/** The CR3 value. */
|
|
Packit |
b1f7ae |
uint64_t cr3;
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
/** The VMCS Base address. */
|
|
Packit |
b1f7ae |
uint64_t vmcs;
|
|
Packit |
b1f7ae |
};
|
|
Packit |
b1f7ae |
~~~
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
The *asid* argument can be used to prepare a collection of process, guest, and
|
|
Packit |
b1f7ae |
hypervisor images to an Intel(R) Processor Trace (Intel PT) instruction flow
|
|
Packit |
b1f7ae |
decoder. The decoder will select the current image based on CR3 and VMCS
|
|
Packit |
b1f7ae |
information in the Intel PT trace.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
If only the CR3 or only the VMCS field should be considered by the decoder,
|
|
Packit |
b1f7ae |
supply *pt_asid_no_cr3* and *pt_asid_no_vmcs* to the other field respectively.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
If the *asid* argument is NULL, the file section will be added for all
|
|
Packit |
b1f7ae |
processes, guests, and hypervisor images.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
If the new section overlaps with an existing section, the existing section is
|
|
Packit |
b1f7ae |
truncated or split to make room for the new section.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
**pt_image_copy**() adds file sections from the *pt_image* pointed to by the
|
|
Packit |
b1f7ae |
*src* argument to the *pt_image* pointed to by the *dst* argument.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
# RETURN VALUE
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
**pt_image_add_file**() and **pt_image_add_cached**() return zero on success or
|
|
Packit |
b1f7ae |
a negative *pt_error_code* enumeration constant in case of an error.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
**pt_image_copy**() returns the number of ignored sections on success or a
|
|
Packit |
b1f7ae |
negative *pt_error_code* enumeration constant in case of an error.
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
# ERRORS
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
pte_invalid
|
|
Packit |
b1f7ae |
: The *image* or *filename* argument is NULL or the *offset* argument is too
|
|
Packit |
b1f7ae |
big such that the section would start past the end of the file
|
|
Packit |
b1f7ae |
(**pt_image_add_file**()).
|
|
Packit |
b1f7ae |
The *image* or *iscache* argument is NULL (**pt_image_add_cached**()).
|
|
Packit |
b1f7ae |
The *src* or *dst* argument is NULL (**pt_image_copy**()).
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
pte_bad_image
|
|
Packit |
b1f7ae |
: The *iscache* does not contain *isid* (**pt_image_add_cached**()).
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
# SEE ALSO
|
|
Packit |
b1f7ae |
|
|
Packit |
b1f7ae |
**pt_image_alloc**(3), **pt_image_free**(3),
|
|
Packit |
b1f7ae |
**pt_image_remove_by_filename**(3), **pt_image_remove_by_asid**(3),
|
|
Packit |
b1f7ae |
**pt_image_set_callback**(3), **pt_insn_set_image**(3),
|
|
Packit |
b1f7ae |
**pt_insn_get_image**(3), **pt_iscache_alloc**(3), **pt_iscache_add_file**(3)
|