1PT_IMAGE_REMOVE_BY_FILENAME(3) PT_IMAGE_REMOVE_BY_FILENAME(3)
2
3
4
6 pt_image_remove_by_filename, pt_image_remove_by_asid - remove sections
7 from a traced memory image descriptor
8
10 #include <intel-pt.h>
11 int pt_image_remove_by_filename(struct pt_image *image,
12 const char *filename,
13 const struct pt_asid *asid);
14 int pt_image_remove_by_asid(struct pt_image *image,
15 const struct pt_asid *asid);
16
17 Link with -lipt.
18
20 pt_image_remove_by_filename() removes all sections from image that were
21 added by a call to pt_image_add_file(3) with an identical filename ar‐
22 gument or by a call to pt_image_copy(3) from such a section. Sections
23 that are based on the same underlying file but that were added using a
24 different filename argument are not removed.
25
26 If the asid argument is not NULL, it removes only sections that were
27 added with a matching address-space identifier. See pt_im‐
28 age_add_file(3).
29
30 pt_image_remove_by_asid(3) removes all sections from image that were
31 added by a call to pt_image_add_file(3) with a matching asid argument
32 or by a call to pt_image_copy(3) from such a section. See pt_im‐
33 age_add_file(3).
34
35 Two pt_asid objects match in their "cr3* or vmcs field if one of them
36 does not provide the field (i.e. sets it to pt_asid_no_cr3 or
37 pt_asid_no_vmcs respectively) or if the provided values are identical.
38 Two pt_asid objects match if they match in all fields.
39
41 Both functions return the number of sections removed on success or a
42 negative pt_error_code enumeration constant in case of an error.
43
45 pte_invalid
46 The image argument is NULL or the filename argument is NULL
47 (pt_image_remove_by_filename() only).
48
50 int foo(struct pt_image *image, uint64_t cr3) {
51 struct pt_asid asid1, asid2;
52 int errcode;
53
54 pt_asid_init(&asid1);
55 asid1.cr3 = cr3;
56
57 pt_asid_init(&asid2);
58 asid2.cr3 = ~cr3;
59
60 errcode = pt_image_add_file(image, "/path/to/libfoo.so",
61 0xa000, 0x100, &asid1, 0xb000);
62 if (errcode < 0)
63 return errcode;
64
65 errcode = pt_image_add_file(image, "rel/path/to/libfoo.so",
66 0xa000, 0x100, &asid1, 0xc000);
67 if (errcode < 0)
68 return errcode;
69
70 /* This call would only remove the section added first:
71 *
72 * - filename matches only the first section's filename
73 * - NULL matches every asid
74 */
75 (void) pt_image_remove_by_filename(image,
76 "/path/to/libfoo.so",
77 NULL);
78
79 /* This call would not remove any of the above sections:
80 *
81 * - filename matches the first section's filename
82 * - asid2 does not match asid1
83 */
84 (void) pt_image_remove_by_filename(image,
85 "/path/to/libfoo.so",
86 &asid2);
87
88 /* This call would not remove any of the above sections:
89 *
90 * - asid2 does not match asid1
91 */
92 (void) pt_image_remove_by_asid(image, &asid2);
93
94 /* This call would remove both sections:
95 *
96 * - asid1 matches itself
97 */
98 (void) pt_image_remove_by_asid(image, &asid1);
99
100 /* This call would remove both sections:
101 *
102 * - NULL matches every asid
103 */
104 (void) pt_image_remove_by_asid(image, NULL);
105 }
106
108 pt_image_alloc(3), pt_image_free(3), pt_image_add_file(3), pt_im‐
109 age_add_cached(3), pt_image_copy(3), pt_insn_set_image(3), pt_in‐
110 sn_get_image(3)
111
112
113
114 PT_IMAGE_REMOVE_BY_FILENAME(3)