diff options
Diffstat (limited to 'ctracecmd.i')
-rw-r--r-- | ctracecmd.i | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ctracecmd.i b/ctracecmd.i index 9569419..624fb63 100644 --- a/ctracecmd.i +++ b/ctracecmd.i | |||
@@ -69,6 +69,32 @@ static PyObject *py_field_get_data(struct format_field *f, struct record *r) | |||
69 | return PyBuffer_FromMemory((char *)r->data + f->offset, f->size); | 69 | return PyBuffer_FromMemory((char *)r->data + f->offset, f->size); |
70 | } | 70 | } |
71 | 71 | ||
72 | static PyObject *py_field_get_str(struct format_field *f, struct record *r) | ||
73 | { | ||
74 | if (!strncmp(f->type, "__data_loc ", 11)) { | ||
75 | unsigned long long val; | ||
76 | int offset; | ||
77 | |||
78 | if (pevent_read_number_field(f, r->data, &val)) { | ||
79 | PyErr_SetString(PyExc_TypeError, | ||
80 | "Field is not a valid number"); | ||
81 | return NULL; | ||
82 | } | ||
83 | |||
84 | /* | ||
85 | * The actual length of the dynamic array is stored | ||
86 | * in the top half of the field, and the offset | ||
87 | * is in the bottom half of the 32 bit field. | ||
88 | */ | ||
89 | offset = val & 0xffff; | ||
90 | |||
91 | return PyString_FromString((char *)r->data + offset); | ||
92 | } | ||
93 | |||
94 | return PyString_FromStringAndSize((char *)r->data + f->offset, | ||
95 | strnlen((char *)r->data + f->offset, f->size)); | ||
96 | } | ||
97 | |||
72 | static PyObject *py_format_get_keys(struct event_format *ef) | 98 | static PyObject *py_format_get_keys(struct event_format *ef) |
73 | { | 99 | { |
74 | PyObject *list; | 100 | PyObject *list; |