Where is the contents of target_fetch_registers ()

Daniel Jacobowitz drow@false.org
Thu May 13 13:37:00 GMT 2004


On Thu, May 13, 2004 at 06:50:17PM +0900, Hiroshi DOYU wrote:
> Hi all,

Hello, Hiroshi-san :)

> Now I am implementing gdb support on Linux kernel, Hitachi 
> SH-Mobile3 (SH73180CP01) and found that the following function 
> seems not to work correctly when compared with other gdb behavior
> which work correctly.
> # I can get this with "set debug target 1" option in gdb.

> (gdb) r
> Starting program: /root/a.out 
> target_acknowledge_created_inferior (103)
> target_reported_exec_events_per_exec_call () = 1
> target_wait (-1, status) = 103,   status->kind = stopped, signal = SIGTRAP
> target_fetch_registers (pc) = a06b5529 0x29556ba0 693463968

This first wait is the shell which GDB invoked to start your program...

> target_terminal_init ()
> target_terminal_inferior ()
> target_terminal_inferior ()
> target_resume (-1, continue, 0)
> target_wait (-1, status) = 103,   status->kind = stopped, signal = SIGTRAP
> target_fetch_registers (pc) = a06b5529 0x29556ba0 693463968

This one is the program starging...

> target_resume (-1, continue, 0)
> target_wait (-1, status) = 103,   status->kind = stopped, signal = SIGTRAP

And this one is probably the dynamic linker breakpoint.  What this
means is that GDB will read some memory from the inferior, figure out
the list of loaded shared libraries, and then try to read symbol
information for them.

If this is where GDB is stopping, it probably means that it is either
loading the library symbols (this can take a _long_ time) or ran out of
memory and crashed.

> I guess the following should have appeaer at this <freeze> line.
> 
>  target_fetch_registers (r14) = 34f9ff7b 0x7bfff934 2080373044
> 
> 
> I would like to look into the problem which it hang at the above
> point but I dont know much about gdb. So could anyone tell me 
> how to find where is the contents of "target_fetch_registers ()"? 
> In other words, in Linux, how can gdb get the registers from 
> kernel?

See the -nat file associated with your target.  In this case it's
sh-linux-nat.c, if I remember right - which isn't in the FSF GDB
sources (was never contributed :().  Look for PTRACE_GETREGS or
PTRACE_PEEKUSER, which are the two standard mechanisms of reading
registers.

-- 
Daniel Jacobowitz



More information about the Gdb mailing list