简体   繁体   中英

gdb on Yosemite: SIGBUS error when calling function at gdb command line

I am using GDB to debug a program on Yosemite OSX. At a breakpoint, I want to print out some information using an internal function, but I get a SIGBUS error even with a trivial function. For example:

Breakpoint 1, ...
(gdb) print my_info_function()
Program received signal SIGBUS, Bus error.
<function called from gdb>
The program being debugged was signaled...

where my_info_function is:

const char *my_info_function() {
  return "hello";
}

In addition, if I run the program with gdb, then interrupt it while it is running, then, regardless of whether the interruption occurs before or after the above breakpoint, print my_info_function() works fine.

This problem seemed to start occurring after upgrading to Yosemite (from Lion), so I am inclined to think it is related to that. I tried using different compilers (clang, gcc-4.9, brew vs macports), and using / reinstalling / rebuilding different gdb's (brew, macports, as well as this brew gdb version ), all to no avail.

Any suggestions as to how to fix this? I am using emacs + gdb and would like to keep it that way. I'd probably be fine with emacs + lldb, but it seems there is some debate over whether/when that will be supported.

Any suggestions as to how to fix this?

This looks like a bug in GDB.

You can either try to build GDB from source, debug GDB with itself, and send a patch to the gdb-patches mailing list , or just report it in GDB bugzilla (and hope that someone else fixes it).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM