WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Setup dgb for multi-threaded debug  (Read 8671 times)

Offline Kurvivor19

  • Newbie
  • *
  • Posts: 4
Setup dgb for multi-threaded debug
« on: October 07, 2016, 04:20:31 PM »
I am trying to compile and debud a multi-threaded program (pthreads). I have compiled it succesfully, however when i try to run it under gdb, i get "threading debug not available" warning every time.

I am using TinyCore, and i have installed gcc and gdb from extension repository, as usual.

What should i do to be able to debug threads under gdb? Are there extra packages i need to install or some settings that need to be enabled?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #1 on: October 08, 2016, 01:44:03 AM »
Do you get this message because the tinycore glibc is stripped?

Offline Kurvivor19

  • Newbie
  • *
  • Posts: 4
Re: Setup dgb for multi-threaded debug
« Reply #2 on: October 08, 2016, 08:05:36 AM »
I do not really know the reason, or to be more precise, i do nt fully understand what these messages mean

Here is the full text of warning messages:
Quote
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "Set solib-search-path" or "set sysroot"?
warning: File "/tmp/tcloop/glibc_add_lib/lib/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
<skilpped lines about security protection>
warning: Unable to find libthread_db matching inferior's hread library, thread debugging will not be available.
 

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #3 on: October 08, 2016, 09:12:59 AM »
You get these messages because the tinycore glibc has the debugging symbols stripped out of it to make it smaller.

Usually this does not impact the debugging of other applications - if you use "threads all" (or whatever the command is in gdb) you should be OK, no?

Offline Kurvivor19

  • Newbie
  • *
  • Posts: 4
Re: Setup dgb for multi-threaded debug
« Reply #4 on: October 08, 2016, 10:20:14 AM »
Well, it is the last message, which is
Quote
warning: Unable to find libthread_db matching inferior's hread library, thread debugging will not be available.
is what worries me.
No matter what i do, i seem unable to see anythreads beside main one when i list them. It seems that is expected behaviour  when libthread_db and libpthread do not match - but why are they not matching? It is certainly strange for libraries from same repository to fail to match.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #5 on: October 09, 2016, 01:26:18 AM »
I was recently dubugging something on tinycore and "thread apply all backtrace" showed the different threads.

libthread_db is in the glibc_add_lib extension, but I was not using the extension, are you?

Offline Kurvivor19

  • Newbie
  • *
  • Posts: 4
Re: Setup dgb for multi-threaded debug
« Reply #6 on: October 09, 2016, 05:26:53 AM »
That extension was pulled together with gdb
To clarify: do you get any warnings?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #7 on: October 09, 2016, 09:46:53 AM »
Yes, but as long as you're not debugging glibc itself it should be OK

Offline Kurvivor

  • Newbie
  • *
  • Posts: 9
Re: Setup dgb for multi-threaded debug
« Reply #8 on: October 10, 2016, 03:33:03 AM »
Well, in my case i still a) get warning about libthread_db and libpthread no matching b) do not see any threads except main one (listing with `thread apply all bt` ot `info threads`) even when several threads are running for sure.
this is very distressing for me

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #9 on: October 11, 2016, 10:10:23 AM »
I see the same warning in the x86 and x86_64 versions of gdb.

Both libpthread-2.22.so and libthread_db-1.0.so are from the same version of glibc, so I'm not sure why the warnings are given.

As per google, plenty of people have the same problem, but I did not find any obvious solutions  :(

Offline Kurvivor

  • Newbie
  • *
  • Posts: 9
Re: Setup dgb for multi-threaded debug
« Reply #10 on: October 13, 2016, 12:28:31 PM »
At stackoverflow, this
Quote
You have stripped libpthread.so.0 (don't do that).
is listed as possible reason
If that is the case, could not-stripped libpthread be provided?

Offline Kurvivor

  • Newbie
  • *
  • Posts: 9
Re: Setup dgb for multi-threaded debug
« Reply #11 on: October 13, 2016, 01:02:08 PM »
Or, even, according to: http://stackoverflow.com/questions/866721/how-to-generate-gcc-debug-symbol-outside-the-build-target - symbols can be provided in a separate tgx file, which would be consistent with TinyCore design
I am begging you to do that. I am quite desperate

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #12 on: October 14, 2016, 04:14:23 AM »
I'm not sure about the script in the link you provided, but if I overwrite libpthread-2.22.so and libthread_db-1.0.so with versions containing debug symbols, I get this:
Code: [Select]
(gdb) run
Starting program: /usr/local/bin/fifth
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0xb58eab40 (LWP 4402)]
[New Thread 0xb5860b40 (LWP 4403)]
[New Thread 0xb56f2b40 (LWP 4404)]

..which looks promising.

Now I need to think how to make this available...

Offline Kurvivor

  • Newbie
  • *
  • Posts: 9
Re: Setup dgb for multi-threaded debug
« Reply #13 on: October 14, 2016, 05:44:01 AM »
Since i am using old version of tinycore (6, i believe, with 3.16.6 kernel), an instruction for how to build those libraries with symbols would suffice.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: Setup dgb for multi-threaded debug
« Reply #14 on: October 14, 2016, 07:21:49 AM »
see the second time glibc is built in:

http://tinycorelinux.net/6.x/x86/release/src/toolchain/compile_tc6_x86

..substitute "sudo make install_root=/tmp/pkg install" for "sudo make install" to avoid overwriting the existing files.