How can I attach to a running MCU target with OpenOCD + gdb? It seems to default to flashing the binary and performing a reset, and unchecking all options under Startup for resetting and flashing results in that no source code or symbols can be loaded.
Yup, you got it. But you can let the symbols/source load but not let the executable load. Disable the "Load executable". The two are unrelated.
But, there is no way to detach as this is not implemented in OpenOCD. The requirement for a gdb-server is to undo any changes made to enable debugging (remove breakpoints, etc.) and let the program continue. This does not seem possible.
Related
I repeatedly debug a program in Eclipse CDT in instruction stepping mode, i.e. a "step over" causes the next assembler/machine code instruction to be executed rather than the next line of C/C++ code.
Because I do it over and over again, it nags me to have to press the "instruction stepping" button again for every execution. Is there a way to enable it by default? I tried to find it in the debug configuration settings of the program that I debug, but I didn't find it there.
By default local launch is using new debugging framework called DSF which
does not remember this settings (at least in mars), however old one did remember it.
You can switch to old one using the following steps:
Open launch configuration
Click on link at the bottom to switch Launcher (on any page)
Select "Legacy Create Process Launcher"
If you use this one now if you press instruction stepping mode it will remember it for the next session
Recently, Eclipse SDK decided to kill my brain cells.
Out of the blue, it just stopped pausing at breakpoints. I do see it hit the breakpoint, but right then window loses focus and in the thread/callstack window it shows
MyApp [C/C++ Application]
MyApp [18556][cores:1]
Thread [2] (Running : Container)
Thread [1] (Running : User Request)
gdb
I see when i hits my breakpoint and it takes a blink of an eye before it goes into above state. My app stops responding and working and i have to kill it.
My app is a non GUI application which runs in linux as a background task, it reads and writes files, performs communication through COM and TCP/UDP. No user input is ever requested or anything like that.
There are tons of people who have problems with eclipse having problems with breakpoints, however they all are about java projects and or windows version of eclipse and none of the provided solutions work for me.
So far i have:
Rebuilt index.
Cleaned and rebuild project.
Deleted all debug files, makefile, binary and built again.
Cleared all breakpoints.
Made sure it was not set to ignore breakpoints.
and probably more which i already forgot.
Eclipse version is 4.2.1
Linux: Arch linux which was not updated for like 2 years now.
Project is C++.
What other information do i need to provide?
How can i solve this problem. I can't debug my application :(
I resolved this problem in this way: "Run" -> "Debug Configuration" -> select you configuration -> Debugger.
Then check the checkbox which shows "Use external console for inferior (open a new console window for input/output)".
I have a remote GDB stub to which my GDB debugger connects over TCP/IP under the control of Eclipse-CDT. The debugger doesn't support set auto-solib-add command. So when I start the application Eclipse (among other commands) sends: -gdb-set auto-solib-add on command to the debugger and it responds with ^error,msg="No symbol \"auto\" in current context." That causes launch to fail.
I tryed to reset Load shared library symbols automatically flag under Run->Debug Configurations...->C/C++ Remote Application->Debugger->Shared libraries. But despite my expectations instead of ommiting the command it sent -gdb-set auto-solib-add off and it didn't work, too.
I need to find a way to influence Eclipse and make it suppress (or in general to gain the full control of Eclipse's behaviour) this command.
Or maybe it is possible to make GDB debugger reply with a warning instead of the error to this command?
Eclipse-CDT: Juno, 4.1.2
GDB debugger: arm-elf-gdb, 6.1
I checked CDT source and apparently there is no way to do it short of implementing custom GDB connector (or forking CDT).
This command is issued as a part of the "final launch sequence" - see org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence:370. The reason it still sends the command when you uncheck the launch configuration box is to override whatever you may have in gdbinit.
Ok i have put breakpoints in my native code and now i need to run, problem is i am having problems specifying target i guess. I have a Droid X on which i want to run app and use gdb to debug going thru breakpoints
type
(gdb) run ????? don't know what to type with run, saw target options but can't understand how to attach to device
Ok i figured myself,
Install and run the app on device
Under project go do a ndk-gdb
if everything is ok, and you get a gdb prompt, enter your breakpoints
and type c to continue, i forgot to see ndk gdb doc, it's simple really
I've just spent a whole day trying to find a way to enable GDB debugging from Qt Creator or Eclipse. I learned that there are basically two approaches to launch the target application:
Using ssh (ssh host gdb)
Using gdbserver
I was able to use both approaches to launch gdb remotely and start the application. However, GDB never responds to any breakpoints set in the IDE. Also I can't pause the application to inspect the program state. In Qt Creator I just get an obscure stack trace (I might have been looking at the traces of ssh or gdb actually...).
Can anyone help me to get started?
Progress!
I found that with Qt Creator 2.0 there is an feature called "Attach and debug remote application." It's based on gdbserver. The good thing is that it stops on the IDE's breakpoints. However, there are two issues:
When it hits a breakpoint it only shows assembly code, not the source code.
GDB often quits because of 'signal received'
I should probably mention that the remote executable is compiled with an older version of GCC than the one installed on my local PC. Perhaps some of the problems are related to this.
Update
I should mention that I switched to running cgdb on the remote machine via SSH.
The remote Qt Creator-based solution wasn't stable. GDB tends to quit because of mysterious 'signal received' messages.
So that GDB on your host (the machine you develop and compile on, so where you have Qt Creator) you have to give it access to the "symbol file".
I usually don't use Qt Creator, but GDB and gdbserver directly for cross-compiled programs remote-debugging. You could maybe give this a try to be sure that this works for you and maybe then find the missing option in Qt Creator (or maybe this will help you find what is missing).
On the target machine run:
gdbserver :5000 yourprogram
On the host machine, run gdb and then load the symbol file:
(gdb) symbol-file yourprogram
On GDB on the host machine, you then have to connect to connect GDB to the remote gdbserver:
(gdb) target remote target_ip_address:5000
From then you can use GDB on the host controlling the program on the target.
I hope this helps!
Due to peculiarities in our makefile build system the file references contained in the debugging symbols look like this:
../src/main.cpp
../../src/utils/logger.cpp
This is no problem for GDB, but Qt Creator was unable to map these paths to the actual files. I was able to fix this by adding 'dir' statements in the GDB init file:
dir src
dir src/utils
...
Now it works.