[PATCH 1/6] Add column information of dwarf to the symbol information
Hannes Domani
ssbssa@yahoo.de
Sat May 16 17:26:28 GMT 2020
---
gdb/buildsym-legacy.c | 2 +-
gdb/buildsym.c | 7 ++++---
gdb/buildsym.h | 2 +-
gdb/dwarf2/read.c | 38 ++++++++++++++++++++++++++++++--------
gdb/frame.c | 1 +
gdb/symtab.c | 3 +++
gdb/symtab.h | 11 +++++++++++
7 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c
index d9c27ebc95..0a4f78fe23 100644
--- a/gdb/buildsym-legacy.c
+++ b/gdb/buildsym-legacy.c
@@ -254,7 +254,7 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
gdb_assert (buildsym_compunit != nullptr);
/* Assume every line entry is a statement start, that is a good place to
put a breakpoint for that line number. */
- buildsym_compunit->record_line (subfile, line, pc, true);
+ buildsym_compunit->record_line (subfile, line, pc, true, 0);
}
/* Start a new symtab for a new source file in OBJFILE. Called, for example,
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b9bcc33080..fa39266269 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -661,12 +661,12 @@ buildsym_compunit::pop_subfile ()
return name;
}
-/* Add a linetable entry for line number LINE and address PC to the
- line vector for SUBFILE. */
+/* Add a linetable entry for line number LINE, address PC and column
+ number COLUMN to the line vector for SUBFILE. */
void
buildsym_compunit::record_line (struct subfile *subfile, int line,
- CORE_ADDR pc, bool is_stmt)
+ CORE_ADDR pc, bool is_stmt, int column)
{
struct linetable_entry *e;
@@ -719,6 +719,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line,
e->line = line;
e->is_stmt = is_stmt ? 1 : 0;
e->pc = pc;
+ e->column = column;
}
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index c768a4c2da..f4dafb6ba3 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -188,7 +188,7 @@ struct buildsym_compunit
const char *pop_subfile ();
void record_line (struct subfile *subfile, int line, CORE_ADDR pc,
- bool is_stmt);
+ bool is_stmt, int column);
struct compunit_symtab *get_compunit_symtab ()
{
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f9d2f255e4..4441c3d390 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -19829,6 +19829,12 @@ class lnp_state_machine
advance_line (line_delta);
}
+ /* Handle DW_LNS_set_column. */
+ void handle_set_column (unsigned int column)
+ {
+ m_column = column;
+ }
+
/* Handle DW_LNS_set_file. */
void handle_set_file (file_name_index file);
@@ -19890,6 +19896,7 @@ class lnp_state_machine
/* The line table index of the current file. */
file_name_index m_file = 1;
unsigned int m_line = 1;
+ unsigned int m_column = 0;
/* These are initialized in the constructor. */
@@ -20027,13 +20034,14 @@ dwarf_record_line_p (struct dwarf2_cu *cu,
return 0;
}
-/* Use the CU's builder to record line number LINE beginning at
- address ADDRESS in the line table of subfile SUBFILE. */
+/* Use the CU's builder to record line number LINE and column
+ number COLUMN beginning at address ADDRESS in the line table
+ of subfile SUBFILE. */
static void
dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
unsigned int line, CORE_ADDR address, bool is_stmt,
- struct dwarf2_cu *cu)
+ struct dwarf2_cu *cu, unsigned int column)
{
CORE_ADDR addr = gdbarch_addr_bits_remove (gdbarch, address);
@@ -20046,7 +20054,7 @@ dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
}
if (cu != nullptr)
- cu->get_builder ()->record_line (subfile, line, addr, is_stmt);
+ cu->get_builder ()->record_line (subfile, line, addr, is_stmt, column);
}
/* Subroutine of dwarf_decode_lines_1 to simplify it.
@@ -20069,7 +20077,7 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
paddress (gdbarch, address));
}
- dwarf_record_line_1 (gdbarch, subfile, 0, address, true, cu);
+ dwarf_record_line_1 (gdbarch, subfile, 0, address, true, cu, 0);
}
void
@@ -20117,7 +20125,8 @@ lnp_state_machine::record_line (bool end_sequence)
dwarf_record_line_1 (m_gdbarch,
builder->get_current_subfile (),
m_line, m_address, is_stmt,
- m_currently_recording_lines ? m_cu : nullptr);
+ m_currently_recording_lines ? m_cu : nullptr,
+ m_column);
}
m_last_subfile = m_cu->get_builder ()->get_current_subfile ();
m_last_line = m_line;
@@ -20334,8 +20343,13 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
}
break;
case DW_LNS_set_column:
- (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
+ {
+ unsigned int column
+ = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+
+ state_machine.handle_set_column (column);
+ }
break;
case DW_LNS_negate_stmt:
state_machine.handle_negate_stmt ();
@@ -20668,6 +20682,14 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
SYMBOL_LINE (sym) = DW_UNSND (attr);
}
+ attr = dwarf2_attr (die,
+ inlined_func ? DW_AT_call_column : DW_AT_decl_column,
+ cu);
+ if (attr != nullptr)
+ {
+ SYMBOL_COLUMN (sym) = DW_UNSND (attr);
+ }
+
attr = dwarf2_attr (die,
inlined_func ? DW_AT_call_file : DW_AT_decl_file,
cu);
diff --git a/gdb/frame.c b/gdb/frame.c
index ff27b9f00e..72062c9f34 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2538,6 +2538,7 @@ find_frame_sal (frame_info *frame)
{
sal.symtab = symbol_symtab (sym);
sal.line = SYMBOL_LINE (sym);
+ sal.column = SYMBOL_COLUMN (sym);
}
else
/* If the symbol does not have a location, we don't know where
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7d4857e323..999c0af8dc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3325,6 +3325,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
val.is_stmt = best->is_stmt;
val.symtab = best_symtab;
val.line = best->line;
+ val.column = best->column;
val.pc = best->pc;
if (best_end && (!alt || best_end < alt->pc))
val.end = best_end;
@@ -3901,6 +3902,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
sal->section = section;
sal->symtab = start_sal.symtab;
sal->line = start_sal.line;
+ sal->column = start_sal.column;
sal->end = start_sal.end;
/* Check if we are now inside an inlined function. If we can,
@@ -3919,6 +3921,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
&& SYMBOL_LINE (BLOCK_FUNCTION (function_block)) != 0)
{
sal->line = SYMBOL_LINE (BLOCK_FUNCTION (function_block));
+ sal->column = SYMBOL_COLUMN (BLOCK_FUNCTION (function_block));
sal->symtab = symbol_symtab (BLOCK_FUNCTION (function_block));
}
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 764c567a90..c936c858e6 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1191,6 +1191,10 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
unsigned short line = 0;
+ /* Column number of this symbol's definition. */
+
+ unsigned short column = 0;
+
/* An arbitrary data pointer, allowing symbol readers to record
additional information on a per-symbol basis. Note that this data
must be allocated using the same obstack as the symbol itself. */
@@ -1237,6 +1241,7 @@ extern const struct symbol_impl *symbol_impls;
(((symbol)->subclass) == SYMBOL_TEMPLATE)
#define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line
+#define SYMBOL_COLUMN(symbol) (symbol)->column
#define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed)
#define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block)
#define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register)
@@ -1307,6 +1312,9 @@ struct linetable_entry
/* The line number for this entry. */
int line;
+ /* The column number for this entry. */
+ int column;
+
/* True if this PC is a good location to place a breakpoint for LINE. */
unsigned is_stmt : 1;
@@ -1887,6 +1895,9 @@ struct symtab_and_line
0 is never a valid line number; it is used to indicate that line number
information is not available. */
int line = 0;
+ /* Column number. 0 is never a valid column number; it is used to
+ indicate that column number information is not available. */
+ int column = 0;
CORE_ADDR pc = 0;
CORE_ADDR end = 0;
--
2.26.2
More information about the Gdb-patches
mailing list