I have a core file generated on an HP IA64 machine. I have the executable and shared objects related to the core file. I am trying to get the call stack using the adb debugger but the core file was generated on a machine I don't have access to, so the shared objects are in a different location than they are at the time the core file was generated.
I know if I have a similar situation using gdb I would do the following:
machine:user> gdb
(gdb) set solib-search-path path1:path2:path3
(gdb) file <name of executable file>
(gdb) core <name of core file>
Where the setting of solib-search-path tells gdb where to load shared libraries from.
Is there an equivalent if I'm using adb?
The answer seems to be not to use adb in this situation but use gdb.
Related
I have libc6 & libc6-dbg installed.
(gdb) b
reak freeifaddrs
(gdb) run
Breakpoint 1, __freeifaddrs (ifa=0xa822e0) at ../sysdeps/unix/sysv/linux/ifaddrs.c:840
840 ../sysdeps/unix/sysv/linux/ifaddrs.c: No such file or directory.
(gdb) list
835 in ../sysdeps/unix/sysv/linux/ifaddrs.c
(gdb) disassemble
Dump of assembler code for function __freeifaddrs:
=> 0x00007ffff7912fd0 <+0>: jmpq 0x7ffff780f8a8
End of assembler dump.
(gdb) where
#0 __freeifaddrs (ifa=0xa822e0) at ../sysdeps/unix/sysv/linux/ifaddrs.c:840
However, gdb refuse to get me any info about ifaddrs.c, although it knows it is on line 840
What happened here?
The debugging information in the libc6-dbg package includes the names of the source files for the C library, and a mapping from assembly instructions to specific lines within those source files, but it does not include the source files themselves. So gdb can tell you that your breakpoint is associated with line 840 of a file named sysdeps/unix/sysv/linux/ifaddrs.c, but it can't show you what's actually on that line. (The leading ../ is an artifact of glibc's terrifyingly complicated build system.)
If you know where to find the Git repository for the source code for the GNU C Library, then you can look up that specific file and line by hand in a web browser. This is relatively quick and easy once you know how to do it, but probably won't show you the exact same version of the code that was used to build your copy of the library (this file in particular doesn't change very often, but others do), and it doesn't get you access to the code inside gdb.
To get the code visible inside gdb, you would need to download the source package that matches the C library on your system. Based on the package name libc6-dbg I am guessing you are using a Linux distribution in the Debian family; if that's right, the command
apt-get source glibc
will do the job. Then you can use the GDB command directory to tell GDB where to look for the source files. It will probably take a bit of fiddling to get everything working just so.
I managed to setup the Neutrino 6.5.0 RTOS in a virtual box and connect to it over qconn from Momentics IDE for Blackberry IDE 2.1.2 .....
I can get the system information perspective view for my Neutrino.
BUT
when I am trying to run my compiled application I am getting the errors :
Could not launch
Cannot find qnx launch process
and
Error starting remote application.
Target launcher#<192.168.56.101:8000>: Error: Attempting to exec a shared lib
SO I manually copied the executable file I compiled to the /tmp dir on my Neutrino virtual machine and run it using ./Test ,still get this error:
"/bin/sh: ./Test: Attempting to exec a shared lib"
I rechecked the project option and make sure that this is an Application output and not a shared library output type.
Any idea what am I doing wrong ?
I also encountered the same problem. Later, I found that the cross compiler was selected incorrectly. This error occurs when x86 programs are run on arm processors; Specify the correct compiler to solve the problem;
I try to debug some native code on Android with GBD. The code wasn't created by me and is not in an Android project, so I can't use the ndk-gdb tool. I use gdbserver on the android machine and connect to it from my mac with the normal GDB program. I try to load all the libraries (which should have symbols according to objdump tool), but gdb tells me that it does not load the symbols (according to the gdb command “info sharedLibrary”). These are the steps I took:
start gdbserver on Android machine
start GDB with the debug version of the binary
gdb symbols/system/bin/mediaserver
the following commands are executed in gdb itself
tell gdb where to look for the libraries with symbols
(gdb) set solib-search-path symbols/system/lib
tell gdb where to find the source files
(gdb) directory /sources
connect to remote target (Android machine)
(gdb) target remote 192.168.1.10:5039
GDB connects successfully to the running binary and I can pause and continue the execution. But it does not show me any debug information like function names or line numbers. It only shows adresses. When I check the status of the used libraries, I see that gdb thinks, they don’t have any symbols:
command in gdb:
(gdb) info sharedLibrary
From To Syms Read Shared Object Library
0x00003700 0x0000ff0c Yes /symbols/system/bin/linker
No libc.so
No libstdc++.so
No libm.so
No liblog.so
No libcutils.so
No libspeexresampler.so
No libaudioutils.so
No libgccdemangle.so
No libamplayer.so
Now for example the last library. When I check with the file command (not in gdb), it tells me that it is a not stripped library (the library is located in the "symbols/system/lib" folder).
file libamplayer.so
Output:
libamplayer.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped
objdump command shows a lot of symbols in it (I don’t show the output because it’s very long). So why does gdb not recognise the symbols in this libraries? I thought, at least line numbers and function names are present in not stripped versions of libraries. Or am I wrong? It would be very nice if someone could give me more insight.
Thanks!
System info:
GDB Version: 7.3.1-gg2 on Mac OS X Mavericks
The code wasn't created by me and is not in an Android project, so I can't use the ndk-gdb tool.
Your conclusion does not at all follow. ndk-gdb should be able to debug any Android program, whether created as a "project" or via other means.
I use gdbserver on the android machine and connect to it from my mac with the normal GDB program.
The normal GDB is likely not configured for cross-debugging, and thus doesn't understand ARM binaries at all. I am surprised you get as far using it as you do.
I use gdb in a cross-compiling environment where I build a linux tree for the target architecture, including lots of shared libraries.
Problem: When I analyze a core dump, gdb finds the paths to my .so files and their symbols, but not their source files.
Host setup:
tree/ <-- Build root
tree/apps/myapp/myapp <--My crashing app
tree/libs/mysharedlib/ <-- Shared libs are built from paths like this and installed in target/
tree/target/ <-- Target build root
tree/target/usr/bin/ <-- My crashing binary goes here
tree/target/lib <-- Some .so:s
tree/target/usr/lib <-- Some more .so:s
Example output:
...
#9 0x2b038cfc in start_thread (arg=0x32dff4d0) at pthread_create.c:302
302 pthread_create.c: No such file or directory.
in pthread_create.c
...
How does gdb know where to search for source files by default?
I know that it's possible to use the 'directory' command in gdb to specify
source directories manually, and it works, but I don't want to do that for
every shared lib. I want to set the root from which all my stuff was built. When I do live debugging using gdbserver, gdb automatically finds the source for all shared libs, so I would like the same behavior for core files.
Is it only the .c filenames that are specified in the debugging information in
the binaries or do they have paths as well? Relative or absolute?
Please clarify ..
I have a multithreaded 64 bit C process running on sun10 server. It is occupying 2.2 GB of RAM.
When I take the gcore and debug it, it is showing me "no symbol table" on GDB prompt. Hence i am not able to debug anything.
The binary is not stripped and compiled with -g gcc option .The gcore if of 32 bits.
Why the procress image is not showing any symbols ??
Thanks-
viva
Did you try to start gdb with both executable file and core dump file?
gdb executable core
This will load symbols from executable and memory dump from core.
As said in gdb manual,
Traditionally, core files contain only some parts of the address space of the process that generated them.