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)



2016/12/06 20:28, Kamil Rytarowski wrote:
Not sure if related and relevant, but I noted that OpenBSD defines
FIX_SSTEP for alpha.

#ifdef _KERNEL
# define FIX_SSTEP(p)	process_sstep(p, 0)
#endif

--- sys/arch/alpha/include/ptrace.h

and additional logic in process_sstep()

 * process_sstep(proc)
 *	Arrange for the process to trap after executing a single instruction.

-- sys/arch/alpha/alpha/process_machdep.c


Hmm, while we do not support PT_STEP on alpha, OpenBSD does. Although,
GDB uses its own software single stepping both for NetBSD and OpenBSD.

Let me summarize the situation.

Now, single stepping of GDB works on alpha, except for two minor
problems; (1) it does not step into, e.g., printf(3) even if debugging
symbols for libc are provided, and (2) same line appears many times
for binaries compiled by "gcc -g -O2" like this:

On 2016/11/01 18:24, Rin Okuyama wrote:
  % 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)

I have no solution for (1) at the moment. (2) turned out to be a problem
of GCC, not GDB. The line number statements are corrupted; the line
number does not monotonically increase:

  % objdump -d hello.O2
  ...
   Line Number Statements:
    [0x00000028]  Extended opcode 2: set Address to 0x120000ac0
    [0x00000033]  Special opcode 9: advance Address by 0 to 0x120000ac0 and Line by 4 to 5
    [0x00000034]  Special opcode 63: advance Address by 16 to 0x120000ad0 and Line by 2 to 7
    [0x00000035]  Special opcode 91: advance Address by 24 to 0x120000ae8 and Line by 2 to 9
    [0x00000036]  Special opcode 31: advance Address by 8 to 0x120000af0 and Line by -2 to 7
    [0x00000037]  Special opcode 21: advance Address by 4 to 0x120000af4 and Line by 2 to 9
    [0x00000038]  Advance PC by 8 to 0x120000afc
    [0x0000003a]  Extended opcode 1: End of Sequence

This is a problem not peculiar to alpha. It also occurs, at least, on
arm, powerpc, and sparc64. But it does not on amd64 and sh3.

In addition, breakpoint sometimes does not work. I posted a work around:

  http://mail-index.netbsd.org/tech-toolchain/2016/11/01/msg002838.html

But I have never gotten any response yet. I will repost it to port-alpha
before long.

Thanks,
Rin


Home | Main Index | Thread Index | Old Index