views:

48

answers:

3

I randomly get this error, and I can't figure out a way to fix it: the variables pane (top right) is blank, and the gdb "po" command can't print any variables.

Debugger with no variables

The "po" command doesn't even know about "self": No po either.

The problem appears specifically for all methods in the MGMinimap class. Nowhere else. I can debug from A and see self and the others, and then as soon as A steps into MGMinimap, the variables pane goes blank like the above image, and gdb doesn't work at all.

The temporary solution to this problem is to create a new class in XCode called e.g. MGMinimapNew, copy-paste everything from the real class's .h and .m into the new class, renaming the old class files to e.g. MGMinimapOld.m|h, then renaming the new class to MGMinimap.m|h. Doing this, things start working again. Still looking for a real answer though.

Update in answer to Rob Napier:

  • Run>Sync with Debugger. I always have high hopes for this. Occasionally it even works.
    • Unfortunately this wasn't one of those occasions :)
  • Select a different stack frame, then select this stack frame again.
    • No change
  • Switch threads and switch back.
    • No change
  • Step-over. Often going to the next line will sync things back up.
    • No change
A: 

This usually means that the object you are referencing somehow went out of scope. I would check that the variable or object instance were still in scope.

ennuikiller
Not sure why this would happen. Not even sure I understand what you're saying. Why would / how could "self" go out of scope?
Kalle
self can go out of scope (for a broad enough meaning of "scope") if you're deallocated on another thread, but the symptom of that is crashing, not the above problems with gdb.
Rob Napier
Ah... yeah, the object is most definitely not being deallocated.
Kalle
A: 

Why? Because Xcode/gdb integration is... flakey.... Sometimes it just doesn't know where you are. Some things you can try in order of increasing disruptiveness:

  • Run>Sync with Debugger. I always have high hopes for this. Occasionally it even works.
  • Select a different stack frame, then select this stack frame again.
  • Switch threads and switch back.
  • Step-over. Often going to the next line will sync things back up.

I wish there were a magic bullet that always worked. Sometimes gdb just gets lost.

Rob Napier
I updated the question with your tips -- none worked, though, long story short.
Kalle
Sorry it didn't help. If you're getting it often on the same line, I sometimes put the breakpoint on a different line. Just to be certain, you're using the standard Debug settings (particularly, optimization set to -O0), correct? With optimizations, sometimes the code you put a breakpoint on doesn't exist (but you tend to get different symptoms there). And you continue to get no variables even going to higher stack frames, right? (That indicates that gdb is completely lost.) One more try: type "where" in gdb. At least you can see where gdb thinks it is.
Rob Napier
Hm, yeah I haven't changed anything like that (went through all user defined settings and didn't see anything remotely close to debug settings). The one thing I have done is in "preprocessor macros", put in a IAM_DEBUGGING=1 which I use to separate debug build from release build using #ifdefs.
Kalle
Found that setting eventually, and yeah it's None [-O0]
Kalle
+1  A: 

Its an Xcode bug/wierdness . Try deleting all your breakpoints and doing a full clean.

If that doesnt work make sure your compiler hasnt slipped away from LLVM.

I had all sorts of heck going down after installing XCode4 and then going back to XCode3

Warren Burton
I did actually install XCode4 but in a separate location. I deleted it later, but yeah, I had the project open in XCode4 at some point, I think. Hrm. Will try the breakpoint thing right away.
Kalle
Nope, no go. I do have the [NSException raise] and objc_exception_throw symbolic breakpoints left (can't figure out how to delete them, actually), but deleted all others. No change. :/
Kalle
Definitely check if your compiler is set to what it should be if you opened up your project in XCode4 . I had this exact issue and XCode had switched the compiler to gcc4 when it needed to be LLVM (the third compiler??) . At work windows box so cant check.
Warren Burton
Hm... wow! I switched from "GCC 4.2" to "LLVM GCC 4.2" and I now actually did get the variable info *BUT* the stack frames are now gone instead! I get -[MGMinimap installTiles:] as top, then a single line with "??" below it. Insanity. Experimenting more...
Kalle
Switching to "LLVM compiler 1.5" had the same results as "LLVM GCC 4.2". Are you sure it should be LLVM? I thought that was the new, "beta version" compiler... not sure I wanna be quite that adventurous :O
Kalle
Yeah, LLVM compiler 1.5 is the new one but LLVM GCC 4.2 is the one you do want. A complete clean should remake your symbol files
Warren Burton
I created a new project from scratch and opened its build settings, then opened my current project's build settings and put the two side by side, comparing every entry. I did realize that Architectures had "Standard (armv6 armv7)" on my end, but "Optimized (armv7)" on the default project. Switched to Optimized, but no change.
Kalle
Warren: switched to LLVM GDB 4.2, did "clean all", then compiled and ran. I do get the variables and such, but the stack frames now show nothing except the current method. :(
Kalle
Hm, though after stepping over a few times, the stack frames did appear. I'm going to give this a run and see how it works out. Thanks a lot for the hints!
Kalle
LLVM GDB 4.2 seems... unstable, after using it for a bit. It keeps showing the current method twice in the stack frames, and in the processing losing one in the middle. I guess I can live with that though, but wish there was a stable alternative.
Kalle