Attaching the Debugger to a Process at a Predictable Location

One method you can use to attach to a process at a predictable location is to add a looping function to your program that keeps executing until the debugger takes control and you interrupt it.

Example


  1. Add code such as the following to your application:

    volatile int endStallForDebugger=0;
      
    void stallForDebugger()
    {
            while (!endStallForDebugger) ;
    }
      
    int main()
    {
            …
            stallForDebugger();
            …
    }
  2. Run this version of your program.

  3. Attach the debugger to the running process.

  4. Stop the program with Ctrl+C or by using $stoponattach.

  5. Use the set variable debugger command to assign a non-zero value to the stallForDebugger variable, and continue executing the process, so that it exits from the loop. For example:

    (idb) set variable endStallForDebugger = 1
    (idb) # set any needed breakpoints, and so on
    (idb) cont

See Also


Submit feedback on this help topic

Copyright © 2001-2011, Intel Corporation. All rights reserved.