GDB backtrace does not show function names

I compiled my library (specifically protbuf-2.3.0 ) using -g -O0 on SunOS 5.10.

An example of a line in the log:

 /bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -pthreads -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -g -O0 -MT text_format.lo -MD -MP -MF .deps/text_format.Tpo -c -o text_format.lo `test -f 'google/protobuf/text_format.cc' || echo './'`google/protobuf/text_format.cc libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -pthreads -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -g -O0 -MT text_format.lo -MD -MP -MF .deps/text_format.Tpo -c google/protobuf/text_format.cc -fPIC -DPIC -o .libs/text_format.o 

And then I connected my gdb by following these steps:

  • Run my application (in this case, my web server is launching a Java application using the library through jni at startup).
  • I linked my gdb to this process via gdb -p XXX (where XXX is the pid I received from ps ).
  • And then I downloaded my library from gdb using file libprotobuf.so from the gdb prompt.

But I can not see the names of my functions from bt . The GDB backtrace command shows something like this:

 (gdb) bt #0 0xf8f98914 in ?? () #1 0xf8f98830 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) 

I also tried doing only # 1 and # 2, # 1 and # 3, and # 1 and gdb libprotobuf.so -p XXX .

In addition, I also tried to run my jvm in debug mode and added a breakpoint in the System.loadLibrary(..) command, and after going through this command, I performed the gdb binding process again ... but still nothing.

However, I can set breakpoints for the given function names and list the contents of the function via list . But then again, I can place breakpoints, but they also don’t stop at these function names (I know that he switched to this function because he is in the jvm hs_err_pid report after every jvm failure).

Any ideas come that it doesn't show me the names of my functions?

+4
source share
3 answers

The problem, most likely, is that GDB does not know how to determine the full executable path for a given PID. If he knew the full path, you would not need to take step number 3 - GDB would add it automatically.

You can check if the GDB executable is outputting correctly using the (gdb) info file command.

If my guess is correct, help GDB by invoking it as follows:

  gdb /path/to/java <PID> 

This should solve all your problems immediately.

+1
source

Also, make sure that the executable that uses your library is not getting something.

+1
source

I think this is a communication problem. Can you check your command, which is executed during the connection. Hope this helps.

-2
source

Source: https://habr.com/ru/post/1303543/


All Articles