[PATCH v4] Disable get_ptrace_pid for NetBSD

Simon Marchi simark@simark.ca
Thu Mar 19 15:30:24 GMT 2020


On 2020-03-19 8:55 a.m., Simon Marchi wrote:
> On 2020-03-19 8:28 a.m., Kamil Rytarowski wrote:
>> Unlike most other Operating Systems, NetBSD tracks both pid and lwp.
>> The process id on NetBSD is stored always in the pid field of ptid.
>>
>> gdb/ChangeLog:
>>
>> 	* inf-ptrace.h: Disable get_ptrace_pid on NetBSD.
>> 	* inf-ptrace.c: Likewise.
>> 	* (gdb_ptrace): Add.
>> 	* (inf_ptrace_target::resume): Update.
>> 	* (inf_ptrace_target::xfer_partial): Likewise.
>> 	* (inf_ptrace_peek_poke): Change argument `pid' to `ptid'.
>> 	* (inf_ptrace_peek_poke): Update.
> 
> Hmm, this breaks simple debugging on Linux:
> 
> $ ./gdb --data-directory=data-directory a.out -ex start
> Reading symbols from a.out...
> Temporary breakpoint 1 at 0x4004da: file test.c, line 2.
> Starting program: /home/smarchi/build/binutils-gdb/gdb/a.out
> 
> Program received signal SIGILL, Illegal instruction.
> 0x00007ffff7dda96d in dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:1517
> 1517    rtld.c: No such file or directory.
> 
> 
> I haven't figured out why by inspecting the code yet, I'll try to debug it later today.
> 
> Simon
> 

Ah, it's because ptrace returns long and not int on GNU/Linux.  So when we want to read
a 64-bits word from memory, it gets truncated.  gdb_ptrace should return PTRACE_TYPE_RET.

In fact, to be consistent, all these gdb_ptrace functions should be changed to return
PTRACE_TYPE_RET (as a separate patch).

Simon



More information about the Gdb-patches mailing list