aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-06 16:38:56 -0600
committerTom Tromey <tom@tromey.com>2017-04-12 11:16:17 -0600
commit67d89901506da74d00a482b7560237dce404b41c (patch)
tree9c9c308fbaabb9ac805325be91bd2f75a07e040e /gdb/python
parent93921405a46c0a58eae19fffb92e02416082801a (diff)
downloadgdb-67d89901506da74d00a482b7560237dce404b41c.zip
gdb-67d89901506da74d00a482b7560237dce404b41c.tar.gz
gdb-67d89901506da74d00a482b7560237dce404b41c.tar.bz2
Change find_pcs_for_symtab_line to return a std::vector
This changes find_pcs_for_symtab_line to return a std::vector. This allows the removal of some cleanups. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * symtab.h (find_pcs_for_symtab_line): Change return type. * symtab.c (find_pcs_for_symtab_line): Change return type. * python/py-linetable.c (build_line_table_tuple_from_pcs): Change type of "vec". Update. (ltpy_get_pcs_for_line): Update. * linespec.c (decode_digits_ordinary): Update.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-linetable.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 8d17aab..13daa3d 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -115,30 +115,28 @@ build_linetable_entry (int line, CORE_ADDR address)
return (PyObject *) obj;
}
-/* Internal helper function to build a Python Tuple from a GDB Vector.
+/* Internal helper function to build a Python Tuple from a vector.
A line table entry can have multiple PCs for a given source line.
Construct a Tuple of all entries for the given source line, LINE
- from the line table VEC. Construct one line table entry object per
+ from the line table PCS. Construct one line table entry object per
address. */
static PyObject *
-build_line_table_tuple_from_pcs (int line, VEC (CORE_ADDR) *vec)
+build_line_table_tuple_from_pcs (int line, const std::vector<CORE_ADDR> &pcs)
{
- int vec_len = 0;
- CORE_ADDR pc;
int i;
- vec_len = VEC_length (CORE_ADDR, vec);
- if (vec_len < 1)
+ if (pcs.size () < 1)
Py_RETURN_NONE;
- gdbpy_ref<> tuple (PyTuple_New (vec_len));
+ gdbpy_ref<> tuple (PyTuple_New (pcs.size ()));
if (tuple == NULL)
return NULL;
- for (i = 0; VEC_iterate (CORE_ADDR, vec, i, pc); ++i)
+ for (i = 0; i < pcs.size (); ++i)
{
+ CORE_ADDR pc = pcs[i];
gdbpy_ref<> obj (build_linetable_entry (line, pc));
if (obj == NULL)
@@ -160,8 +158,7 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
struct symtab *symtab;
gdb_py_longest py_line;
struct linetable_entry *best_entry = NULL;
- VEC (CORE_ADDR) *pcs = NULL;
- PyObject *tuple;
+ std::vector<CORE_ADDR> pcs;
LTPY_REQUIRE_VALID (self, symtab);
@@ -178,10 +175,7 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
}
END_CATCH
- tuple = build_line_table_tuple_from_pcs (py_line, pcs);
- VEC_free (CORE_ADDR, pcs);
-
- return tuple;
+ return build_line_table_tuple_from_pcs (py_line, pcs);
}
/* Implementation of gdb.LineTable.has_line (self, line) -> Boolean.