From: Simon Marchi <simark@simark.ca>
To: Kamil Rytarowski <n54@gmx.com>, gdb-patches@sourceware.org
Cc: tom@tromey.com
Subject: Re: [PATCH v4] Disable get_ptrace_pid for NetBSD
Date: Thu, 19 Mar 2020 11:30:24 -0400 [thread overview]
Message-ID: <6e74c142-d3e7-6fd8-b765-594931be898b@simark.ca> (raw)
In-Reply-To: <3bbb5348-a6bb-fac2-3ca1-2a3e8a1eb11e@simark.ca>
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
next prev parent reply other threads:[~2020-03-19 15:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 21:49 [PATCH] " Kamil Rytarowski
2020-03-18 21:51 ` Kamil Rytarowski
2020-03-18 21:55 ` [PATCH v2] " Kamil Rytarowski
2020-03-18 22:21 ` Simon Marchi
2020-03-18 23:30 ` Kamil Rytarowski
2020-03-18 23:16 ` [PATCH v3] " Kamil Rytarowski
2020-03-19 1:13 ` Simon Marchi
2020-03-19 12:01 ` Kamil Rytarowski
2020-03-19 12:28 ` [PATCH v4] " Kamil Rytarowski
2020-03-19 12:55 ` Simon Marchi
2020-03-19 15:30 ` Simon Marchi [this message]
2020-03-19 15:51 ` Kamil Rytarowski
2020-03-20 15:50 ` Tom Tromey
2020-03-19 15:45 ` [PATCH v5] " Kamil Rytarowski
2020-03-19 19:27 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e74c142-d3e7-6fd8-b765-594931be898b@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=n54@gmx.com \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox