GDB command file in XCode - xcode

I'd like to add a file to my project that has a list of gbd commands and load that into GDB within xcode at any breakpoint. Looking at GDB documentation I see the "source" commmand, but it is unknown within xcode's gdb. Has anyone had success doing this?
source -f commandfile.gdb
Thanks,

The source command appears to work although no options are supported if you are really using gdb as the debugger. In the debug console make sure it says "(gdb)" as the prompt. The default debugger now is LLDB instead of GDB. You can change this under Product -> Edit Schemeā€¦ and select the "Info" tab at the top. The "Debugger" popup will present you with GDB or LLDB.

Related

LLDB lost the ability to autocomplete filenames

I'm not sure if I've been dreaming these past years, but all the time I've used lldb, I've been able to autocomplete source file names when setting breakpoints
(lldb) breakpoint set --file m<TAB>
would autocomplete to
(lldb) breakpoint set --file main.cpp
for instance. Now this does not work anymore. Neither in lldb 3.8.0 on Ubuntu 16.04, nor in lldb 10.0.1 or 12.x on macOS.
This renders command-line usage basically impossible if I have to manually copy-paste or type in file names.
What could this be caused by and how do I restore this function?
In one case where it did not work, I had passed -flto compiler flag for Link-Time-Optimization. This removed the ability to autocomplete sources, presumably because info about source files is lost completely.
In another case where I don't have this enabled, there is still no autocompletion.
Too bad lldb cannot simply show the known source files like gdb can with info sources.

XCode: custom lldb or adding args to existing one

Recently I found that it's possible to debug via lldb remotely but from command line. So the question: is it possible somehow to replace standard lldb with my version or to have any control over command line which is passed from xcode when it's launched.
there are two reason for doing this:
pure remote debugging, extremely convenient when debugging focus/eventTarget issues (window/process activation/deactivation)
debugging of root processes following the manual Debugging in XCode as root . I'm aware about "debug as root" in xcode 6 option, but it doesn't work for me for some reason... Also notice that there an option to select a debugger in lld Debugger/Attach to Process/By Process Identifier (PID) or Name... However the option is only.

Unable to hit breakpoints in MonoDevelop

On my archlinux system I did a fresh installation of:
mono 3.0.7
monodevelop 4.0.8
monodevelop-debugger-gdb 4.0
When I debug an application the debugger doesn't stop on the breakpoints, even not on the System.Diagnostics.Debugger.Break (); code.
And an error windows is displayed with the following message :
Could not connect to the debugger
Does anyone know how to fix it?
This is due to a recent gnome-terminal change. Recent gnome-terminal no longer accepts the --disable-factory argument.
Install the xterm package, then in a gnome-terminal session do the following:
$ unset GNOME_DESKTOP_SESSION_ID
$ monodevelop
This will cause monodevelop to use xterm as its external terminal and all should be well.
As a workaround untick the "Run on external console" checkbox in your running project settings. You can find this option in the "Run" tab from the settings pane.
Another factor which will cause break points to not be hit is if you don't have "Emit debugging information" button set.
You'll find this setting in "Project" tab then at the bottom of the menu " Option". Then look for "Build" tree branch then "Compiler" option. The checkbox for "Emit debugging information" is here.
I had a similar problem - breakpoints was not triggered while checkbox "Use MSBuild build engine" was checked in the project properties.

How can I automatically run my programs in a Terminal window & debug with Xcode?

I am building a program on Mac OS that uses the curses library. When I attempt to run it inside Xcode, I get this error message:
Error opening terminal: unknown.
And then curses calls exit.
Obviously, it works from a Terminal window.
Is it possible to launch my program in a terminal window from Xcode? I know that I can use the "Wait for XXX to launch" option, but a lot of Xcode's helpfulness in starting programs vanishes that way, so I would be looking for another way.
Xcode uses GDB, or LLDB for debugging.
You can invoke them directly from a terminal. This way, your executable will be attached to a working one.
Try:
gdb path/to/my/executable
Then, from the GDB prompt, type:
run
To start your program in debugging mode.
Take a look at the GDB manual for learning stuff like debugging commands, breakpoints, etc.

Can I use my gdb to debug an XCode project

I have a XCode which builds and runs under XCode.
I would like to know if it is possible to debug it using a gdb I build under Mac OSX (gdb 7 to be specified). If yes, can you please tell me how can I do that?
Thank you.
gdb-7.0 reverse debugging currently can only work with two classes of targets:
1) a remote simulator/emulator/virtual-machine that supports going backwards, or
2) the built in "process record" target, which at present has only been ported to x86-linux, x86-64 linux, and moxie linux.
Well, now -- I take that back. I recently discovered that process record can work with any remote x86 target, so if you're connecting with your macintosh target via "target remote", you might just be able to do it!
There is an online tutorial for process record here:
http://www.sourceware.org/gdb/wiki/ProcessRecord/Tutorial
More info about process record here:
http://www.sourceware.org/gdb/wiki/ProcessRecord
And about gdb reverse debugging here:
http://www.sourceware.org/gdb/wiki/ReverseDebug
So you want to use your own version of gdb to debug your executable? Easy!
Open Terminal, and do something like this:
$ cd <directory where Xcode project lives>
$ cd build/Debug (for example - depends on project configuration)
$ /usr/local/bin/my-gdb ./MyExecutable
Of course, specifying the actual path to your custom gdb version.
XCode's debugger is gdb (likely with Apple-specific modifications.) When you debug an application you can get to the gdb command line by opening the Console from the Run menu.
What requirements are imposed on your application that would require you to debug with your own version of gdb?

Resources