1

This is regarding to add some extra delay while opening gdb. The scenario is something like this:

  1. From c++ I use to call my gdb. which is auto configured with host setup in .gdbinit file. Target release localhost:PortNumber
  2. And gdb debugger stops at its reset vector location.
  3. I am giving the reset vector address through a pin prior to opening gdb, which should be updated and gdb should stop at new location.
  4. but gdb is still stops at its initial reset vector location.
  5. So, I need to give a short delay while opening the gdb.

How this can be done? Any solution will be appreciated.

ks1322
  • 33,961
  • 14
  • 109
  • 164

1 Answers1

0

See also this post: How to use the sleep function in C

#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>

int main(void)
{
    printf("starting gdb");
    Sleep(5000);
    printf("resume program");
}

Specify the delay in milliseconds

Anteino
  • 1,044
  • 7
  • 28
  • Hi @Anteino, thanks for the valuable input is possible without adding sleep or wait()? Like something while opening gdb only ? or in .gdbinit – nitin srivastava Dec 03 '19 at 16:58
  • Well, tell me exactly what you are trying to do first, please. I thought you wanted to stall the program until gdb was loaded. You can insert the command for starting gdb on the line where I wrote `printf("starting gdb");` The program will then wait 5000 milliseconds and continue. – Anteino Dec 03 '19 at 17:02
  • I want to give delay not from cpp but while opening GDB, i.e when gdb calls its .gdbinit file, it should open after few ms. – nitin srivastava Dec 03 '19 at 17:06
  • So you're working from the command line then? Please give us a little more info on what exactly you're trying to do. – Anteino Dec 03 '19 at 17:10
  • Okay, let me explain ... i have a cpp from where I open my gdb. While opening gdb it is automatically configured (from my .gdbinit file) the local host set-up to debug my source. So, I need a short delay when my gdb opens. I don't want to put sleep or wait in my cpp. I just want, when I call my gdb it should open with some delay. – nitin srivastava Dec 03 '19 at 17:15
  • I believe this thread answers your question then: https://stackoverflow.com/questions/4708760/c-timers-and-threads-again – Anteino Dec 03 '19 at 17:17