#176462 - Rajveer - Sun Jul 31, 2011 2:04 pm
I have a project which compiles both for the Nintendo DS and Windows, so all of my debugging I've been doing in Visual C++. I've got a DS specific problem now and am trying to debug with DeSmuME and Insight, however Insight won't let me set breakpoints in many functions (including the one I'm trying to debug), only on lines of code with black horizontal lines next to them. From what I've read I should be able to put breakpoints wherever I want, so is this normal?
#176463 - elhobbs - Sun Jul 31, 2011 3:45 pm
you need to disable optimizations when compiling in order to set breakpoints on any line. You need to change your makefile CFLAGS. change -O2 to -O0 and remove -fomit-frame-pointer when building a debug build.
#176464 - Rajveer - Sun Jul 31, 2011 6:03 pm
Thanks for the suggestion, I think I'm still doing something wrong though. I can set breakpoints wherever I want in my main.cpp file (each line that's not commented out has that black horizontal line next to it which allows me to set a breakpoint), but only a few of my other source files allow me to. In fact the source file that has the function to be debugged has lost all of those black lines, so I can't set a breakpoint anywhere in that file now. Here are my code gen options:
Code: |
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork
CFLAGS := -g -Wall -O0\
-march=armv5te -mtune=arm946e-s\
-ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM9
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) |
EDIT: The spacing is a bit messed up when I paste from my makefile.
#176465 - elhobbs - Sun Jul 31, 2011 7:49 pm
I am not sure if you are doing something wrong. I just opened one of my old projects in insight compiled with the same flags as you are using from a previous devkitarm install and it was working. I recompiled with the current devkitarm and I can no longer set breakpoints in insight.
#176466 - wintermute - Sun Jul 31, 2011 9:56 pm
You'll need a new Insight for latest devkitARM that I haven't got around to uploading yet. The arm-eabi-gdb included with devkitARM will work though
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#176467 - wintermute - Sun Jul 31, 2011 9:59 pm
elhobbs wrote: |
you need to disable optimizations when compiling in order to set breakpoints on any line. You need to change your makefile CFLAGS. change -O2 to -O0 and remove -fomit-frame-pointer when building a debug build. |
Actually this is a myth, you can quite happily set breakpoints in optimised code. Stepping will look a little odd and some lines will be missing entirely since they're optimised out.
Switching to -O0 for debugging purposes is also rather pointless, you're not necessarily debugging the code that's breaking since it quite often only breaks on the higher optimisation levels.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#176468 - Rajveer - Sun Jul 31, 2011 10:18 pm
Thanks for going to the effort of checking what was the cause elhobbs, and wintermute for confirming. I'll learn how to use GDB without a GUI, although shamefully I'll admit that I'm a GUI kinda guy :)
#176470 - elhobbs - Mon Aug 01, 2011 2:11 pm
wintermute wrote: |
elhobbs wrote: | you need to disable optimizations when compiling in order to set breakpoints on any line. You need to change your makefile CFLAGS. change -O2 to -O0 and remove -fomit-frame-pointer when building a debug build. |
Actually this is a myth, you can quite happily set breakpoints in optimised code. Stepping will look a little odd and some lines will be missing entirely since they're optimised out. |
I was not trying to say that it is impossible in optimized code. I was trying to say that if you want to be able to stop on every line then disabling optimizations will allow that. it is hard to tell what someone's problem is from a few lines in a forum post - though Rajveer did say that it is missing from "many" functions but not all. it seemed like a good place to start.
wintermute wrote: |
Switching to -O0 for debugging purposes is also rather pointless, you're not necessarily debugging the code that's breaking since it quite often only breaks on the higher optimisation levels. |
that may be true for the code that you write, but the simpleton stuff that I write tends to fail just fine without optimations turned on.
#176471 - Rajveer - Tue Aug 02, 2011 12:07 am
I gave arm-ebai-gdb a shot today and I'm still having issues. I tried listing the beginning of various functions in different source files (with list filename:function), GDB correctly listed those functions where I could set a breakpoint in Insight. In the source files and functions where I was having problems before, it listed the beginnings of totally different functions (the ones I tried showed glCallList - I'm including videoGL.h in the source file, but not using glCallList in any of those functions). So does this mean that the debug symbols are messed up if arm-ebai-gdb is supposed to work?
#176486 - wintermute - Thu Aug 04, 2011 10:46 pm
I just uploaded the new insight builds, give those a shot.
Any chance you could send me a copy of your project to have a look & see if I can figure out what's going on? Drop by IRC if you get a chance.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#176489 - Rajveer - Sat Aug 06, 2011 1:02 am
Awesome, the new Insight build works and I can step through my code, thanks a bunch :)
One thing, I get the horizontal lines next to my code but I can't set a breakpoint by clicking on them like I could in the older build. Although I was able to right click on the function name that needed debugging and choose set breakpoint, which set a red square on the first black line at the beginning of the function.
I could definately send you a copy if it will help with anything; since it works with the new Insight, do you still want it (maybe you want to see why it wasn't working with the older GDB)?