This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/1] Fix internal warning when "gdb -p xxx"


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]