1PT_ALLOC_ENCODER(3) PT_ALLOC_ENCODER(3)
2
3
4
6 pt_alloc_encoder, pt_free_encoder - allocate/free an Intel(R) Processor
7 Trace packet encoder
8
10 #include <intel-pt.h>
11 struct pt_packet_encoder *
12 pt_alloc_encoder(const struct pt_config *config);
13 void pt_free_encoder(struct pt_packet_encoder *encoder);
14
15 Link with -lipt.
16
18 pt_alloc_encoder() allocates a new Intel Processor Trace (Intel PT)
19 packet encoder and returns a pointer to it. The packet encoder gener‐
20 ates Intel PT trace from pt_packet objects. See pt_enc_next(3).
21
22 The config argument points to a pt_config object. See pt_config(3).
23 The config argument will not be referenced by the returned encoder but
24 the trace buffer defined by the config argument's begin and end fields
25 will.
26
27 The returned packet encoder is initially synchronized onto the begin‐
28 ning of the trace buffer specified in its config argument. Use
29 pt_enc_sync_set(3) to move it to any other position inside the trace
30 buffer.
31
32 pt_free_encoder() frees the Intel PT packet encoder pointed to by en‐
33 coder. The encoder argument must be NULL or point to an encoder that
34 has been *allocated by a call to pt_alloc_encoder().
35
37 pt_alloc_encoder() returns a pointer to a pt_packet_encoder object on
38 success or NULL in case of an error.
39
41 int foo(const struct pt_config *config) {
42 struct pt_packet_encoder *encoder;
43 errcode;
44
45 encoder = pt_alloc_encoder(config);
46 if (!encoder)
47 return pte_nomem;
48
49 errcode = bar(encoder);
50
51 pt_free_encoder(encoder);
52 return errcode;
53 }
54
56 pt_config(3), pt_enc_sync_set(3), pt_enc_get_offset(3), pt_enc_get_con‐
57 fig(3), pt_enc_next(3)
58
59
60
61 PT_ALLOC_ENCODER(3)