forked from Imagelibrary/binutils-gdb
gdb/python: allow instantiation of gdb.LineTableEntry objects
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
This commit is contained in:
@@ -6691,6 +6691,14 @@ True if pc (associated with this entry) marks the start of the epilogue.
|
|||||||
This attribute is not writable.
|
This attribute is not writable.
|
||||||
@end defvar
|
@end defvar
|
||||||
|
|
||||||
|
@code{LineTableEntry} objects have the following methods:
|
||||||
|
|
||||||
|
@defun LineTableEntry.__init__ (line, pc@r{[}, is_stmt@r{][}, prologue_end@r{][}, epilogue_begin@r{]})
|
||||||
|
Create new line table entry. Arguments correspond to @code{LineTableEntry}
|
||||||
|
attributes described above. Optional arguments @var{is_stmt},
|
||||||
|
@var{prologue_end} and @var{epilogue_begin} default to @code{False}.
|
||||||
|
@end defun
|
||||||
|
|
||||||
As there can be multiple addresses for a single source line, you may
|
As there can be multiple addresses for a single source line, you may
|
||||||
receive multiple @code{LineTableEntry} objects with matching
|
receive multiple @code{LineTableEntry} objects with matching
|
||||||
@code{line} attributes, but with different @code{pc} attributes. The
|
@code{line} attributes, but with different @code{pc} attributes. The
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ build_line_table_tuple_from_entries (
|
|||||||
|
|
||||||
for (i = 0; i < entries.size (); ++i)
|
for (i = 0; i < entries.size (); ++i)
|
||||||
{
|
{
|
||||||
auto entry = entries[i];
|
const linetable_entry *entry = entries[i];
|
||||||
gdbpy_ref<> obj (build_linetable_entry (
|
gdbpy_ref<> obj (build_linetable_entry (
|
||||||
entry->line, entry->pc (objfile), entry->is_stmt,
|
entry->line, entry->pc (objfile), entry->is_stmt,
|
||||||
entry->prologue_end, entry->epilogue_begin));
|
entry->prologue_end, entry->epilogue_begin));
|
||||||
@@ -390,6 +390,41 @@ ltpy_entry_get_epilogue_begin (PyObject *self, void *closure)
|
|||||||
Py_RETURN_FALSE;
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Object initializer; creates new linetable entry.
|
||||||
|
|
||||||
|
Use: __init__(LINE, PC, IS_STMT, PROLOGUE_END, EPILOGUE_BEGIN). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
ltpy_entry_init (PyObject *zelf, PyObject *args, PyObject *kw)
|
||||||
|
{
|
||||||
|
linetable_entry_object *self = (linetable_entry_object *) zelf;
|
||||||
|
|
||||||
|
static const char *keywords[] = { "line", "pc", "is_stmt", "prologue_end",
|
||||||
|
"epilogue_begin", nullptr };
|
||||||
|
int line = 0;
|
||||||
|
CORE_ADDR pc = 0;
|
||||||
|
int is_stmt = 0;
|
||||||
|
int prologue_end = 0;
|
||||||
|
int epilogue_begin = 0;
|
||||||
|
|
||||||
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "iK|ppp",
|
||||||
|
keywords,
|
||||||
|
&line,
|
||||||
|
&pc,
|
||||||
|
&is_stmt,
|
||||||
|
&prologue_end,
|
||||||
|
&epilogue_begin))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
self->line = line;
|
||||||
|
self->pc = pc;
|
||||||
|
self->is_stmt = is_stmt == 1 ? true : false;
|
||||||
|
self->prologue_end = prologue_end == 1 ? true : false;
|
||||||
|
self->epilogue_begin = epilogue_begin == 1 ? true : false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* LineTable iterator functions. */
|
/* LineTable iterator functions. */
|
||||||
|
|
||||||
/* Return a new line table iterator. */
|
/* Return a new line table iterator. */
|
||||||
@@ -604,12 +639,12 @@ static gdb_PyGetSetDef linetable_entry_object_getset[] = {
|
|||||||
"The line number in the source file.", NULL },
|
"The line number in the source file.", NULL },
|
||||||
{ "pc", ltpy_entry_get_pc, NULL,
|
{ "pc", ltpy_entry_get_pc, NULL,
|
||||||
"The memory address for this line number.", NULL },
|
"The memory address for this line number.", NULL },
|
||||||
{ "is_stmt", ltpy_entry_get_is_stmt, NULL,
|
{ "is_stmt", ltpy_entry_get_is_stmt, nullptr,
|
||||||
"Whether this is a good location to place a breakpoint for associated LINE.", NULL },
|
"Whether this is a good location to place a breakpoint for associated LINE.", nullptr },
|
||||||
{ "prologue_end", ltpy_entry_get_prologue_end, NULL,
|
{ "prologue_end", ltpy_entry_get_prologue_end, nullptr,
|
||||||
"Whether this is a good location to place a breakpoint after method prologue.", NULL },
|
"Whether this is a good location to place a breakpoint after method prologue.", nullptr },
|
||||||
{ "epilogue_begin", ltpy_entry_get_epilogue_begin, NULL,
|
{ "epilogue_begin", ltpy_entry_get_epilogue_begin, nullptr,
|
||||||
"True if this location marks the start of the epilogue.", NULL },
|
"True if this location marks the start of the epilogue.", nullptr },
|
||||||
{ NULL } /* Sentinel */
|
{ NULL } /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -650,6 +685,7 @@ PyTypeObject linetable_entry_object_type = {
|
|||||||
0, /* tp_descr_get */
|
0, /* tp_descr_get */
|
||||||
0, /* tp_descr_set */
|
0, /* tp_descr_set */
|
||||||
0, /* tp_dictoffset */
|
0, /* tp_dictoffset */
|
||||||
0, /* tp_init */
|
ltpy_entry_init, /* tp_init */
|
||||||
0, /* tp_alloc */
|
0, /* tp_alloc */
|
||||||
|
PyType_GenericNew, /* tp_new */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -81,3 +81,28 @@ gdb_test "python print(lt.has_line(44))" \
|
|||||||
gdb_test "python print(lt.has_line(10))" \
|
gdb_test "python print(lt.has_line(10))" \
|
||||||
"False.*" \
|
"False.*" \
|
||||||
"test has_pcs at line 10"
|
"test has_pcs at line 10"
|
||||||
|
|
||||||
|
# Test gdb.LineTableEntry.__init__ ()
|
||||||
|
gdb_test "python print( gdb.LineTableEntry(10, 0xcafe0000).line)" \
|
||||||
|
"10" \
|
||||||
|
"test new LineTableEntry line"
|
||||||
|
|
||||||
|
gdb_test "python print( gdb.LineTableEntry(10, 123456).pc)" \
|
||||||
|
"123456" \
|
||||||
|
"test new LineTableEntry pc"
|
||||||
|
|
||||||
|
gdb_test "python print( gdb.LineTableEntry(10, 123456).is_stmt)" \
|
||||||
|
"False" \
|
||||||
|
"test new LineTableEntry is_stmt"
|
||||||
|
gdb_test "python print( gdb.LineTableEntry(10, 123456).prologue_end)" \
|
||||||
|
"False" \
|
||||||
|
"test new LineTableEntry prologue_end"
|
||||||
|
gdb_test "python print( gdb.LineTableEntry(10, 123456).epilogue_begin)" \
|
||||||
|
"False" \
|
||||||
|
"test new LineTableEntry epilogue_begin"
|
||||||
|
gdb_test "python print( gdb.LineTableEntry('xx', 123456).pc)" \
|
||||||
|
"TypeError.*:.*" \
|
||||||
|
"test creating invalid gdb.LineTableEntry"
|
||||||
|
gdb_test "python print( gdb.LineTableEntry(10, 123456, prologue_end = True).prologue_end)" \
|
||||||
|
"True" \
|
||||||
|
"test prologue_end keyword argument"
|
||||||
|
|||||||
Reference in New Issue
Block a user