Blame doc/man/pt_image_alloc.3.md

Packit b1f7ae
% PT_IMAGE_ALLOC(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_alloc, pt_image_free, pt_image_name - allocate/free a traced memory
Packit b1f7ae
image descriptor
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# SYNOPSIS
Packit b1f7ae
Packit b1f7ae
| **\#include `<intel-pt.h>`**
Packit b1f7ae
|
Packit b1f7ae
| **struct pt_image \*pt_image_alloc(const char \**name*);**
Packit b1f7ae
| **const char \*pt_image_name(const struct pt_image \**image*);**
Packit b1f7ae
| **void pt_image_free(struct pt_image \**image*);**
Packit b1f7ae
Packit b1f7ae
Link with *-lipt*.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# DESCRIPTION
Packit b1f7ae
Packit b1f7ae
**pt_image_alloc**() allocates a new *pt_image* and returns a pointer to it.  A
Packit b1f7ae
*pt_image* object defines the memory image that was traced as a collection of
Packit b1f7ae
file sections and the virtual addresses at which those sections were loaded.
Packit b1f7ae
Packit b1f7ae
The *name* argument points to an optional zero-terminated name string.  If the
Packit b1f7ae
*name* argument is NULL, it will be ignored and the returned *pt_image* object
Packit b1f7ae
will not have a name.  Otherwise, the returned *pt_image* object will have a
Packit b1f7ae
copy of the string pointed to by the *name* argument as name.
Packit b1f7ae
Packit b1f7ae
**pt_image_name**() returns the name of the *pt_image* object the *image*
Packit b1f7ae
argument points to.
Packit b1f7ae
Packit b1f7ae
**pt_image_free**() frees the *pt_image* object pointed to by *image*.  The
Packit b1f7ae
*image* argument must be NULL or point to an image that has been allocated by a
Packit b1f7ae
call to **pt_image_alloc**().
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# RETURN VALUE
Packit b1f7ae
Packit b1f7ae
**pt_image_alloc**() returns a pointer to a *pt_image* object on success or NULL
Packit b1f7ae
in case of an error.
Packit b1f7ae
Packit b1f7ae
**pt_image_name**() returns a pointer to a zero-terminated string of NULL if the
Packit b1f7ae
image does not have a name.
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# EXAMPLE
Packit b1f7ae
Packit b1f7ae
~~~{.c}
Packit b1f7ae
int foo(const char *name) {
Packit b1f7ae
	struct pt_image *image;
Packit b1f7ae
	errcode;
Packit b1f7ae
Packit b1f7ae
	image = pt_image_alloc(name);
Packit b1f7ae
	if (!image)
Packit b1f7ae
		return pte_nomem;
Packit b1f7ae
Packit b1f7ae
	errcode = bar(image);
Packit b1f7ae
Packit b1f7ae
	pt_image_free(image);
Packit b1f7ae
	return errcode;
Packit b1f7ae
}
Packit b1f7ae
~~~
Packit b1f7ae
Packit b1f7ae
Packit b1f7ae
# SEE ALSO
Packit b1f7ae
Packit b1f7ae
**pt_image_add_file**(3), **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_image_set_callback**(3), **pt_insn_set_image**(3), **pt_insn_get_image**(3)