aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2015-06-26 15:11:14 +0200
committerJan Kratochvil <jan.kratochvil@redhat.com>2015-06-26 15:11:14 +0200
commit6e22494e5076e4d3c0b2c2785883162f83db499e (patch)
treef5ba9ed99e230fc9b2358f2308cc212ca602cadd /gdb/linespec.c
parentc742574f825fe43d1e7203fca8690c008b525e97 (diff)
downloadgdb-6e22494e5076e4d3c0b2c2785883162f83db499e.zip
gdb-6e22494e5076e4d3c0b2c2785883162f83db499e.tar.gz
gdb-6e22494e5076e4d3c0b2c2785883162f83db499e.tar.bz2
Do not skip prologue for asm (.S) files
GDB tries to skip prologue for .S files according to .debug_line but it then places the breakpoint to a location where it is never hit. This is because #defines in .S files cause prologue skipping which is completely inappropriate, for s390x: glibc/sysdeps/unix/syscall-template.S 78:/* This is a "normal" system call stub: if there is an error, 79: it returns -1 and sets errno. */ 80: 81:T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) 82: ret 00000000000f4210 T __select Line Number Statements: Extended opcode 2: set Address to 0xf41c8 Advance Line by 80 to 81 Copy Advance PC by 102 to 0xf422e Special opcode 6: advance Address by 0 to 0xf422e and Line by 1 to 82 Special opcode 34: advance Address by 2 to 0xf4230 and Line by 1 to 83 Advance PC by 38 to 0xf4256 Extended opcode 1: End of Sequence Compilation Unit @ offset 0x28b3e0: <0><28b3eb>: Abbrev Number: 1 (DW_TAG_compile_unit) <28b3ec> DW_AT_stmt_list : 0x7b439 <28b3f0> DW_AT_low_pc : 0xf41c8 <28b3f8> DW_AT_high_pc : 0xf4256 <28b400> DW_AT_name : ../sysdeps/unix/syscall-template.S <28b423> DW_AT_comp_dir : /usr/src/debug////////glibc-2.17-c758a686/misc <28b452> DW_AT_producer : GNU AS 2.23.52.0.1 <28b465> DW_AT_language : 32769 (MIPS assembler) without debuginfo or with debuginfo and the fix - correct address: (gdb) b select Breakpoint 1 at 0xf4210 It is also where .dynsym+.symtab point to: 00000000000f4210 T __select 00000000000f4210 W select with debuginfo, without the fix: (gdb) b select Breakpoint 1 at 0xf41c8: file ../sysdeps/unix/syscall-template.S, line 81. One part is to behave for asm files similar way like for 'locations_valid': /* Symtab has been compiled with both optimizations and debug info so that GDB may stop skipping prologues as variables locations are valid already at function entry points. */ unsigned int locations_valid : 1; The other part is to extend the 'locations_valid'-like functionality more. Both minsym_found and find_function_start_sal need to be patched, otherwise their addresses do not match and GDB regresses on ppc64: gdb/ChangeLog 2015-06-26 Jan Kratochvil <jan.kratochvil@redhat.com> * linespec.c (minsym_found): Reset sal.PC for COMPUNIT_LOCATIONS_VALID and language_asm.. * symtab.c (find_function_start_sal): Likewise. gdb/testsuite/ChangeLog 2015-06-26 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.arch/amd64-prologue-skip.S: New file. * gdb.arch/amd64-prologue-skip.exp: New file.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index d2089b5..65155d9 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3432,7 +3432,9 @@ collect_symbols (struct symbol *sym, void *data)
}
/* We've found a minimal symbol MSYMBOL in OBJFILE to associate with our
- linespec; return the SAL in RESULT. */
+ linespec; return the SAL in RESULT. This function should return SALs
+ matching those from find_function_start_sal, otherwise false
+ multiple-locations breakpoints could be placed. */
static void
minsym_found (struct linespec_state *self, struct objfile *objfile,
@@ -3454,7 +3456,23 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
sal = find_pc_sect_line (pc, NULL, 0);
if (self->funfirstline)
- skip_prologue_sal (&sal);
+ {
+ if (sal.symtab != NULL
+ && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))
+ || SYMTAB_LANGUAGE (sal.symtab) == language_asm))
+ {
+ /* If gdbarch_convert_from_func_ptr_addr does not apply then
+ sal.SECTION, sal.LINE&co. will stay correct from above.
+ If gdbarch_convert_from_func_ptr_addr applies then
+ sal.SECTION is cleared from above and sal.LINE&co. will
+ stay correct from the last find_pc_sect_line above. */
+ sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol);
+ sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc,
+ &current_target);
+ }
+ else
+ skip_prologue_sal (&sal);
+ }
if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))
add_sal_to_sals (self, result, &sal, MSYMBOL_NATURAL_NAME (msymbol), 0);