Search code examples
gdb

GDB command to know whether the program is running or stopped


I am trying to automate a GDB Debugging session, I want to know whether is there any command or any other way in GDB which will help me know whether a program is running or stopped ?


Solution

  • I added a new command into gdb to know whether the program is running or stopped.

    if(is_running (inferior_ptid))
    {
          fprintf_filtered (gdb_stdout, "running\n");
    }
    else
    {
        fprintf_filtered (gdb_stdout, "stopped\n");
    }