Codeblocks not stopping at all breakpoints - c

I am attempting to build a custom lookup in exim, I have followed the docs and good the groundwork in place so my additional code is being compiled and hooked in, as well as being called. I am using the Makefile included with Exim to perform the build and I have added in CFLAGS=-g -O0 to ensure I have debugging symbols.
Codeblocks, gcc, gdb and the source all live on my Linux box, which I am SSHing into and exporting the X session to my Windows desktop using XMing, I don't think this has any baring on the problem, but worth mentioning.
Now, my problem is that when I run debugger with breakpoints in, C::B seems to be not setting or gdb is ignoring breakpoints in my code, but is hitting ones I have in the main function (I added one at exit so I could read the execution output and to prove they were working).
I have confirmed my code is actually being called, it currently spits out an error message, which it is doing. If I add a breakpoint on that line, it doesn't fire, nor if it's on the function or first line of the function.
What is even stranger (to me), is that previously it was working! it only stopped working when I resized the bottom C::B pane which caused a portion of the screen to not render (I think this is a problem with C::B and XMing, sometimes I just get a grey blank window and need to stop and restart C::B). So I quit C::B, restarted it, reloaded my project and since then break points in my code simply do not work, even though I can prove the code is being executed.
Also if I manually add the breakpoint it works as expected. I set a breakpoint in C::B at the start of main. Hit debug and then sent b mddfind_open (name of my function) into gdb and hit continue.. C::B stops again at the start of that function. Possibly some weirdness with how C::B is passing the breakpoints to gdb?
UPDATE:
The project I am working on is Exim, which links the code into the build directory (due to some bug with gcc 2.92.x and extern's IIRC). If I open the file from that location in C::B and set a breakpoint it works as expected. I suspect that C::B is possibly passing incorrect references to gdb?
Any ideas?

It would seem that in this situation I need to specify the source path for the source file in question, even though it is within the root source path.
Originally I had my GDB source path set to:
/home/graeme/exim/src
The code in question lives in src/lookups, so adding that path too fixes the problem
/home/graeme/exim/src
/home/graeme/exim/src/lookups
I believe this situation has arisen as the code I am building is initially compiled into a static library, this library is then linked into the main program itself. As such symbols reference the source for the library source files located at the point the library was compiled. So in this case there are multiple packages being built, and I needed to reference each of them in the source paths.

Related

How to keep watching variables and their values in VS Code Debugging Session?

So I've been writing a program in C and debugging to solve the problems I had. After I solved those problems, I could not watch the values of the variables since debugging session just quits because there are no errors or breakpoints after I solved the problems occurred previously.
My editor is Visual Studio Code, running it on macOS, GCC.
You should basicely put breakpoints at the end of your code, for example on the return line.
If you just want to know which values your variables have at the end of the execution, you can put printf("%x", your_variable); //DEBUG for the variables you want to see, and remove these lines when you finished debugging.
Moreover, if you're familiar with prompt commands, I recommand you to install gdb, this debugger is very powerful and easy to use ! Here is a little tutorial if you're interested ;)
Set your breakpoint on the code then press F5 to run the app in VSCode. Once the breakpoint hit, you can see local variables by selecting Run and Debug button (Red). You alse can add variables into Watch...

How to load shared libraries symbols for remote source level debugging with gdb and gdbserver?

I've installed gdb and gdbserver on an angstrom linux ARM board (with external access), and am trying to get source level debugging of a shared library working from my local machine. Currently, if I ssh into the device, I can run gdb and I am able to get everything working, including setting a breakpoint, hitting it and doing a backtrace.
My problem comes when I try and do the same using gdbserver and running gdb on my host machine in order to accomplish the same thing (eventually I'd like to get this working in eclipse, but in gdb is good enough for the moment).
I notice that when I just use gdb on the server and run "info shared", it correctly loads symbol files (syms read : yes for all), which I'm then able to debug. I've had no such luck doing so remotely, using "symbol-file" or "directory" or "shared". Its obviously seeing the files, but I can't get it load any symbols, even when I specify remote files directly. Any advice on what I can try next?
There are a few different ways for this to fail, but the typical one is for gdb to pick up local files rather than files from the server.
There are also a few different ways to fix this, but the simplest by far is to do this before invoking target remote:
(gdb) set sysroot remote:
This tells gdb to fetch files from the remote system. If you have debug info there (which I gather from your post that you do), then it will all work fine.
The typical problem with this approach is that it requires copying data from the remote. This can be a pain if you have a bad link. In this case you can keep a copy of the data locally and point sysroot at the copy. However, this requires some attention to keeping things in sync.
First run up to main, and then set solib-search-path . Otherwise, gdbserver stops in the dynamic loader, before libraries can be loaded. More details at: Debugging shared libraries with gdbserver

C error parsing in Eclipe-Indigo is not functioning

I'm trying to migrate some C programs from Windows Server to Linux. To edit the code, I'm using Eclipse-Indigo. The machine on which I'm working has WinXP on it (not my choice, so no comments please). My eclipse workarea is on a samba shared drive which is in my home directory on the Linux server.
Each C program is in a separate makefile project. I have specified the cygwin gcc compiler/parser in the settings for new CDT Projects and selected all relevant error parsers in the makefile project settings.
There are no syntax errors showing and the errors that are listed seem somewhat bizarre. The first error states:
make: *** No rule to make target `../../../../../fiscus/vo/src/mk/e12_.mk'. Stop.
The make script at the end is wrong. There is a value in the name which comes from an environment variable. The path is correct exactly as shown but the script name has hte variable $(WA_PLATFORM) in it. This is not being resolved although I have specified the value in the build environment variables.
The subsequent errors are even weirder. For each subsequent project I get the message:
Program "make" is not found in PATH
This makes me wonder how the first message was generated. Besides, the path on my winXP environment, which I assume is the relevant one here, does indeed have the directory with the make program in it.
Where have I mucked it up? Any hints?
One last piece of information. When I shut down eclipse I get access violation errors for the following:
<workarea-path>\.metadata\plugins\org.eclipse.debug.ui\launchConfigurationHistory.xml
<workarea-path>\.metadata\plugins\org.eclipse.jdt.core\variablesAndContainers.dat
I find this to be suspicious...
The problem appears to lie in the fact that I was using the samba share as my workarea. Apparently the regular backups made on the server changed something (don't know exactly what, though). The projects were no longer being recognised as makefile projects and certain essential metadata files were not accessible. The permissions certainly were not the problem, since I checked those on the server (everything was set to rwxrwxrwx).
To solve the problem I copied the entire workarea to my local hard drive. I then pointed eclipse at this new workarea. The next step was a bit of a pain, because I had to delete each project (without deleting the source, of course) and then import "Existing code as Makefile Project". This can be done with "File->import..." or with a right-click in the package explorer and select "import...".
The last requirement is to specify the required "include" directories. This can be done with "Project-> Properties-> C/C++ General-> Paths and Symbols". Select the "Includes" tab, choose the language (in this case "GNU C") and add the directories where the headers are defined.
Now it works properly again.

openFrameworks: Math killing debugger?

Using a lerping rectangle class in openFrameworks. I then tried to instantiate it as an array, but it crashed with error:
"warning: Could not find object file "/Users/mike/Projects/simbl/build/SIMBL.build/Deployment/SIMBL.build/Objects-normal/i386/SIMBLPlugin.o" - no debug information available for "/Users/mike/Projects/simbl/src/SIMBLPlugin.m".
The release build was slightly more stable than the debug.
When commenting out these two lines (within a function called continuously throughout the array of its class), it runs fine.
pos.x = catchUpSpeed * mouseX + (1-catchUpSpeed) * pos.x;
pos.y = catchUpSpeed * mouseY + (1-catchUpSpeed) * pos.y;
catchUpSpeed is .03f
Any thoughts on the error message? How did this error arise and how can it be avoided? I can't make heads or tails of it. Seems like simple enough math.
Thank you for reading!
You shouldn't see a crash if this happens, or rather, a crash shouldn't be caused by/related to this warning.
There are two ways to build your app with debug information on Mac OS X / iOS: "DWARF" and "DWARF with dSYM". (these are options in your Xcode project Build Settings)
"DWARF" means that the debug information exists in your .o (object) files. It is not copied into the final executable binary for your app. Your app binary has pointers back to the debug information in the object files. This helps to speed up the link & run cycle. But for it to work, your object files need to be located in the same place as when your built your app. Copying your app to another computer would likely break this. Removing your build intermediates would result in the same problem. The "DWARF" debug info scheme is designed for active development on your local desktop where the .o files will remain in place and not be removed while you're debugging your app.
"DWARF with dSYM" means that when your app binary is linked together, another command (dsymutil) is run to create a linked version of all of your debug information -- a .dSYM bundle. This collects all of the debug information from your object files into a single bundle, and it sits next to your binary. If you want to copy your binary to another system to run & debug it, bring the dSYM along and everything will work fine.
I'm not sure how you're using the build system so that this arrangement is failing for you at debug time, but if you're doing something behind the scenes so that your SIMBLPlugin.o object file does not exist wen you're debugging your app, try changing your project to DWARF with dSYM and you should be fine.
If Xcode is crashing, it's unlikely to be related to that warning message from the debugger. But it would be worth filing a bug report if you're seeing this with a current (Xcode 4.6, etc) version of the tools. http://bugreport.apple.com/ - include the crash reporter text from one of the instances and that'll be a place for them to start.

Application is compiled but does not run

I made some changes in a WPF xBap application and it compiles well but the new changes is not applied and when I put a break-point on the changed lines, the IDE ignores the break-point and shoes the following hint message: "The breakpoint will not currently be hit, No executable code associated with this line."
I tried the following:
Cleaned and Rebuilt the Solution
Cleaned the cache
Restart the machine
and no hope.
Any idea or suggestion will be appreciated.
Note: The application works well with the new changes in the published version but it does not through the IDE.
"No executable code associated with this line"
try to add a debug line Console.WriteLine() and add a break point at that line.
I found the problem, it's because a wrong path in the file projectName.csproj.user.
I opened the file using the notepad and edited it manually.

Resources