gdb doesn't read the core dump on macOS - gdb

I've installed gdb formulae from Homebrew on OSX 10.10.5 to send a backtrace to developers of weechat (because weechat installed with Homebrew crashes every time I do /exit).
And got this problem when trying to read the core file:
gdb /usr/local/bin/weechat /cores/core.70087
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin14.5.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/weechat...(no debugging symbols found)...done.
"/cores/core.70087": no core file handler recognizes format
(gdb)
I've tried to do this with with lldb instead of gdb:
$ lldb /usr/local/bin/weechat /cores/core.70087
(lldb) target create "/usr/local/bin/weechat"
Current executable set to '/usr/local/bin/weechat' (x86_64).
(lldb) settings set -- target.run-args "/cores/core.70087"
(lldb) bt full
error: bt [<digit>|all]
(lldb) bt all
error: invalid process
(lldb) bt
error: invalid process
(lldb) thread backtrace
error: invalid process
(lldb)
Have no idea what am I doing, just trying to do whatever I can to address these crashes.

You should be able to launch lldb as
$ lldb --core "/cores/core.70087"

Related

Getting GDB 8.0.1 to work in CLion on OSX High Sierra 10.13.4

Long story short - LLDB doesn't debug my program properly, so I need to use GDB on my Mac to debug a c++ project. Steps I've taken:
Install GDB 8.0.1 and 8.1 via brew/macports (ie try all options)
Codesign the binary properly.
Start the mac in restart mode and typing csrutil enable --without debug
Choose the custom GDB executable in Clion.
Write in the .gdbinit file located in the home directory set startup-with-shell off
When I go to debug in Clion, in the debugger window it reads:
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin17.2.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
[New Thread 0x2203 of process 1208]
warning: unhandled dyld version (15)
In the console window it just prints the path of the executable and then hangs there until eventually it says 'command timed out'.
Any ideas would be massively appreciated.

gdb shows During startup program exited normally. in WSL (Bash on Windows, Windows Subsystem for Linux)

I'm using WSL(Bash on Windows = Windows Subsystem for Linux).
I wrote a simple code, a.c
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello\n");
return 0;
}
I compiled it.
$ gcc -g -o a.exe a.c
$
It worked well.
$ ./a.exe
Hello
$
And, I tried to execute a.exe in gdb. However, I got "During startup program exited normally."
$ gdb ./a.exe
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.exe...done.
(gdb) r
Starting program: /home/softgear/a.exe
During startup program exited normally.
(gdb)
How can I use gdb in WSL? Help me, please.
Looks like this is already reported and fixed WSL bug.
As a workaround you can set disable-randomization off before debugging, see https://github.com/Microsoft/WSL/issues/2870#issuecomment-359664608. Or update WSL to a latest version.

cygwin gdb Program received signal ?, Unknown signal

my.cpp:
#include<stdio.h>
int main()
{
printf("hello main");
return 0;
}
build with gcc and then
i use gdb to run the program, error occurred.
gdb: unknown target exception 0x406d1388 at 0x75fca6f2
Program received signal ?, Unknown signal.
0x75fca6f2 in RaiseException ()
from /cygdrive/c/WINDOWS/System32/KERNELBASE.dll
gcc info:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/5.4.0/lto-wrapper.exe
Target: i686-pc-cygwin
Thread model: posix
gcc version 5.4.0 (GCC)
gdb info:
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
It is a known bug for this version of GDB. This link may help you.
When I changed my cygwin to 64 version, the problem is suprisely solved.
I think this may be another a bug which differ from the "well-known" GDB bug.

Eclipse - remote debugging and segfault in dl_main at rtld.c

I want to debug my application written in C++ in Eclipse via network. I followed this tutorial http://janaxelson.com/eclipse5.htm but when debugging starts it gives me strange segmentation fault. Full log:
GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
0xb7fdf0d0 in print_statistics (rtld_total_timep=<optimized out>) at rtld.c:2594
2594 rtld.c: No such file or directory.
Program received signal SIGSEGV, Segmentation fault.
0xb7fe129f in dl_main (phdr=0x8048034, phnum=9, user_entry=0xbffff6ec, auxv=0xbffff7e0) at rtld.c:2182
2182 in rtld.c
I can't figure out what's wrong.
My setup is
Ubuntu 15.04, gcc version 4.9.2, gdb 7.9, Eclipse Mars
Target machine:
Ubuntu 14.04.2 LTS, gdb 7.7.1, gdbserver 7.7.1

GDB 7.7 symbols error SHT_SYMTAB_SHNDX

We have upgraded our C compiler to 4.5.3 and are now experiencing problems when trying to debug the server binary on solaris (works fine on linux rhel5 and AIX 6.1)
Below is the log of a debugging attempt. Any help would be appreciated.
-bash-3.00$ gdb myServer
Python Exception exceptions.ImportError No module named gdb:
warning:
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
Type "show configuration" for configuration details.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
BFD: BFD (GNU Binutils) 2.24.51.20140206 assertion fail elf.c:1727
Reading symbols from myServer...BFD: /data3/develop/myServer symbol number 7 references nonexistent SHT_SYMTAB_SHNDX section
Can't read symbols from /data3/develop/myServer: Invalid operation
(gdb)
BFD: BFD (GNU Binutils) 2.24.51.20140206 assertion fail elf.c:1727
This is a bug in gnu binutils. You should report it here.