rentzsch.com: tales from the red shed

Bug: GDB breakpoints and errno

Bugs

Watch out: it appears GDB stomps on errno when landing on a breakpoint. Consider the following code:

int main(int argc, const char *argv[]) {
  errno = 0;
  assert(0 == errno); // breakpoint here fails
  return 0;
}

Works fine, in and out of GDB, unless you place a breakpoint on the assert() line and land there. When landing, GDB sets errno to 9 (EBADF). A breakpoint before or after that line works fine.

Repro’d on Mac OS X 10.4.8/Intel+Xcode 2.4.1 and 10.4.6/PPC+Xcode 2.2.1. Example project. rdar://problem/4861223

Update: Eric Albert and Alastair Houghton informed me that they couldn’t reproduce the bug using gdb directly on the command line, which sweeps the finger of blame in Xcode’s direction. Here’s a telling work-around: Disable Xcode’s debugger data formatters (Debug > Varibles View > Enable Data Formatters).

Sunday, December 03, 2006
12:00 AM