[lldb-dev] PATCH for REVIEW: Implement Host::SetThreadName on Linux
Greg Clayton
gclayton at apple.com
Mon May 13 09:43:41 PDT 2013
On May 10, 2013, at 5:30 PM, Mike Sartain <mikesart at valvesoftware.com> wrote:
> On Fri, May 10, 2013 at 1:41 PM, Kopec, Matt <matt.kopec at intel.com> wrote:
>
>> Thanks for contributing the patch! This will help many of us in debugging lldb. Good to know there are other Linux lldb developers out there. :)
>
> Thanks Matt. We're doing a lot of debugging on Linux and I'm hoping to do whatever I can to make lldb a much better debugger than gdb / cgdb - what most of use are currently using.
We look forward to getting more people working on LLDB in general, I am glad to see more people getting on board!
> I'm just now starting to get in the code and poke around and see what's there. If you have any suggestions on where I could help and not duplicate work, please fire away.
The libedit code in the "lldb" binary seems to be a bit flaky on linux. Sometimes the (lldb) prompt does't show up and other times the newlines after entered commands come out in the command output. Anything that can be done to solidify the libedit based code on linux would be a great help.
>
>> Some comments about the patch...
>>
>>> +#elif defined (__linux__)
>>> + void *fn = dlsym (RTLD_DEFAULT, "pthread_setname_np");
>>> + if (fn)
>>> + {
>>
>> I believe this pthread function can be added by including pthread.h for Linux. That way you don't need dlsym and can just re-use most of the code that is already there for apple.
>
> pthread_setname_np was added in glibc v2.12, so anything running less than that would run into issues if we called it directly. As an example on the Ubuntu side, I believe 10.04 LTS shipped with 2.11.1. What are your thoughts / requirements for minspecs like this?
dlsym() is the right way to go to avoid build issues and distribution issues. We will need to keep this in for at least a few years until we require at least a certain version of glibc on linux.
>
>>> + const char *lastdot = ::strrchr( thread_name, '.' );
>>> +
>>> + if (lastdot && lastdot != thread_name)
>>> + thread_name = lastdot + 1;
>>> + ::strncpy (namebuf, thread_name, sizeof(namebuf));
>>> + namebuf[ sizeof(namebuf) - 1 ] = 0;
>>> +
>>> + int namebuflen = strlen(namebuf);
>>
>> It would have been nice to use std::string and its' facilities. It would make this easier to write and understand but what you have is fine.
>
> I'll switch this over to using std::string on Monday and resubmit. Would have done it today but I just got back from a Pioneer Farms fieldtrip. Whee! :)
>
> Thanks for the reply. Have a great weekend.
> -Mike
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
More information about the lldb-dev
mailing list