Blame doc/man/pt_iscache_add_file.3.md

Packit b1f7ae
% PT_ISCACHE_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_iscache_add_file - add file sections to a traced memory image section cache
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# SYNOPSIS
Packit b1f7ae
Packit b1f7ae
| **\#include `<intel-pt.h>`**
Packit b1f7ae
|
Packit b1f7ae
| **int pt_iscache_add_file(struct pt_image_section_cache \**iscache*,**
Packit b1f7ae
|                         **const char \**filename*, uint64_t *offset*,**
Packit b1f7ae
|                         **uint64_t *size*, uint64_t *vaddr*);**
Packit b1f7ae
Packit b1f7ae
Link with *-lipt*.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# DESCRIPTION
Packit b1f7ae
Packit b1f7ae
**pt_iscache_add_file**() adds a new section consisting of *size* bytes starting
Packit b1f7ae
at *offset* in *filename* loaded at *vaddr* to *iscache*.
Packit b1f7ae
Packit b1f7ae
On success, **pt_iscache_add_file**() returns a positive integer identifier that
Packit b1f7ae
uniquely identifies the added section in that cache.  This identifier can be
Packit b1f7ae
used to add sections from an image section cache to one or more traced memory
Packit b1f7ae
images.  See **pt_image_add_cached**(3).  Sections added from an image section
Packit b1f7ae
cache will be shared across images.  It can also be used to read memory from the
Packit b1f7ae
cached section.  See **pt_iscache_read**(3).
Packit b1f7ae
Packit b1f7ae
If the cache already contains a suitable section, no section is added and the
Packit b1f7ae
identifier for the existing section is returned.  If the cache already contains
Packit b1f7ae
a section that only differs in the load address, a new section is added that
Packit b1f7ae
shares the underlying file section.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# RETURN VALUE
Packit b1f7ae
Packit b1f7ae
**pt_iscache_add_file**() returns a positive image section identifier on success
Packit b1f7ae
or a 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 *iscache* 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
Packit b1f7ae
Packit b1f7ae
# EXAMPLE
Packit b1f7ae
Packit b1f7ae
~~~{.c}
Packit b1f7ae
int add_file(struct pt_image_section_cache *iscache, struct pt_image *image,
Packit b1f7ae
             const char *filename, uint64_t offset, uint64_t size,
Packit b1f7ae
             uint64_t vaddr, const struct pt_asid *asid) {
Packit b1f7ae
    int isid;
Packit b1f7ae
Packit b1f7ae
    isid = pt_iscache_add_file(iscache, filename, offset, size, vaddr);
Packit b1f7ae
    if (isid < 0)
Packit b1f7ae
       return isid;
Packit b1f7ae
Packit b1f7ae
    return pt_image_add_cached(image, iscache, isid, asid);
Packit b1f7ae
}
Packit b1f7ae
~~~
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# SEE ALSO
Packit b1f7ae
Packit b1f7ae
**pt_iscache_alloc**(3), **pt_iscache_free**(3), **pt_iscache_read**(3),
Packit b1f7ae
**pt_image_add_cached**(3)