tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: GDB single-step fails on alpha (Re: CVS commit: src/share/mk)



On 2016/10/29 4:59, Martin Husemann wrote:
I am not sure what I am doing wrong but with my build (including your patch)
I get:

[/tmp] martin@gemini > gdb pwd
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
..
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from pwd...Reading symbols from /usr/libdata/debug//bin/pwd.debug...done.
done.
(gdb) break main
Breakpoint 1 at 0x1060: file /ssd/src/bin/pwd/pwd.c, line 71.
(gdb) run
Starting program: /bin/pwd
/tmp
[Inferior 1 (process 34) exited normally]

I found the reason why this breakpoint does not work:

  % gdb pwd
  GNU gdb (GDB) 7.12
  ...
  Reading symbols from pwd...Reading symbols from /usr/libdata/debug//bin/pwd.debug...done.
  done.
  (gdb) b main
  Breakpoint 1 at 0x120000fa0: file /var/build/src/bin/pwd/pwd.c, line 71.
  (gdb) b ___start
  Breakpoint 2 at 0x120000ab8
  (gdb) disas 0x120000ab8
  Dump of assembler code for function ___start:
  ...
     0x0000000120000c34 <+404>:   bsr     ra,0x120000fa8 <main+8>
  ...
  (gdb)

___start() from crt0.o skips the first 8 bytes in main(). As a result,
breakpoint at the head of main() does not work. This seems to be a
regression introduced to GDB 7.12; GDB 7.10 is not affected. I don't
know the convention for function calling on alpha, but this first 8
bytes seem to be trampoline code in function prologue (it is 4 bytes
for some functions, and 0 byte for others). I attached a workaround to
this mail, by which function prologue is to be skipped, not only by
gdbarch_skip_prologue(), but also by gdbarch_skip_entrypoint().

However, with this patch, there remain two problems. (1) A same line
appears many times with single-stepping for binaries compiled with
"gcc -g -O2":

  % gdb ./hello.O2
  GNU gdb (GDB) 7.12
  ...
  Reading symbols from ./hello.O2...done.
  (gdb) b main
  Breakpoint 1 at 0x120000ad0: file hello.c, line 7.
  (gdb) r
  Starting program: /tmp/hello.O2

  Breakpoint 1, main () at hello.c:7
  7               printf("Hello, World!\n");
  (gdb) s
  Hello, World!
  9       }
  (gdb) s
  7               printf("Hello, World!\n");
  (gdb) s
  9       }
  (gdb) s
  0x00000001200008b8 in ___start ()
  (gdb) s
  Single stepping until exit from function ___start,
  which has no line number information.
  [Inferior 1 (process 327) exited normally]
  (gdb)

This is a problem not only for alpha. I observed similar failures on
arm, powerpc, and sparc64, but I did not on amd64 and sh3. It occurs
also with GDB 7.10 (at least on alpha and powerpc). What is the
difference between the former and latter archs? (2) It still does not
step into, e.g., printf(3), even if separate debugging information is
provided.

Thanks,
Rin
====
--- src/external/gpl3/gdb/dist/gdb/alpha-tdep.c.orig	2016-11-01 18:00:25.646778173 +0900
+++ src/external/gpl3/gdb/dist/gdb/alpha-tdep.c	2016-11-01 18:01:05.363084551 +0900
@@ -697,7 +697,7 @@
    up the frame (it's OK to skip more, just so long as we don't skip
    anything which might clobber the registers which are being saved.  */
-static CORE_ADDR
+CORE_ADDR
 alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   unsigned long inst;
--- src/external/gpl3/gdb/dist/gdb/alpha-tdep.h.orig	2016-11-01 18:00:30.092008033 +0900
+++ src/external/gpl3/gdb/dist/gdb/alpha-tdep.h	2016-11-01 18:01:37.186980036 +0900
@@ -105,6 +105,7 @@
 extern unsigned int alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc);
 extern int alpha_software_single_step (struct frame_info *frame);
 extern CORE_ADDR alpha_after_prologue (CORE_ADDR pc);
+extern CORE_ADDR alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc);
extern void alpha_mdebug_init_abi (struct gdbarch_info, struct gdbarch *);
 extern void alpha_dwarf2_init_abi (struct gdbarch_info, struct gdbarch *);
--- src/external/gpl3/gdb/dist/gdb/alphanbsd-tdep.c.orig	2016-11-01 18:00:18.184023068 +0900
+++ src/external/gpl3/gdb/dist/gdb/alphanbsd-tdep.c	2016-11-01 18:03:54.927018757 +0900
@@ -37,6 +37,12 @@
 #include "tramp-frame.h"
 #include "target.h"
+static CORE_ADDR
+alphanbsd_skip_entrypoint (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+  return alpha_skip_prologue (gdbarch, pc);
+}
+
 /* from obsd-tdep.c with symbol name adjusted to ours */
 static CORE_ADDR
 alphanbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
@@ -364,6 +370,8 @@
set_gdbarch_iterate_over_regset_sections
     (gdbarch, alphanbsd_iterate_over_regset_sections);
+
+  set_gdbarch_skip_entrypoint (gdbarch, alphanbsd_skip_entrypoint);
 }
 


Home | Main Index | Thread Index | Old Index