GDB (xrefs)
Loading...
Searching...
No Matches
py-record-btrace.c
Go to the documentation of this file.
1/* Python interface to btrace instruction history.
2
3 Copyright 2016-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "gdbcore.h"
22#include "gdbcmd.h"
23#include "gdbthread.h"
24#include "btrace.h"
25#include "py-record.h"
26#include "py-record-btrace.h"
27#include "record-btrace.h"
28#include "disasm.h"
29#include "gdbarch.h"
30
31/* Python object for btrace record lists. */
32
34 PyObject_HEAD
35
36 /* The thread this list belongs to. */
38
39 /* The first index being part of this list. */
40 Py_ssize_t first;
41
42 /* The last index begin part of this list. */
43 Py_ssize_t last;
44
45 /* Stride size. */
46 Py_ssize_t step;
47
48 /* Either &BTPY_CALL_TYPE or &RECPY_INSN_TYPE. */
49 PyTypeObject* element_type;
50};
51
52/* Python type for btrace lists. */
53
54static PyTypeObject btpy_list_type = {
55 PyVarObject_HEAD_INIT (NULL, 0)
56};
57
58/* Returns either a btrace_insn for the given Python gdb.RecordInstruction
59 object or sets an appropriate Python exception and returns NULL. */
60
61static const btrace_insn *
62btrace_insn_from_recpy_insn (const PyObject * const pyobject)
63{
64 const btrace_insn *insn;
65 const recpy_element_object *obj;
66 thread_info *tinfo;
68
69 if (Py_TYPE (pyobject) != &recpy_insn_type)
70 {
71 PyErr_Format (gdbpy_gdb_error, _("Must be gdb.RecordInstruction"));
72 return NULL;
73 }
74
75 obj = (const recpy_element_object *) pyobject;
76 tinfo = obj->thread;
77
78 if (tinfo == NULL || btrace_is_empty (tinfo))
79 {
80 PyErr_Format (gdbpy_gdb_error, _("No such instruction."));
81 return NULL;
82 }
83
84 if (btrace_find_insn_by_number (&iter, &tinfo->btrace, obj->number) == 0)
85 {
86 PyErr_Format (gdbpy_gdb_error, _("No such instruction."));
87 return NULL;
88 }
89
90 insn = btrace_insn_get (&iter);
91 if (insn == NULL)
92 {
93 PyErr_Format (gdbpy_gdb_error, _("Not a valid instruction."));
94 return NULL;
95 }
96
97 return insn;
98}
99
100/* Returns either a btrace_function for the given Python
101 gdb.RecordFunctionSegment object or sets an appropriate Python exception and
102 returns NULL. */
103
104static const btrace_function *
105btrace_func_from_recpy_func (const PyObject * const pyobject)
106{
107 const btrace_function *func;
108 const recpy_element_object *obj;
109 thread_info *tinfo;
111
112 if (Py_TYPE (pyobject) != &recpy_func_type)
113 {
114 PyErr_Format (gdbpy_gdb_error, _("Must be gdb.RecordFunctionSegment"));
115 return NULL;
116 }
117
118 obj = (const recpy_element_object *) pyobject;
119 tinfo = obj->thread;
120
121 if (tinfo == NULL || btrace_is_empty (tinfo))
122 {
123 PyErr_Format (gdbpy_gdb_error, _("No such function segment."));
124 return NULL;
125 }
126
127 if (btrace_find_call_by_number (&iter, &tinfo->btrace, obj->number) == 0)
128 {
129 PyErr_Format (gdbpy_gdb_error, _("No such function segment."));
130 return NULL;
131 }
132
133 func = btrace_call_get (&iter);
134 if (func == NULL)
135 {
136 PyErr_Format (gdbpy_gdb_error, _("Not a valid function segment."));
137 return NULL;
138 }
139
140 return func;
141}
142
143/* Looks at the recorded item with the number NUMBER and create a
144 gdb.RecordInstruction or gdb.RecordGap object for it accordingly. */
145
146static PyObject *
147btpy_insn_or_gap_new (thread_info *tinfo, Py_ssize_t number)
148{
150 int err_code;
151
152 btrace_find_insn_by_number (&iter, &tinfo->btrace, number);
153 err_code = btrace_insn_get_error (&iter);
154
155 if (err_code != 0)
156 {
157 const btrace_config *config;
158 const char *err_string;
159
160 config = btrace_conf (&tinfo->btrace);
161 err_string = btrace_decode_error (config->format, err_code);
162
163 return recpy_gap_new (err_code, err_string, number);
164 }
165
166 return recpy_insn_new (tinfo, RECORD_METHOD_BTRACE, number);
167}
168
169/* Create a new gdb.BtraceList object. */
170
171static PyObject *
172btpy_list_new (thread_info *thread, Py_ssize_t first, Py_ssize_t last,
173 Py_ssize_t step, PyTypeObject *element_type)
174{
175 btpy_list_object * const obj = PyObject_New (btpy_list_object,
177
178 if (obj == NULL)
179 return NULL;
180
181 obj->thread = thread;
182 obj->first = first;
183 obj->last = last;
184 obj->step = step;
185 obj->element_type = element_type;
186
187 return (PyObject *) obj;
188}
189
190/* Implementation of RecordInstruction.sal [gdb.Symtab_and_line] for btrace.
191 Returns the SAL associated with this instruction. */
192
193PyObject *
194recpy_bt_insn_sal (PyObject *self, void *closure)
195{
196 const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
197 PyObject *result = NULL;
198
199 if (insn == NULL)
200 return NULL;
201
202 try
203 {
204 result = symtab_and_line_to_sal_object (find_pc_line (insn->pc, 0));
205 }
206 catch (const gdb_exception &except)
207 {
209 }
210
211 return result;
212}
213
214/* Implementation of RecordInstruction.pc [int] for btrace.
215 Returns the instruction address. */
216
217PyObject *
218recpy_bt_insn_pc (PyObject *self, void *closure)
219{
220 const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
221
222 if (insn == NULL)
223 return NULL;
224
225 return gdb_py_object_from_ulongest (insn->pc).release ();
226}
227
228/* Implementation of RecordInstruction.size [int] for btrace.
229 Returns the instruction size. */
230
231PyObject *
232recpy_bt_insn_size (PyObject *self, void *closure)
233{
234 const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
235
236 if (insn == NULL)
237 return NULL;
238
239 return gdb_py_object_from_longest (insn->size).release ();
240}
241
242/* Implementation of RecordInstruction.is_speculative [bool] for btrace.
243 Returns if this instruction was executed speculatively. */
244
245PyObject *
247{
248 const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
249
250 if (insn == NULL)
251 return NULL;
252
254 Py_RETURN_TRUE;
255 else
256 Py_RETURN_FALSE;
257}
258
259/* Implementation of RecordInstruction.data [buffer] for btrace.
260 Returns raw instruction data. */
261
262PyObject *
263recpy_bt_insn_data (PyObject *self, void *closure)
264{
265 const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
266 gdb::byte_vector buffer;
267 PyObject *object;
268
269 if (insn == NULL)
270 return NULL;
271
272 try
273 {
274 buffer.resize (insn->size);
275 read_memory (insn->pc, buffer.data (), insn->size);
276 }
277 catch (const gdb_exception &except)
278 {
280 }
281
282 object = PyBytes_FromStringAndSize ((const char *) buffer.data (),
283 insn->size);
284
285 if (object == NULL)
286 return NULL;
287
288 return PyMemoryView_FromObject (object);
289}
290
291/* Implementation of RecordInstruction.decoded [str] for btrace.
292 Returns the instruction as human readable string. */
293
294PyObject *
295recpy_bt_insn_decoded (PyObject *self, void *closure)
296{
297 const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
298 string_file strfile;
299
300 if (insn == NULL)
301 return NULL;
302
303 try
304 {
305 gdb_print_insn (target_gdbarch (), insn->pc, &strfile, NULL);
306 }
307 catch (const gdb_exception &except)
308 {
310 return NULL;
311 }
312
313 return PyBytes_FromString (strfile.string ().c_str ());
314}
315
316/* Implementation of RecordFunctionSegment.level [int] for btrace.
317 Returns the call level. */
318
319PyObject *
320recpy_bt_func_level (PyObject *self, void *closure)
321{
322 const btrace_function * const func = btrace_func_from_recpy_func (self);
323 thread_info *tinfo;
324
325 if (func == NULL)
326 return NULL;
327
328 tinfo = ((recpy_element_object *) self)->thread;
329 return gdb_py_object_from_longest (tinfo->btrace.level
330 + func->level).release ();
331}
332
333/* Implementation of RecordFunctionSegment.symbol [gdb.Symbol] for btrace.
334 Returns the symbol associated with this function call. */
335
336PyObject *
337recpy_bt_func_symbol (PyObject *self, void *closure)
338{
339 const btrace_function * const func = btrace_func_from_recpy_func (self);
340
341 if (func == NULL)
342 return NULL;
343
344 if (func->sym == NULL)
345 Py_RETURN_NONE;
346
347 return symbol_to_symbol_object (func->sym);
348}
349
350/* Implementation of RecordFunctionSegment.instructions [list] for btrace.
351 Returns the list of instructions that belong to this function call. */
352
353PyObject *
355{
356 const btrace_function * const func = btrace_func_from_recpy_func (self);
357 unsigned int len;
358
359 if (func == NULL)
360 return NULL;
361
362 len = func->insn.size ();
363
364 /* Gaps count as one instruction. */
365 if (len == 0)
366 len = 1;
367
368 return btpy_list_new (((recpy_element_object *) self)->thread,
369 func->insn_offset, func->insn_offset + len, 1,
371}
372
373/* Implementation of RecordFunctionSegment.up [RecordFunctionSegment] for
374 btrace. Returns the caller / returnee of this function. */
375
376PyObject *
377recpy_bt_func_up (PyObject *self, void *closure)
378{
379 const btrace_function * const func = btrace_func_from_recpy_func (self);
380
381 if (func == NULL)
382 return NULL;
383
384 if (func->up == 0)
385 Py_RETURN_NONE;
386
387 return recpy_func_new (((recpy_element_object *) self)->thread,
389}
390
391/* Implementation of RecordFunctionSegment.prev [RecordFunctionSegment] for
392 btrace. Returns a previous segment of this function. */
393
394PyObject *
395recpy_bt_func_prev (PyObject *self, void *closure)
396{
397 const btrace_function * const func = btrace_func_from_recpy_func (self);
398
399 if (func == NULL)
400 return NULL;
401
402 if (func->prev == 0)
403 Py_RETURN_NONE;
404
405 return recpy_func_new (((recpy_element_object *) self)->thread,
407}
408
409/* Implementation of RecordFunctionSegment.next [RecordFunctionSegment] for
410 btrace. Returns a following segment of this function. */
411
412PyObject *
413recpy_bt_func_next (PyObject *self, void *closure)
414{
415 const btrace_function * const func = btrace_func_from_recpy_func (self);
416
417 if (func == NULL)
418 return NULL;
419
420 if (func->next == 0)
421 Py_RETURN_NONE;
422
423 return recpy_func_new (((recpy_element_object *) self)->thread,
425}
426
427/* Implementation of BtraceList.__len__ (self) -> int. */
428
429static Py_ssize_t
431{
432 const btpy_list_object * const obj = (btpy_list_object *) self;
433 const Py_ssize_t distance = obj->last - obj->first;
434 const Py_ssize_t result = distance / obj->step;
435
436 if ((distance % obj->step) == 0)
437 return result;
438
439 return result + 1;
440}
441
442/* Implementation of
443 BtraceList.__getitem__ (self, key) -> BtraceInstruction and
444 BtraceList.__getitem__ (self, key) -> BtraceFunctionCall. */
445
446static PyObject *
447btpy_list_item (PyObject *self, Py_ssize_t index)
448{
449 const btpy_list_object * const obj = (btpy_list_object *) self;
450 Py_ssize_t number;
451
452 if (index < 0 || index >= btpy_list_length (self))
453 return PyErr_Format (PyExc_IndexError, _("Index out of range: %zd."),
454 index);
455
456 number = obj->first + (obj->step * index);
457
458 if (obj->element_type == &recpy_insn_type)
459 return recpy_insn_new (obj->thread, RECORD_METHOD_BTRACE, number);
460 else
461 return recpy_func_new (obj->thread, RECORD_METHOD_BTRACE, number);
462}
463
464/* Implementation of BtraceList.__getitem__ (self, slice) -> BtraceList. */
465
466static PyObject *
468{
469 const btpy_list_object * const obj = (btpy_list_object *) self;
470 const Py_ssize_t length = btpy_list_length (self);
471 Py_ssize_t start, stop, step, slicelength;
472
473 if (PyLong_Check (value))
474 {
475 Py_ssize_t index = PyLong_AsSsize_t (value);
476
477 /* Emulate Python behavior for negative indices. */
478 if (index < 0)
479 index += length;
480
481 return btpy_list_item (self, index);
482 }
483
484 if (!PySlice_Check (value))
485 return PyErr_Format (PyExc_TypeError, _("Index must be int or slice."));
486
487 if (0 != PySlice_GetIndicesEx (value, length, &start, &stop,
488 &step, &slicelength))
489 return NULL;
490
491 return btpy_list_new (obj->thread, obj->first + obj->step * start,
492 obj->first + obj->step * stop, obj->step * step,
493 obj->element_type);
494}
495
496/* Helper function that returns the position of an element in a BtraceList
497 or -1 if the element is not in the list. */
498
499static LONGEST
501{
502 const btpy_list_object * const list_obj = (btpy_list_object *) self;
503 const recpy_element_object * const obj = (const recpy_element_object *) value;
504 Py_ssize_t index = obj->number;
505
506 if (list_obj->element_type != Py_TYPE (value))
507 return -1;
508
509 if (list_obj->thread != obj->thread)
510 return -1;
511
512 if (index < list_obj->first || index > list_obj->last)
513 return -1;
514
515 index -= list_obj->first;
516
517 if (index % list_obj->step != 0)
518 return -1;
519
520 return index / list_obj->step;
521}
522
523/* Implementation of "in" operator for BtraceLists. */
524
525static int
527{
528 if (btpy_list_position (self, value) < 0)
529 return 0;
530
531 return 1;
532}
533
534/* Implementation of BtraceLists.index (self, value) -> int. */
535
536static PyObject *
538{
539 const LONGEST index = btpy_list_position (self, value);
540
541 if (index < 0)
542 return PyErr_Format (PyExc_ValueError, _("Not in list."));
543
544 return gdb_py_object_from_longest (index).release ();
545}
546
547/* Implementation of BtraceList.count (self, value) -> int. */
548
549static PyObject *
551{
552 /* We know that if an element is in the list, it is so exactly one time,
553 enabling us to reuse the "is element of" check. */
555 value)).release ();
556}
557
558/* Python rich compare function to allow for equality and inequality checks
559 in Python. */
560
561static PyObject *
563{
564 const btpy_list_object * const obj1 = (btpy_list_object *) self;
565 const btpy_list_object * const obj2 = (btpy_list_object *) other;
566
567 if (Py_TYPE (self) != Py_TYPE (other))
568 {
569 Py_INCREF (Py_NotImplemented);
570 return Py_NotImplemented;
571 }
572
573 switch (op)
574 {
575 case Py_EQ:
576 if (obj1->thread == obj2->thread
577 && obj1->element_type == obj2->element_type
578 && obj1->first == obj2->first
579 && obj1->last == obj2->last
580 && obj1->step == obj2->step)
581 Py_RETURN_TRUE;
582 else
583 Py_RETURN_FALSE;
584
585 case Py_NE:
586 if (obj1->thread != obj2->thread
587 || obj1->element_type != obj2->element_type
588 || obj1->first != obj2->first
589 || obj1->last != obj2->last
590 || obj1->step != obj2->step)
591 Py_RETURN_TRUE;
592 else
593 Py_RETURN_FALSE;
594
595 default:
596 break;
597 }
598
599 Py_INCREF (Py_NotImplemented);
600 return Py_NotImplemented;
601}
602
603/* Implementation of
604 BtraceRecord.method [str]. */
605
606PyObject *
607recpy_bt_method (PyObject *self, void *closure)
608{
609 return PyUnicode_FromString ("btrace");
610}
611
612/* Implementation of
613 BtraceRecord.format [str]. */
614
615PyObject *
616recpy_bt_format (PyObject *self, void *closure)
617{
618 const recpy_record_object * const record = (recpy_record_object *) self;
619 const struct thread_info * const tinfo = record->thread;
620 const struct btrace_config * config;
621
622 if (tinfo == NULL)
623 Py_RETURN_NONE;
624
625 config = btrace_conf (&tinfo->btrace);
626
627 if (config == NULL)
628 Py_RETURN_NONE;
629
630 return PyUnicode_FromString (btrace_format_short_string (config->format));
631}
632
633/* Implementation of
634 BtraceRecord.replay_position [BtraceInstruction]. */
635
636PyObject *
637recpy_bt_replay_position (PyObject *self, void *closure)
638{
639 const recpy_record_object * const record = (recpy_record_object *) self;
640 thread_info * tinfo = record->thread;
641
642 if (tinfo == NULL)
643 Py_RETURN_NONE;
644
645 if (tinfo->btrace.replay == NULL)
646 Py_RETURN_NONE;
647
648 return btpy_insn_or_gap_new (tinfo,
649 btrace_insn_number (tinfo->btrace.replay));
650}
651
652/* Implementation of
653 BtraceRecord.begin [BtraceInstruction]. */
654
655PyObject *
656recpy_bt_begin (PyObject *self, void *closure)
657{
658 const recpy_record_object * const record = (recpy_record_object *) self;
659 thread_info *const tinfo = record->thread;
660 struct btrace_insn_iterator iterator;
661
662 if (tinfo == NULL)
663 Py_RETURN_NONE;
664
666
667 if (btrace_is_empty (tinfo))
668 Py_RETURN_NONE;
669
670 btrace_insn_begin (&iterator, &tinfo->btrace);
671 return btpy_insn_or_gap_new (tinfo, btrace_insn_number (&iterator));
672}
673
674/* Implementation of
675 BtraceRecord.end [BtraceInstruction]. */
676
677PyObject *
678recpy_bt_end (PyObject *self, void *closure)
679{
680 const recpy_record_object * const record = (recpy_record_object *) self;
681 thread_info *const tinfo = record->thread;
682 struct btrace_insn_iterator iterator;
683
684 if (tinfo == NULL)
685 Py_RETURN_NONE;
686
688
689 if (btrace_is_empty (tinfo))
690 Py_RETURN_NONE;
691
692 btrace_insn_end (&iterator, &tinfo->btrace);
693 return btpy_insn_or_gap_new (tinfo, btrace_insn_number (&iterator));
694}
695
696/* Implementation of
697 BtraceRecord.instruction_history [list]. */
698
699PyObject *
701{
702 const recpy_record_object * const record = (recpy_record_object *) self;
703 thread_info *const tinfo = record->thread;
704 struct btrace_insn_iterator iterator;
705 unsigned long first = 0;
706 unsigned long last = 0;
707
708 if (tinfo == NULL)
709 Py_RETURN_NONE;
710
712
713 if (btrace_is_empty (tinfo))
714 Py_RETURN_NONE;
715
716 btrace_insn_begin (&iterator, &tinfo->btrace);
717 first = btrace_insn_number (&iterator);
718
719 btrace_insn_end (&iterator, &tinfo->btrace);
720 last = btrace_insn_number (&iterator);
721
722 return btpy_list_new (tinfo, first, last, 1, &recpy_insn_type);
723}
724
725/* Implementation of
726 BtraceRecord.function_call_history [list]. */
727
728PyObject *
730{
731 const recpy_record_object * const record = (recpy_record_object *) self;
732 thread_info *const tinfo = record->thread;
733 struct btrace_call_iterator iterator;
734 unsigned long first = 0;
735 unsigned long last = 0;
736
737 if (tinfo == NULL)
738 Py_RETURN_NONE;
739
741
742 if (btrace_is_empty (tinfo))
743 Py_RETURN_NONE;
744
745 btrace_call_begin (&iterator, &tinfo->btrace);
746 first = btrace_call_number (&iterator);
747
748 btrace_call_end (&iterator, &tinfo->btrace);
749 last = btrace_call_number (&iterator);
750
751 return btpy_list_new (tinfo, first, last, 1, &recpy_func_type);
752}
753
754/* Implementation of BtraceRecord.goto (self, BtraceInstruction) -> None. */
755
756PyObject *
758{
759 const recpy_record_object * const record = (recpy_record_object *) self;
760 thread_info *const tinfo = record->thread;
761 const recpy_element_object *obj;
762 PyObject *parse_obj;
763
764 if (tinfo == NULL || btrace_is_empty (tinfo))
765 return PyErr_Format (gdbpy_gdb_error, _("Empty branch trace."));
766
767 if (!PyArg_ParseTuple (args, "O", &parse_obj))
768 return NULL;
769
770 if (Py_TYPE (parse_obj) != &recpy_insn_type)
771 return PyErr_Format (PyExc_TypeError, _("Argument must be instruction."));
772 obj = (const recpy_element_object *) parse_obj;
773
774 try
775 {
776 struct btrace_insn_iterator iter;
777
778 btrace_insn_end (&iter, &tinfo->btrace);
779
780 if (btrace_insn_number (&iter) == obj->number)
782 else
784 }
785 catch (const gdb_exception &except)
786 {
788 }
789
790 Py_RETURN_NONE;
791}
792
793/* BtraceList methods. */
794
795static PyMethodDef btpy_list_methods[] =
796{
797 { "count", btpy_list_count, METH_O, "count number of occurrences"},
798 { "index", btpy_list_index, METH_O, "index of entry"},
799 {NULL}
800};
801
802/* BtraceList sequence methods. */
803
804static PySequenceMethods btpy_list_sequence_methods =
805{
806 NULL
807};
808
809/* BtraceList mapping methods. Necessary for slicing. */
810
811static PyMappingMethods btpy_list_mapping_methods =
812{
813 NULL
814};
815
816/* Sets up the btrace record API. */
817
820{
821 btpy_list_type.tp_new = PyType_GenericNew;
822 btpy_list_type.tp_flags = Py_TPFLAGS_DEFAULT;
823 btpy_list_type.tp_basicsize = sizeof (btpy_list_object);
824 btpy_list_type.tp_name = "gdb.BtraceObjectList";
825 btpy_list_type.tp_doc = "GDB btrace list object";
829 btpy_list_type.tp_richcompare = btpy_list_richcompare;
830
834
836
837 return PyType_Ready (&btpy_list_type);
838}
839
struct gdbarch * target_gdbarch(void)
const struct btrace_function * btrace_call_get(const struct btrace_call_iterator *it)
Definition btrace.c:2324
unsigned int btrace_call_number(const struct btrace_call_iterator *it)
Definition btrace.c:2335
void btrace_insn_end(struct btrace_insn_iterator *it, const struct btrace_thread_info *btinfo)
Definition btrace.c:2075
int btrace_find_insn_by_number(struct btrace_insn_iterator *it, const struct btrace_thread_info *btinfo, unsigned int number)
Definition btrace.c:2255
void btrace_call_begin(struct btrace_call_iterator *it, const struct btrace_thread_info *btinfo)
Definition btrace.c:2350
const char * btrace_decode_error(enum btrace_format format, int errcode)
Definition btrace.c:1857
int btrace_find_call_by_number(struct btrace_call_iterator *it, const struct btrace_thread_info *btinfo, unsigned int number)
Definition btrace.c:2456
void btrace_fetch(struct thread_info *tp, const struct btrace_cpu *cpu)
Definition btrace.c:1906
const struct btrace_config * btrace_conf(const struct btrace_thread_info *btinfo)
Definition btrace.c:1653
const struct btrace_insn * btrace_insn_get(const struct btrace_insn_iterator *it)
Definition btrace.c:2022
unsigned int btrace_insn_number(const struct btrace_insn_iterator *it)
Definition btrace.c:2053
int btrace_insn_get_error(const struct btrace_insn_iterator *it)
Definition btrace.c:2045
int btrace_is_empty(struct thread_info *tp)
Definition btrace.c:2511
void btrace_insn_begin(struct btrace_insn_iterator *it, const struct btrace_thread_info *btinfo)
Definition btrace.c:2061
void btrace_call_end(struct btrace_call_iterator *it, const struct btrace_thread_info *btinfo)
Definition btrace.c:2363
@ BTRACE_INSN_FLAG_SPECULATIVE
Definition btrace.h:62
const std::string & string()
Definition ui-file.h:198
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition corefile.c:238
int gdb_print_insn(struct gdbarch *gdbarch, CORE_ADDR memaddr, struct ui_file *stream, int *branch_delay_insns)
Definition disasm.c:1217
PyObject * recpy_bt_func_prev(PyObject *self, void *closure)
PyObject * recpy_bt_func_instructions(PyObject *self, void *closure)
PyObject * recpy_bt_func_up(PyObject *self, void *closure)
static int btpy_list_contains(PyObject *self, PyObject *value)
PyObject * recpy_bt_format(PyObject *self, void *closure)
static PySequenceMethods btpy_list_sequence_methods
static PyObject * btpy_list_index(PyObject *self, PyObject *value)
static PyObject * btpy_list_richcompare(PyObject *self, PyObject *other, int op)
static const btrace_insn * btrace_insn_from_recpy_insn(const PyObject *const pyobject)
static const btrace_function * btrace_func_from_recpy_func(const PyObject *const pyobject)
PyObject * recpy_bt_insn_pc(PyObject *self, void *closure)
static PyTypeObject btpy_list_type
PyObject * recpy_bt_func_symbol(PyObject *self, void *closure)
PyObject * recpy_bt_begin(PyObject *self, void *closure)
static Py_ssize_t btpy_list_length(PyObject *self)
PyObject * recpy_bt_insn_sal(PyObject *self, void *closure)
PyObject * recpy_bt_goto(PyObject *self, PyObject *args)
static PyObject * btpy_insn_or_gap_new(thread_info *tinfo, Py_ssize_t number)
static LONGEST btpy_list_position(PyObject *self, PyObject *value)
PyObject * recpy_bt_end(PyObject *self, void *closure)
PyObject * recpy_bt_method(PyObject *self, void *closure)
static PyObject * btpy_list_slice(PyObject *self, PyObject *value)
PyObject * recpy_bt_func_level(PyObject *self, void *closure)
static PyObject * btpy_list_count(PyObject *self, PyObject *value)
static PyObject * btpy_list_item(PyObject *self, Py_ssize_t index)
PyObject * recpy_bt_insn_decoded(PyObject *self, void *closure)
PyObject * recpy_bt_replay_position(PyObject *self, void *closure)
PyObject * recpy_bt_insn_data(PyObject *self, void *closure)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_btrace(void)
PyObject * recpy_bt_func_next(PyObject *self, void *closure)
static PyMappingMethods btpy_list_mapping_methods
PyObject * recpy_bt_instruction_history(PyObject *self, void *closure)
static PyObject * btpy_list_new(thread_info *thread, Py_ssize_t first, Py_ssize_t last, Py_ssize_t step, PyTypeObject *element_type)
PyObject * recpy_bt_insn_is_speculative(PyObject *self, void *closure)
PyObject * recpy_bt_insn_size(PyObject *self, void *closure)
static PyMethodDef btpy_list_methods[]
PyObject * recpy_bt_function_call_history(PyObject *self, void *closure)
PyTypeObject recpy_func_type
Definition py-record.c:42
PyObject * recpy_gap_new(int reason_code, const char *reason_string, Py_ssize_t number)
Definition py-record.c:437
PyObject * recpy_func_new(thread_info *thread, enum record_method method, Py_ssize_t number)
Definition py-record.c:277
PyObject * recpy_insn_new(thread_info *thread, enum record_method method, Py_ssize_t number)
Definition py-record.c:180
PyTypeObject recpy_insn_type
Definition py-record.c:36
PyObject * symbol_to_symbol_object(struct symbol *sym)
Definition py-symbol.c:344
PyObject * symtab_and_line_to_sal_object(struct symtab_and_line sal)
Definition py-symtab.c:481
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
Definition py-utils.c:282
void gdbpy_convert_exception(const struct gdb_exception &exception)
Definition py-utils.c:217
gdbpy_ref gdb_py_object_from_ulongest(ULONGEST l)
Definition py-utils.c:293
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
#define GDBPY_INITIALIZE_FILE(INIT,...)
PyObject * gdbpy_gdb_error
#define GDB_PY_HANDLE_EXCEPTION(Exception)
const struct btrace_cpu * record_btrace_get_cpu(void)
@ RECORD_METHOD_BTRACE
Definition record.h:52
void(* func)(remote_target *remote, char *)
PyTypeObject * element_type
PyObject_HEAD thread_info * thread
gdb_byte size
Definition btrace.h:75
btrace_insn_flags flags
Definition btrace.h:81
CORE_ADDR pc
Definition btrace.h:72
PyObject_HEAD thread_info * thread
Definition py-record.h:47
Py_ssize_t number
Definition py-record.h:53
Definition value.h:130
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition symtab.c:3295
void target_goto_record(ULONGEST insn)
Definition target.c:4172
void target_goto_record_end(void)
Definition target.c:4164
int PyObject
Definition varobj.c:41