GDB hanging when trying to print references.

177 views
Skip to first unread message

ol...@illusionlabs.se

unread,
Oct 14, 2015, 9:58:24 AM10/14/15
to android-ndk

Is there a known issue with printing references with GDB in latest r10e NDK?
For me, it seems it hangs 100% of the times I try to print a reference variable.

I have reference to a class, which include other classes. I can print the members of the class, but not the class itself.

Like this:

(gdb) p metrics.dim
$1 = {x = 106, y = 0}
(gdb) p metrics
$2 = (SystemText::SystemTextLabelMetrics &) @0xe1b18000: {text = {<std::__1::__basic_string_common<true>> = {<No data fields>}, 
    __r_ = {<std::__1::__libcpp_compressed_pair_imp<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, std::__1::allocator<char>, 2u>> = {<std::__1::allocator<char>> = {<No data fields>}, __first_ = {{__l = {__cap_ = 1818579724, __size_ = 7627621, __data_ = 0x0}, __s = {
              {__size_ = 12 '\f', __lx = 12 '\f'}, __data_ = "Select\000\000\000\000"}, __r = {__words = {1818579724, 7627621, 0}}}}}, <No data fields>}, static npos = 4294967295}, fontName = {<std::__1::__basic_string_common<true>> = {<No data fields>}, 
    __r_ = {<std::__1::__libcpp_compressed_pair_imp<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, std::__1::allocator<char>, 2u>> = {<std::__1::allocator<char>> = {<No data fields>}, __first_ = {{__l = {__cap_ = 33, __size_ = 20, 
              __data_ = 0xe1abfc80 "DigitalSansEF-Medium"}, __s = {{__size_ = 33 '!', __lx = 33 '!'}, 


Works fine to "p metrics.dim"  but if I try to "p metrics" the console hangs after printing the above (looks incomplete), and gdb starts using 100% cpu.
Also happened when trying to print a const std::string&, which makes me suspect the problem is the reference?

Anyone who recognises this and maybe even have a solution?

Cheers,
Olof



ol...@illusionlabs.se

unread,
Oct 14, 2015, 11:04:37 AM10/14/15
to android-ndk
Some more info. 
It seems it might not be references that is the root problem.

It happens when the thread gets blocked.
In this case, it was blocked because of an infinite loop in Java code, called by the C++ code a few lines after the line I was on.

If the program was in a state where the JNI call to Java would not hang, it worked to print the references.
But if it was in a state where the JNI call would hang, if I had continued, then it would hang when I tried to print any reference. (tried with this one, and a const std::string&)

Cheers,
Olof



ol...@illusionlabs.se

unread,
Oct 16, 2015, 9:54:10 AM10/16/15
to android-ndk
No-one has any ideas?

It happens when the thread is blocked for any reason. And it seems to be any "complex" type.
So if it stopped on an abort or such, I can not print anything but simple values like pointers and ints. If I try to dereference my pointer, then gdb hangs.

It makes gdb a lot less useful...
The device is a Samsung S6 with 5.1.  It is rooted, so I could set suid on run-as, to be able to debug at all...
NDK is r10e

Just an explanation why this happens would make it a lot less frustrating... or at least a confirmation if this is a known problem, or just some issue at my side.
Any hints of workarounds would be awesome.

John Morman

unread,
Oct 27, 2015, 5:34:27 PM10/27/15
to android-ndk
I believe I am seeing similar behavior myself. I can print basic types. But when I try to do something more complex like dereference a shared pointer gdb prints out the following

Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x3550

then it's done. I have to quit gdb at this point. I also see this same behavior anytime I try to run a function after stopping at a breakpoint. Do you see this as well?

I wish I could help provide an answer here but I think I'm just stuck in the same situation you are where debugging with ndk-gdb is rather useless.
Reply all
Reply to author
Forward
0 new messages