[PATCH 0/1] Fix internal warning when "gdb -p xxx"
Pedro Alves
palves@redhat.com
Wed Mar 19 10:16:00 GMT 2014
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
More information about the Gdb-patches
mailing list