Blame doc/man/pt_image_set_callback.3.md

Packit b1f7ae
% PT_IMAGE_SET_CALLBACK(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_set_callback - set a traced memory image read memory callback
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# SYNOPSIS
Packit b1f7ae
Packit b1f7ae
| **\#include `<intel-pt.h>`**
Packit b1f7ae
|
Packit b1f7ae
| **typedef int (read_memory_callback_t)(uint8_t \**buffer*, size_t *size*,**
Packit b1f7ae
|				                       **const struct pt_asid \**asid*,**
Packit b1f7ae
|				                       **uint64_t *ip*, void \**context*);**
Packit b1f7ae
|
Packit b1f7ae
| **int pt_image_set_callback(struct pt_image \**image*,**
Packit b1f7ae
|					        **read_memory_callback_t \**callback*,**
Packit b1f7ae
|                           **void \**context*);**
Packit b1f7ae
Packit b1f7ae
Link with *-lipt*.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# DESCRIPTION
Packit b1f7ae
Packit b1f7ae
**pt_image_set_callback**() sets the function pointed to by *callback* as the
Packit b1f7ae
read-memory callback function in the *pt_image* object pointed to by *image*.
Packit b1f7ae
Any previous read-memory callback function is replaced.  The read-memory
Packit b1f7ae
callback function can be removed by passing NULL as *callback* argument.
Packit b1f7ae
Packit b1f7ae
When the Intel(R) Processor Trace (Intel PT) instruction flow decoder that is
Packit b1f7ae
using *image* tries to read memory from a location that is not contained in any
Packit b1f7ae
of the file sections in *image*, it calls the read-memory callback function with
Packit b1f7ae
the following arguments:
Packit b1f7ae
Packit b1f7ae
buffer
Packit b1f7ae
:   A pre-allocated memory buffer to hold the to-be-read memory.  The callback
Packit b1f7ae
    function shall provide the read memory in that buffer.
Packit b1f7ae
Packit b1f7ae
size
Packit b1f7ae
:   The size of the memory buffer pointed to by the *buffer* argument.
Packit b1f7ae
Packit b1f7ae
asid
Packit b1f7ae
:   The address-space identifier specifying the process, guest, or hypervisor,
Packit b1f7ae
    in which context the *ip* argument is to be interpreted.  See
Packit b1f7ae
    **pt_image_add_file**(3).
Packit b1f7ae
Packit b1f7ae
ip
Packit b1f7ae
:   The virtual address from which *size* bytes of memory shall be read.
Packit b1f7ae
Packit b1f7ae
context
Packit b1f7ae
:   The *context* argument passed to **pt_image_set_callback**().
Packit b1f7ae
Packit b1f7ae
The callback function shall return the number of bytes read on success (no more
Packit b1f7ae
than *size*) or a negative *pt_error_code* enumeration constant in case of an
Packit b1f7ae
error.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# RETURN VALUE
Packit b1f7ae
Packit b1f7ae
**pt_image_set_callback**() returns zero on success or a negative
Packit b1f7ae
*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
:   If the *image* argument is NULL.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# SEE ALSO
Packit b1f7ae
Packit b1f7ae
**pt_image_alloc**(3), **pt_image_free**(3), **pt_image_add_file**(3),
Packit b1f7ae
**pt_image_add_cached**(3), pt_image_copy**(3),
Packit b1f7ae
**pt_image_remove_by_filename**(3), pt_image_remove_by_asid**(3),
Packit b1f7ae
**pt_insn_set_image**(3), pt_insn_get_image**(3)