GDB (xrefs)
Loading...
Searching...
No Matches
py-frame.c
Go to the documentation of this file.
1/* Python interface to stack frames
2
3 Copyright (C) 2008-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 "charset.h"
22#include "block.h"
23#include "frame.h"
24#include "symtab.h"
25#include "stack.h"
26#include "value.h"
27#include "python-internal.h"
28#include "symfile.h"
29#include "objfiles.h"
30
32 PyObject_HEAD
35
36 /* Marks that the FRAME_ID member actually holds the ID of the frame next
37 to this, and not this frames' ID itself. This is a hack to permit Python
38 frame objects which represent invalid frames (i.e., the last frame_info
39 in a corrupt stack). The problem arises from the fact that this code
40 relies on FRAME_ID to uniquely identify a frame, which is not always true
41 for the last "frame" in a corrupt stack (it can have a null ID, or the same
42 ID as the previous frame). Whenever get_prev_frame returns NULL, we
43 record the frame_id of the next frame and set FRAME_ID_IS_NEXT to 1. */
45};
46
47/* Require a valid frame. This must be called inside a TRY_CATCH, or
48 another context in which a gdb exception is allowed. */
49#define FRAPY_REQUIRE_VALID(frame_obj, frame) \
50 do { \
51 frame = frame_object_to_frame_info (frame_obj); \
52 if (frame == NULL) \
53 error (_("Frame is invalid.")); \
54 } while (0)
55
56/* Returns the frame_info object corresponding to the given Python Frame
57 object. If the frame doesn't exist anymore (the frame id doesn't
58 correspond to any frame in the inferior), returns NULL. */
59
62{
63 frame_object *frame_obj = (frame_object *) obj;
64 frame_info_ptr frame;
65
66 frame = frame_find_by_id (frame_obj->frame_id);
67 if (frame == NULL)
68 return NULL;
69
70 if (frame_obj->frame_id_is_next)
71 frame = get_prev_frame (frame);
72
73 return frame;
74}
75
76/* Called by the Python interpreter to obtain string representation
77 of the object. */
78
79static PyObject *
80frapy_str (PyObject *self)
81{
82 const frame_id &fid = ((frame_object *) self)->frame_id;
83 return PyUnicode_FromString (fid.to_string ().c_str ());
84}
85
86/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
87 Returns True if the frame corresponding to the frame_id of this
88 object still exists in the inferior. */
89
90static PyObject *
91frapy_is_valid (PyObject *self, PyObject *args)
92{
93 frame_info_ptr frame = NULL;
94
95 try
96 {
97 frame = frame_object_to_frame_info (self);
98 }
99 catch (const gdb_exception &except)
100 {
102 }
103
104 if (frame == NULL)
105 Py_RETURN_FALSE;
106
107 Py_RETURN_TRUE;
108}
109
110/* Implementation of gdb.Frame.name (self) -> String.
111 Returns the name of the function corresponding to this frame. */
112
113static PyObject *
114frapy_name (PyObject *self, PyObject *args)
115{
116 frame_info_ptr frame;
117 gdb::unique_xmalloc_ptr<char> name;
118 enum language lang;
119 PyObject *result;
120
121 try
122 {
123 FRAPY_REQUIRE_VALID (self, frame);
124
125 name = find_frame_funname (frame, &lang, NULL);
126 }
127 catch (const gdb_exception &except)
128 {
130 }
131
132 if (name)
133 {
134 result = PyUnicode_Decode (name.get (), strlen (name.get ()),
135 host_charset (), NULL);
136 }
137 else
138 {
139 result = Py_None;
140 Py_INCREF (Py_None);
141 }
142
143 return result;
144}
145
146/* Implementation of gdb.Frame.type (self) -> Integer.
147 Returns the frame type, namely one of the gdb.*_FRAME constants. */
148
149static PyObject *
150frapy_type (PyObject *self, PyObject *args)
151{
152 frame_info_ptr frame;
153 enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */
154
155 try
156 {
157 FRAPY_REQUIRE_VALID (self, frame);
158
159 type = get_frame_type (frame);
160 }
161 catch (const gdb_exception &except)
162 {
164 }
165
166 return gdb_py_object_from_longest (type).release ();
167}
168
169/* Implementation of gdb.Frame.architecture (self) -> gdb.Architecture.
170 Returns the frame's architecture as a gdb.Architecture object. */
171
172static PyObject *
173frapy_arch (PyObject *self, PyObject *args)
174{
175 frame_info_ptr frame = NULL; /* Initialize to appease gcc warning. */
176 frame_object *obj = (frame_object *) self;
177
178 try
179 {
180 FRAPY_REQUIRE_VALID (self, frame);
181 }
182 catch (const gdb_exception &except)
183 {
185 }
186
187 return gdbarch_to_arch_object (obj->gdbarch);
188}
189
190/* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
191 Returns one of the gdb.FRAME_UNWIND_* constants. */
192
193static PyObject *
194frapy_unwind_stop_reason (PyObject *self, PyObject *args)
195{
196 frame_info_ptr frame = NULL; /* Initialize to appease gcc warning. */
197 enum unwind_stop_reason stop_reason;
198
199 try
200 {
201 FRAPY_REQUIRE_VALID (self, frame);
202 }
203 catch (const gdb_exception &except)
204 {
206 }
207
208 stop_reason = get_frame_unwind_stop_reason (frame);
209
210 return gdb_py_object_from_longest (stop_reason).release ();
211}
212
213/* Implementation of gdb.Frame.pc (self) -> Long.
214 Returns the frame's resume address. */
215
216static PyObject *
217frapy_pc (PyObject *self, PyObject *args)
218{
219 CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
220 frame_info_ptr frame;
221
222 try
223 {
224 FRAPY_REQUIRE_VALID (self, frame);
225
226 pc = get_frame_pc (frame);
227 }
228 catch (const gdb_exception &except)
229 {
231 }
232
233 return gdb_py_object_from_ulongest (pc).release ();
234}
235
236/* Implementation of gdb.Frame.read_register (self, register) -> gdb.Value.
237 Returns the value of a register in this frame. */
238
239static PyObject *
240frapy_read_register (PyObject *self, PyObject *args)
241{
242 PyObject *pyo_reg_id;
243 struct value *val = NULL;
244
245 if (!PyArg_UnpackTuple (args, "read_register", 1, 1, &pyo_reg_id))
246 return NULL;
247 try
248 {
249 frame_info_ptr frame;
250 int regnum;
251
252 FRAPY_REQUIRE_VALID (self, frame);
253
254 if (!gdbpy_parse_register_id (get_frame_arch (frame), pyo_reg_id,
255 &regnum))
256 return nullptr;
257
258 gdb_assert (regnum >= 0);
259 val = value_of_register (regnum, frame);
260
261 if (val == NULL)
262 PyErr_SetString (PyExc_ValueError, _("Can't read register."));
263 }
264 catch (const gdb_exception &except)
265 {
267 }
268
269 return val == NULL ? NULL : value_to_value_object (val);
270}
271
272/* Implementation of gdb.Frame.block (self) -> gdb.Block.
273 Returns the frame's code block. */
274
275static PyObject *
276frapy_block (PyObject *self, PyObject *args)
277{
278 frame_info_ptr frame;
279 const struct block *block = NULL, *fn_block;
280
281 try
282 {
283 FRAPY_REQUIRE_VALID (self, frame);
284 block = get_frame_block (frame, NULL);
285 }
286 catch (const gdb_exception &except)
287 {
289 }
290
291 for (fn_block = block;
292 fn_block != NULL && fn_block->function () == NULL;
293 fn_block = fn_block->superblock ())
294 ;
295
296 if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
297 {
298 PyErr_SetString (PyExc_RuntimeError,
299 _("Cannot locate block for frame."));
300 return NULL;
301 }
302
303 if (block)
304 {
306 (block, fn_block->function ()->objfile ());
307 }
308
309 Py_RETURN_NONE;
310}
311
312
313/* Implementation of gdb.Frame.function (self) -> gdb.Symbol.
314 Returns the symbol for the function corresponding to this frame. */
315
316static PyObject *
317frapy_function (PyObject *self, PyObject *args)
318{
319 struct symbol *sym = NULL;
320 frame_info_ptr frame;
321
322 try
323 {
324 enum language funlang;
325
326 FRAPY_REQUIRE_VALID (self, frame);
327
328 gdb::unique_xmalloc_ptr<char> funname
329 = find_frame_funname (frame, &funlang, &sym);
330 }
331 catch (const gdb_exception &except)
332 {
334 }
335
336 if (sym)
337 return symbol_to_symbol_object (sym);
338
339 Py_RETURN_NONE;
340}
341
342/* Convert a frame_info struct to a Python Frame object.
343 Sets a Python exception and returns NULL on error. */
344
345PyObject *
347{
348 gdbpy_ref<frame_object> frame_obj (PyObject_New (frame_object,
350 if (frame_obj == NULL)
351 return NULL;
352
353 try
354 {
355
356 /* Try to get the previous frame, to determine if this is the last frame
357 in a corrupt stack. If so, we need to store the frame_id of the next
358 frame and not of this one (which is possibly invalid). */
359 if (get_prev_frame (frame) == NULL
360 && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
361 && get_next_frame (frame) != NULL)
362 {
363 frame_obj->frame_id = get_frame_id (get_next_frame (frame));
364 frame_obj->frame_id_is_next = 1;
365 }
366 else
367 {
368 frame_obj->frame_id = get_frame_id (frame);
369 frame_obj->frame_id_is_next = 0;
370 }
371 frame_obj->gdbarch = get_frame_arch (frame);
372 }
373 catch (const gdb_exception &except)
374 {
376 return NULL;
377 }
378
379 return (PyObject *) frame_obj.release ();
380}
381
382/* Implementation of gdb.Frame.older (self) -> gdb.Frame.
383 Returns the frame immediately older (outer) to this frame, or None if
384 there isn't one. */
385
386static PyObject *
387frapy_older (PyObject *self, PyObject *args)
388{
389 frame_info_ptr frame, prev = NULL;
390 PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */
391
392 try
393 {
394 FRAPY_REQUIRE_VALID (self, frame);
395
396 prev = get_prev_frame (frame);
397 }
398 catch (const gdb_exception &except)
399 {
401 }
402
403 if (prev)
404 prev_obj = frame_info_to_frame_object (prev);
405 else
406 {
407 Py_INCREF (Py_None);
408 prev_obj = Py_None;
409 }
410
411 return prev_obj;
412}
413
414/* Implementation of gdb.Frame.newer (self) -> gdb.Frame.
415 Returns the frame immediately newer (inner) to this frame, or None if
416 there isn't one. */
417
418static PyObject *
419frapy_newer (PyObject *self, PyObject *args)
420{
421 frame_info_ptr frame, next = NULL;
422 PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */
423
424 try
425 {
426 FRAPY_REQUIRE_VALID (self, frame);
427
428 next = get_next_frame (frame);
429 }
430 catch (const gdb_exception &except)
431 {
433 }
434
435 if (next)
436 next_obj = frame_info_to_frame_object (next);
437 else
438 {
439 Py_INCREF (Py_None);
440 next_obj = Py_None;
441 }
442
443 return next_obj;
444}
445
446/* Implementation of gdb.Frame.find_sal (self) -> gdb.Symtab_and_line.
447 Returns the frame's symtab and line. */
448
449static PyObject *
450frapy_find_sal (PyObject *self, PyObject *args)
451{
452 frame_info_ptr frame;
453 PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */
454
455 try
456 {
457 FRAPY_REQUIRE_VALID (self, frame);
458
459 symtab_and_line sal = find_frame_sal (frame);
460 sal_obj = symtab_and_line_to_sal_object (sal);
461 }
462 catch (const gdb_exception &except)
463 {
465 }
466
467 return sal_obj;
468}
469
470/* Implementation of gdb.Frame.read_var_value (self, variable,
471 [block]) -> gdb.Value. If the optional block argument is provided
472 start the search from that block, otherwise search from the frame's
473 current block (determined by examining the resume address of the
474 frame). The variable argument must be a string or an instance of a
475 gdb.Symbol. The block argument must be an instance of gdb.Block. Returns
476 NULL on error, with a python exception set. */
477static PyObject *
478frapy_read_var (PyObject *self, PyObject *args)
479{
480 frame_info_ptr frame;
481 PyObject *sym_obj, *block_obj = NULL;
482 struct symbol *var = NULL; /* gcc-4.3.2 false warning. */
483 const struct block *block = NULL;
484 struct value *val = NULL;
485
486 if (!PyArg_ParseTuple (args, "O|O", &sym_obj, &block_obj))
487 return NULL;
488
489 if (PyObject_TypeCheck (sym_obj, &symbol_object_type))
490 var = symbol_object_to_symbol (sym_obj);
491 else if (gdbpy_is_string (sym_obj))
492 {
493 gdb::unique_xmalloc_ptr<char>
494 var_name (python_string_to_target_string (sym_obj));
495
496 if (!var_name)
497 return NULL;
498
499 if (block_obj)
500 {
501 block = block_object_to_block (block_obj);
502 if (!block)
503 {
504 PyErr_SetString (PyExc_RuntimeError,
505 _("Second argument must be block."));
506 return NULL;
507 }
508 }
509
510 try
511 {
512 struct block_symbol lookup_sym;
513 FRAPY_REQUIRE_VALID (self, frame);
514
515 if (!block)
516 block = get_frame_block (frame, NULL);
517 lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL);
518 var = lookup_sym.symbol;
519 block = lookup_sym.block;
520 }
521 catch (const gdb_exception &except)
522 {
524 return NULL;
525 }
526
527 if (!var)
528 {
529 PyErr_Format (PyExc_ValueError,
530 _("Variable '%s' not found."), var_name.get ());
531
532 return NULL;
533 }
534 }
535 else
536 {
537 PyErr_SetString (PyExc_TypeError,
538 _("Argument must be a symbol or string."));
539 return NULL;
540 }
541
542 try
543 {
544 FRAPY_REQUIRE_VALID (self, frame);
545
546 val = read_var_value (var, block, frame);
547 }
548 catch (const gdb_exception &except)
549 {
551 }
552
553 return value_to_value_object (val);
554}
555
556/* Select this frame. */
557
558static PyObject *
559frapy_select (PyObject *self, PyObject *args)
560{
562
563 try
564 {
565 FRAPY_REQUIRE_VALID (self, fi);
566
567 select_frame (fi);
568 }
569 catch (const gdb_exception &except)
570 {
572 }
573
574 Py_RETURN_NONE;
575}
576
577/* The stack frame level for this frame. */
578
579static PyObject *
580frapy_level (PyObject *self, PyObject *args)
581{
583
584 try
585 {
586 FRAPY_REQUIRE_VALID (self, fi);
587
588 return gdb_py_object_from_longest (frame_relative_level (fi)).release ();
589 }
590 catch (const gdb_exception &except)
591 {
593 }
594
595 Py_RETURN_NONE;
596}
597
598/* The language for this frame. */
599
600static PyObject *
601frapy_language (PyObject *self, PyObject *args)
602{
603 try
604 {
606 FRAPY_REQUIRE_VALID (self, fi);
607
608 enum language lang = get_frame_language (fi);
609 const language_defn *lang_def = language_def (lang);
610
611 return host_string_to_python_string (lang_def->name ()).release ();
612 }
613 catch (const gdb_exception &except)
614 {
616 }
617
618 Py_RETURN_NONE;
619}
620
621/* Implementation of gdb.newest_frame () -> gdb.Frame.
622 Returns the newest frame object. */
623
624PyObject *
625gdbpy_newest_frame (PyObject *self, PyObject *args)
626{
627 frame_info_ptr frame = NULL;
628
629 try
630 {
631 frame = get_current_frame ();
632 }
633 catch (const gdb_exception &except)
634 {
636 }
637
638 return frame_info_to_frame_object (frame);
639}
640
641/* Implementation of gdb.selected_frame () -> gdb.Frame.
642 Returns the selected frame object. */
643
644PyObject *
645gdbpy_selected_frame (PyObject *self, PyObject *args)
646{
647 frame_info_ptr frame = NULL;
648
649 try
650 {
651 frame = get_selected_frame ("No frame is currently selected.");
652 }
653 catch (const gdb_exception &except)
654 {
656 }
657
658 return frame_info_to_frame_object (frame);
659}
660
661/* Implementation of gdb.stop_reason_string (Integer) -> String.
662 Return a string explaining the unwind stop reason. */
663
664PyObject *
665gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
666{
667 int reason;
668 const char *str;
669
670 if (!PyArg_ParseTuple (args, "i", &reason))
671 return NULL;
672
673 if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
674 {
675 PyErr_SetString (PyExc_ValueError,
676 _("Invalid frame stop reason."));
677 return NULL;
678 }
679
681 return PyUnicode_Decode (str, strlen (str), host_charset (), NULL);
682}
683
684/* Implements the equality comparison for Frame objects.
685 All other comparison operators will throw a TypeError Python exception,
686 as they aren't valid for frames. */
687
688static PyObject *
689frapy_richcompare (PyObject *self, PyObject *other, int op)
690{
691 int result;
692
693 if (!PyObject_TypeCheck (other, &frame_object_type)
694 || (op != Py_EQ && op != Py_NE))
695 {
696 Py_INCREF (Py_NotImplemented);
697 return Py_NotImplemented;
698 }
699
700 frame_object *self_frame = (frame_object *) self;
701 frame_object *other_frame = (frame_object *) other;
702
703 if (self_frame->frame_id_is_next == other_frame->frame_id_is_next
704 && self_frame->frame_id == other_frame->frame_id)
705 result = Py_EQ;
706 else
707 result = Py_NE;
708
709 if (op == result)
710 Py_RETURN_TRUE;
711 Py_RETURN_FALSE;
712}
713
714/* Sets up the Frame API in the gdb module. */
715
716int
718{
719 frame_object_type.tp_new = PyType_GenericNew;
720 if (PyType_Ready (&frame_object_type) < 0)
721 return -1;
722
723 /* Note: These would probably be best exposed as class attributes of
724 Frame, but I don't know how to do it except by messing with the
725 type's dictionary. That seems too messy. */
726 if (PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME) < 0
727 || PyModule_AddIntConstant (gdb_module, "DUMMY_FRAME", DUMMY_FRAME) < 0
728 || PyModule_AddIntConstant (gdb_module, "INLINE_FRAME", INLINE_FRAME) < 0
729 || PyModule_AddIntConstant (gdb_module, "TAILCALL_FRAME",
730 TAILCALL_FRAME) < 0
731 || PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME",
732 SIGTRAMP_FRAME) < 0
733 || PyModule_AddIntConstant (gdb_module, "ARCH_FRAME", ARCH_FRAME) < 0
734 || PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME",
735 SENTINEL_FRAME) < 0)
736 return -1;
737
738#define SET(name, description) \
739 if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
740 return -1;
741#include "unwind_stop_reasons.def"
742#undef SET
743
744 return gdb_pymodule_addobject (gdb_module, "Frame",
745 (PyObject *) &frame_object_type);
746}
747
748
749
750static PyMethodDef frame_object_methods[] = {
751 { "is_valid", frapy_is_valid, METH_NOARGS,
752 "is_valid () -> Boolean.\n\
753Return true if this frame is valid, false if not." },
754 { "name", frapy_name, METH_NOARGS,
755 "name () -> String.\n\
756Return the function name of the frame, or None if it can't be determined." },
757 { "type", frapy_type, METH_NOARGS,
758 "type () -> Integer.\n\
759Return the type of the frame." },
760 { "architecture", frapy_arch, METH_NOARGS,
761 "architecture () -> gdb.Architecture.\n\
762Return the architecture of the frame." },
763 { "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
764 "unwind_stop_reason () -> Integer.\n\
765Return the reason why it's not possible to find frames older than this." },
766 { "pc", frapy_pc, METH_NOARGS,
767 "pc () -> Long.\n\
768Return the frame's resume address." },
769 { "read_register", frapy_read_register, METH_VARARGS,
770 "read_register (register_name) -> gdb.Value\n\
771Return the value of the register in the frame." },
772 { "block", frapy_block, METH_NOARGS,
773 "block () -> gdb.Block.\n\
774Return the frame's code block." },
775 { "function", frapy_function, METH_NOARGS,
776 "function () -> gdb.Symbol.\n\
777Returns the symbol for the function corresponding to this frame." },
778 { "older", frapy_older, METH_NOARGS,
779 "older () -> gdb.Frame.\n\
780Return the frame that called this frame." },
781 { "newer", frapy_newer, METH_NOARGS,
782 "newer () -> gdb.Frame.\n\
783Return the frame called by this frame." },
784 { "find_sal", frapy_find_sal, METH_NOARGS,
785 "find_sal () -> gdb.Symtab_and_line.\n\
786Return the frame's symtab and line." },
787 { "read_var", frapy_read_var, METH_VARARGS,
788 "read_var (variable) -> gdb.Value.\n\
789Return the value of the variable in this frame." },
790 { "select", frapy_select, METH_NOARGS,
791 "Select this frame as the user's current frame." },
792 { "level", frapy_level, METH_NOARGS,
793 "The stack level of this frame." },
794 { "language", frapy_language, METH_NOARGS,
795 "The language of this frame." },
796 {NULL} /* Sentinel */
797};
798
799PyTypeObject frame_object_type = {
800 PyVarObject_HEAD_INIT (NULL, 0)
801 "gdb.Frame", /* tp_name */
802 sizeof (frame_object), /* tp_basicsize */
803 0, /* tp_itemsize */
804 0, /* tp_dealloc */
805 0, /* tp_print */
806 0, /* tp_getattr */
807 0, /* tp_setattr */
808 0, /* tp_compare */
809 0, /* tp_repr */
810 0, /* tp_as_number */
811 0, /* tp_as_sequence */
812 0, /* tp_as_mapping */
813 0, /* tp_hash */
814 0, /* tp_call */
815 frapy_str, /* tp_str */
816 0, /* tp_getattro */
817 0, /* tp_setattro */
818 0, /* tp_as_buffer */
819 Py_TPFLAGS_DEFAULT, /* tp_flags */
820 "GDB frame object", /* tp_doc */
821 0, /* tp_traverse */
822 0, /* tp_clear */
823 frapy_richcompare, /* tp_richcompare */
824 0, /* tp_weaklistoffset */
825 0, /* tp_iter */
826 0, /* tp_iternext */
827 frame_object_methods, /* tp_methods */
828 0, /* tp_members */
829 0, /* tp_getset */
830 0, /* tp_base */
831 0, /* tp_dict */
832 0, /* tp_descr_get */
833 0, /* tp_descr_set */
834 0, /* tp_dictoffset */
835 0, /* tp_init */
836 0, /* tp_alloc */
837};
int regnum
Definition: aarch64-tdep.c:68
const char *const name
Definition: aarch64-tdep.c:67
const struct block * get_frame_block(frame_info_ptr frame, CORE_ADDR *addr_in_block)
Definition: blockframe.c:55
const char * host_charset(void)
Definition: charset.c:416
language
Definition: defs.h:211
struct value * value_of_register(int regnum, frame_info_ptr frame)
Definition: findvar.c:254
struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame)
Definition: findvar.c:787
frame_info_ptr get_next_frame(frame_info_ptr this_frame)
Definition: frame.c:1968
enum unwind_stop_reason get_frame_unwind_stop_reason(frame_info_ptr frame)
Definition: frame.c:3007
int frame_relative_level(frame_info_ptr fi)
Definition: frame.c:2826
void select_frame(frame_info_ptr fi)
Definition: frame.c:1852
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition: frame.c:2592
const char * unwind_stop_reason_to_string(enum unwind_stop_reason reason)
Definition: frame.c:3019
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition: frame.c:2907
enum frame_type get_frame_type(frame_info_ptr frame)
Definition: frame.c:2835
frame_info_ptr get_selected_frame(const char *message)
Definition: frame.c:1813
frame_info_ptr frame_find_by_id(struct frame_id id)
Definition: frame.c:868
enum language get_frame_language(frame_info_ptr frame)
Definition: frame.c:2954
frame_info_ptr get_current_frame(void)
Definition: frame.c:1615
struct frame_id get_frame_id(frame_info_ptr fi)
Definition: frame.c:607
frame_info_ptr get_prev_frame(frame_info_ptr this_frame)
Definition: frame.c:2494
symtab_and_line find_frame_sal(frame_info_ptr frame)
Definition: frame.c:2701
frame_type
Definition: frame.h:176
@ ARCH_FRAME
Definition: frame.h:192
@ DUMMY_FRAME
Definition: frame.h:182
@ TAILCALL_FRAME
Definition: frame.h:187
@ SIGTRAMP_FRAME
Definition: frame.h:190
@ NORMAL_FRAME
Definition: frame.h:179
@ SENTINEL_FRAME
Definition: frame.h:195
@ INLINE_FRAME
Definition: frame.h:185
unwind_stop_reason
Definition: frame.h:436
const struct language_defn * language_def(enum language lang)
Definition: language.c:442
PyObject * gdbarch_to_arch_object(struct gdbarch *gdbarch)
Definition: py-arch.c:90
PyObject * block_to_block_object(const struct block *block, struct objfile *objfile)
Definition: py-block.c:329
const struct block * block_object_to_block(PyObject *obj)
Definition: py-block.c:342
static PyObject * frapy_read_register(PyObject *self, PyObject *args)
Definition: py-frame.c:240
static PyObject * frapy_str(PyObject *self)
Definition: py-frame.c:80
PyObject * gdbpy_frame_stop_reason_string(PyObject *self, PyObject *args)
Definition: py-frame.c:665
static PyObject * frapy_older(PyObject *self, PyObject *args)
Definition: py-frame.c:387
static PyObject * frapy_is_valid(PyObject *self, PyObject *args)
Definition: py-frame.c:91
static PyObject * frapy_arch(PyObject *self, PyObject *args)
Definition: py-frame.c:173
static PyObject * frapy_language(PyObject *self, PyObject *args)
Definition: py-frame.c:601
#define FRAPY_REQUIRE_VALID(frame_obj, frame)
Definition: py-frame.c:49
int gdbpy_initialize_frames(void)
Definition: py-frame.c:717
PyObject * frame_info_to_frame_object(frame_info_ptr frame)
Definition: py-frame.c:346
static PyObject * frapy_richcompare(PyObject *self, PyObject *other, int op)
Definition: py-frame.c:689
static PyObject * frapy_pc(PyObject *self, PyObject *args)
Definition: py-frame.c:217
static PyObject * frapy_block(PyObject *self, PyObject *args)
Definition: py-frame.c:276
static PyObject * frapy_find_sal(PyObject *self, PyObject *args)
Definition: py-frame.c:450
PyObject * gdbpy_selected_frame(PyObject *self, PyObject *args)
Definition: py-frame.c:645
static PyObject * frapy_name(PyObject *self, PyObject *args)
Definition: py-frame.c:114
static PyObject * frapy_level(PyObject *self, PyObject *args)
Definition: py-frame.c:580
PyObject * gdbpy_newest_frame(PyObject *self, PyObject *args)
Definition: py-frame.c:625
PyTypeObject frame_object_type
Definition: py-frame.c:799
static PyObject * frapy_unwind_stop_reason(PyObject *self, PyObject *args)
Definition: py-frame.c:194
static PyObject * frapy_type(PyObject *self, PyObject *args)
Definition: py-frame.c:150
static PyObject * frapy_function(PyObject *self, PyObject *args)
Definition: py-frame.c:317
frame_info_ptr frame_object_to_frame_info(PyObject *obj)
Definition: py-frame.c:61
static PyObject * frapy_read_var(PyObject *self, PyObject *args)
Definition: py-frame.c:478
static PyObject * frapy_newer(PyObject *self, PyObject *args)
Definition: py-frame.c:419
static PyMethodDef frame_object_methods[]
Definition: py-frame.c:750
static PyObject * frapy_select(PyObject *self, PyObject *args)
Definition: py-frame.c:559
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
Definition: py-ref.h:43
bool gdbpy_parse_register_id(struct gdbarch *gdbarch, PyObject *pyo_reg_id, int *reg_num)
Definition: py-registers.c:370
struct symbol * symbol_object_to_symbol(PyObject *obj)
Definition: py-symbol.c:354
PyObject * symbol_to_symbol_object(struct symbol *sym)
Definition: py-symbol.c:341
PyTypeObject symbol_object_type
Definition: py-symbol.c:725
PyObject * symtab_and_line_to_sal_object(struct symtab_and_line sal)
Definition: py-symtab.c:481
gdbpy_ref host_string_to_python_string(const char *str)
Definition: py-utils.c:153
gdb::unique_xmalloc_ptr< char > python_string_to_target_string(PyObject *obj)
Definition: py-utils.c:113
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
Definition: py-utils.c:279
void gdbpy_convert_exception(const struct gdb_exception &exception)
Definition: py-utils.c:216
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
Definition: py-utils.c:331
int gdbpy_is_string(PyObject *obj)
Definition: py-utils.c:163
gdbpy_ref gdb_py_object_from_ulongest(ULONGEST l)
Definition: py-utils.c:290
PyObject * value_to_value_object(struct value *val)
Definition: py-value.c:1778
PyObject * gdb_module
Definition: python.c:84
#define GDB_PY_HANDLE_EXCEPTION(Exception)
gdb::unique_xmalloc_ptr< char > find_frame_funname(frame_info_ptr frame, enum language *funlang, struct symbol **funcp)
Definition: stack.c:1278
const struct block * block
Definition: symtab.h:1498
struct symbol * symbol
Definition: symtab.h:1494
Definition: block.h:109
symbol * function() const
Definition: block.h:127
std::string to_string() const
Definition: frame.c:383
PyObject_HEAD struct frame_id frame_id
Definition: py-frame.c:33
int frame_id_is_next
Definition: py-frame.c:44
struct gdbarch * gdbarch
Definition: py-frame.c:34
virtual const char * name() const =0
struct objfile * objfile() const
Definition: symtab.c:6477
Definition: gdbtypes.h:922
Definition: value.c:181
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition: symtab.c:1967
@ VAR_DOMAIN
Definition: symtab.h:881