From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/6] Add LineTableEntry.column to python line table interface
Date: Sat, 16 May 2020 19:26:31 +0200 [thread overview]
Message-ID: <20200516172632.4803-5-ssbssa@yahoo.de> (raw)
In-Reply-To: <20200516172632.4803-1-ssbssa@yahoo.de>
---
gdb/python/py-linetable.c | 30 ++++++++++++++++++++++++------
gdb/symtab.c | 5 ++++-
gdb/symtab.h | 3 ++-
3 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 858313bb22..f0aa736ac7 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -24,6 +24,8 @@ typedef struct {
PyObject_HEAD
/* The line table source line. */
int line;
+ /* The line table source column. */
+ int column;
/* The pc associated with the source line. */
CORE_ADDR pc;
} linetable_entry_object;
@@ -99,7 +101,7 @@ symtab_to_linetable_object (PyObject *symtab)
and an address. */
static PyObject *
-build_linetable_entry (int line, CORE_ADDR address)
+build_linetable_entry (int line, int column, CORE_ADDR address)
{
linetable_entry_object *obj;
@@ -108,6 +110,7 @@ build_linetable_entry (int line, CORE_ADDR address)
if (obj != NULL)
{
obj->line = line;
+ obj->column = column;
obj->pc = address;
}
@@ -121,7 +124,8 @@ build_linetable_entry (int line, CORE_ADDR address)
address. */
static PyObject *
-build_line_table_tuple_from_pcs (int line, const std::vector<CORE_ADDR> &pcs)
+build_line_table_tuple_from_pcs (int line, const std::vector<CORE_ADDR> &pcs,
+ const std::vector<int> &columns)
{
int i;
@@ -136,7 +140,7 @@ build_line_table_tuple_from_pcs (int line, const std::vector<CORE_ADDR> &pcs)
for (i = 0; i < pcs.size (); ++i)
{
CORE_ADDR pc = pcs[i];
- gdbpy_ref<> obj (build_linetable_entry (line, pc));
+ gdbpy_ref<> obj (build_linetable_entry (line, columns[i], pc));
if (obj == NULL)
return NULL;
@@ -158,6 +162,7 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
gdb_py_longest py_line;
struct linetable_entry *best_entry = NULL;
std::vector<CORE_ADDR> pcs;
+ std::vector<int> columns;
LTPY_REQUIRE_VALID (self, symtab);
@@ -166,14 +171,14 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
try
{
- pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry);
+ pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry, &columns);
}
catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
- return build_line_table_tuple_from_pcs (py_line, pcs);
+ return build_line_table_tuple_from_pcs (py_line, pcs, columns);
}
/* Implementation of gdb.LineTable.has_line (self, line) -> Boolean.
@@ -339,6 +344,17 @@ ltpy_entry_get_pc (PyObject *self, void *closure)
return gdb_py_object_from_longest (obj->pc).release ();
}
+/* Implementation of gdb.LineTableEntry.column (self) -> Long. Returns
+ a long integer associated with the line table entry. */
+
+static PyObject *
+ltpy_entry_get_column (PyObject *self, void *closure)
+{
+ linetable_entry_object *obj = (linetable_entry_object *) self;
+
+ return gdb_py_object_from_longest (obj->column).release ();
+}
+
/* LineTable iterator functions. */
/* Return a new line table iterator. */
@@ -422,7 +438,7 @@ ltpy_iternext (PyObject *self)
item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]);
}
- obj = build_linetable_entry (item->line, item->pc);
+ obj = build_linetable_entry (item->line, item->column, item->pc);
iter_obj->current_index++;
return obj;
@@ -548,6 +564,8 @@ static gdb_PyGetSetDef linetable_entry_object_getset[] = {
"The line number in the source file.", NULL },
{ "pc", ltpy_entry_get_pc, NULL,
"The memory address for this line number.", NULL },
+ { "column", ltpy_entry_get_column, NULL,
+ "The column number in the source file.", NULL },
{ NULL } /* Sentinel */
};
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 999c0af8dc..19a3d86f24 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3472,7 +3472,8 @@ find_line_symtab (struct symtab *sym_tab, int line,
std::vector<CORE_ADDR>
find_pcs_for_symtab_line (struct symtab *symtab, int line,
- struct linetable_entry **best_item)
+ struct linetable_entry **best_item,
+ std::vector<int> *columns)
{
int start = 0;
std::vector<CORE_ADDR> result;
@@ -3500,6 +3501,8 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line,
}
result.push_back (SYMTAB_LINETABLE (symtab)->item[idx].pc);
+ if (columns != nullptr)
+ columns->push_back (SYMTAB_LINETABLE (symtab)->item[idx].column);
start = idx + 1;
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c936c858e6..fb1b8c9393 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2274,7 +2274,8 @@ void iterate_over_symtabs (const char *name,
std::vector<CORE_ADDR> find_pcs_for_symtab_line
- (struct symtab *symtab, int line, struct linetable_entry **best_entry);
+ (struct symtab *symtab, int line, struct linetable_entry **best_entry,
+ std::vector<int> *columns = nullptr);
/* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS. The callback
is called once per matching symbol SYM. The callback should return
--
2.26.2
next prev parent reply other threads:[~2020-05-16 17:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200516172632.4803-1-ssbssa.ref@yahoo.de>
2020-05-16 17:26 ` [RFC][PATCH 0/6] Step program considering the source column information Hannes Domani
2020-05-16 17:26 ` [PATCH 1/6] Add column information of dwarf to the symbol information Hannes Domani
2020-05-18 16:17 ` Tom Tromey
2020-05-19 12:23 ` Luis Machado
2020-05-16 17:26 ` [PATCH 2/6][PR gdb/25913] Implement nextc and stepc commands Hannes Domani
2020-05-16 17:26 ` [PATCH 3/6] Add column information to maint info line-table Hannes Domani
2020-05-16 17:26 ` Hannes Domani [this message]
2020-05-27 13:50 ` [PATCH 4/6] Add LineTableEntry.column to python line table interface Tom de Vries
2020-05-27 14:36 ` Tom Tromey
2020-05-16 17:26 ` [PATCH 5/6][PR gdb/25911] Show column of current execution point in frame info Hannes Domani
2020-05-18 16:20 ` Tom Tromey
2020-05-18 16:37 ` Hannes Domani
2020-05-19 14:51 ` Tom Tromey
2020-05-16 17:26 ` [PATCH 6/6] Show column of current execution point in TUI Hannes Domani
2020-05-16 18:45 ` [RFC][PATCH 0/6] Step program considering the source column information Pedro Alves
2020-05-17 0:08 ` Hannes Domani
2020-05-18 16:21 ` Tom Tromey
2020-05-18 16:28 ` Hannes Domani
2020-05-19 12:27 ` Luis Machado
2020-05-19 16:02 ` Hannes Domani
2020-05-27 15:33 ` Tom de Vries
2020-05-27 16:04 ` Hannes Domani
2020-06-02 9:08 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200516172632.4803-5-ssbssa@yahoo.de \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox