This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 0/1] Fix internal warning when "gdb -p xxx"
- From: Pedro Alves <palves at redhat dot com>
- To: Hui Zhu <hui_zhu at mentor dot com>
- Cc: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Wed, 19 Mar 2014 10:16:40 +0000
- Subject: Re: [PATCH 0/1] Fix internal warning when "gdb -p xxx"
- Authentication-results: sourceware.org; auth=none
- References: <53271C09 dot 5000709 at mentor dot com> <53271ED2 dot 6010707 at redhat dot com> <53272958 dot 1080605 at redhat dot com> <5327F7D0 dot 1050304 at mentor dot com> <53281C69 dot 7090703 at redhat dot com> <532915BF dot 2090608 at mentor dot com>
On 03/19/2014 03:57 AM, Hui Zhu wrote:
>> >
>> > Same with the nul termination. The most standard solution is:
>> >
>> > static char buf[PATH_MAX];
>> > char name[PATH_MAX];
>> > ssize_t len;
>> >
>> > xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
>> > len = readlink (name, buf, PATH_MAX - 1);
>> > if (len != -1)
>> > {
>> > buf[len] = '\0';
>> > return buf;
>> > }
>> > return NULL;
>> >
> I make a new patch according to your comments.
> Please help me review it.
The patch changes the bsd implementations's behavior, because
you made them return the /proc path when readlink fails (like
the Linux version does), instead of what the current code does
or what I suggested above.
--
Pedro Alves