Author Topic: Can't debug programs from Code::Blocks on Mac OSX  (Read 26967 times)

sswater

  • Guest
Re: Can't debug programs from Code::Blocks on Mac OSX
« Reply #15 on: March 29, 2014, 06:30:22 pm »
Exactly the same problem! It can RUN but cannot DEBUG.

When RUN, it seems that the $SCRIPT in ( osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script "$SCRIPT"' -e 'end tell' ) is successfully passed in, while when DEBUG, the $SCRIPT is empty.

Offline ridge

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: Can't debug programs from Code::Blocks on Mac OSX
« Reply #16 on: January 11, 2017, 10:52:24 am »
[SOLVED] Debugging works on Mac OSX using xterm.

OSX Version: 10.11 (El Capitan)
CodeBlocks Version: 13.12

Start Terminal from /Applications/Utilities.

Install homebrew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install debugger
$ brew install gdb

Codesign the gdb binary and kill taskgated:
Guide: https://sourceware.org/gdb/wiki/BuildingOnDarwin
(Note: You must make sure that taskgated is killed when following the guide.
Then, you should get a pop-up when using gdb within codeblocks the first
time, asking for credentials.)

In Terminal:
$ /usr/local/bin/gdb -v    (make sure it works)
(You could prepend your PATH with /usr/local/bin in your .bash_profile.
However, note that codeblocks won't see your PATH.)

Install XQuartz
Browser: https://www.xquartz.org/
(click on the .dmg, double-click after download, follow instructions)
Reboot (you could just log-out and log-in but the reboot should solve the taskgated issue, too)
First, start XQuartz from /Applications/Utilities.
In Terminal:
$ /opt/X11/bin/xterm   (make sure it works)
If you get the "Xt error: Can't open display" problem, you probably didn't reboot or log out.

In CodeBlocks: Settings->Debugger
Click Default
Set Executable path: /usr/local/bin/gdb

In CodeBlocks: Settings->Environment
Set Terminal to launch console programs: /opt/X11/bin/xterm -e $SCRIPT
Ignore the warning in the xterm window (the debugger seems to work fine):
warning: GDB: Failed to set controlling terminal: Operation not permitted
« Last Edit: January 12, 2017, 09:46:03 pm by ridge »