From 924c2928ae3f7a9fa1130103e6a83ff2b1ff17dd Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 27 May 2015 13:22:02 -0700 Subject: [PATCH] dwarf2read.c code cleanup, split out check_line_address gdb/ChangeLog: * dwarf2read.c (record_line_ftype): New typedef. (check_line_address): New function. (dwarf_decode_lines_1): Call it. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2read.c | 62 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e531727..d50bb0f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2015-05-27 Doug Evans + * dwarf2read.c (record_line_ftype): New typedef. + (check_line_address): New function. + (dwarf_decode_lines_1): Call it. + +2015-05-27 Doug Evans + * NEWS: Mention "set debug dwarf-line". * dwarf2read.c (dwarf_line_debug): New static global. (add_include_dir): Add debug dwarf-line support. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e6d6b30..0a7950f 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -17475,6 +17475,11 @@ psymtab_include_file_name (const struct line_header *lh, int file_index, return include_name; } +/* Function to record a line number. */ + +typedef void (record_line_ftype) (struct subfile *subfile, int line, + CORE_ADDR pc); + /* Ignore this record_line request. */ static void @@ -17574,6 +17579,36 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile, dwarf_record_line (gdbarch, subfile, 0, address, p_record_line); } +/* Check address and if invalid nop-out the rest of the lines in this + sequence. */ + +static void +check_line_address (struct dwarf2_cu *cu, record_line_ftype **p_record_line, + const gdb_byte *line_ptr, + CORE_ADDR lowpc, CORE_ADDR address) +{ + /* If address < lowpc then it's not a usable value, it's outside the + pc range of the CU. However, we restrict the test to only address + values of zero to preserve GDB's previous behaviour which is to + handle the specific case of a function being GC'd by the linker. */ + + if (address == 0 && address < lowpc) + { + /* This line table is for a function which has been + GCd by the linker. Ignore it. PR gdb/12528 */ + + struct objfile *objfile = cu->objfile; + long line_offset = line_ptr - get_debug_line_section (cu)->buffer; + + complaint (&symfile_complaints, + _(".debug_line address at offset 0x%lx is 0 [in module %s]"), + line_offset, objfile_name (objfile)); + *p_record_line = noop_record_line; + /* Note: *p_record_line is left as noop_record_line + until we see DW_LNE_end_sequence. */ + } +} + /* Subroutine of dwarf_decode_lines to simplify it. Process the line number information in LH. */ @@ -17707,31 +17742,10 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu, break; case DW_LNE_set_address: address = read_address (abfd, line_ptr, cu, &bytes_read); - - /* If address < lowpc then it's not a usable value, it's - outside the pc range of the CU. However, we restrict - the test to only address values of zero to preserve - GDB's previous behaviour which is to handle the specific - case of a function being GC'd by the linker. */ - if (address == 0 && address < lowpc) - { - /* This line table is for a function which has been - GCd by the linker. Ignore it. PR gdb/12528 */ - - long line_offset - = line_ptr - get_debug_line_section (cu)->buffer; - - complaint (&symfile_complaints, - _(".debug_line address at offset 0x%lx is 0 " - "[in module %s]"), - line_offset, objfile_name (objfile)); - p_record_line = noop_record_line; - /* Note: p_record_line is left as noop_record_line - until we see DW_LNE_end_sequence. */ - } - - op_index = 0; line_ptr += bytes_read; + check_line_address (cu, &p_record_line, line_ptr, + lowpc, address); + op_index = 0; address += baseaddr; address = gdbarch_adjust_dwarf2_line (gdbarch, address, 0); break; -- 2.7.4