1

I'm trying to debug a simple program of several line with gdb from the command line. The problem is that whenever I run the program it runs the program and then automatically assume that I wanted to quit and quit gdb for me.

  • I'm using gcc compiler and I've updated the version (which solved another problem that I had).
  • to clarify the problem is that it is not me who entered the quit command after the run command, gdb generates it automatically without asking me and then assumes yes. Code show the process mention above.
BarAmber
  • 11
  • 3
  • 1
    Maybe you have some fancy `.gdbinit` as in https://stackoverflow.com/questions/3740754/make-gdb-quit-automatically-on-successful-termination/5286038 ? – Eugene Sh. Mar 25 '21 at 13:39
  • Seems like it is the same problem the other way around though I can't figure out how to cancel it from their answers, any suggestions? – BarAmber Mar 25 '21 at 14:02
  • Check your `.gdbinit` files. There are might be several though... – Eugene Sh. Mar 25 '21 at 14:03
  • 1
    suggest: 1) before entering the `run` command, set a breakpoint on the beginning of the program: `br main` and also set a breakpoint on the last executed line of the program – user3629249 Mar 25 '21 at 15:32
  • 1
    Please do not post links to images. Rather, copy/paste the actual text into the text of your question – user3629249 Mar 25 '21 at 15:43
  • what is the linked image of your commands to `gdb` expected to show? Right after the `run` command, you entered `quit`! What does that have to do with your question? – user3629249 Mar 25 '21 at 15:46
  • That's exactly the problem! That's not me who enter `quit` it does that without asking me. I'm setting `br main` and then gdb verifies that it's actually set the breakpoint and then I run the program and it just does everything normal and continue to `quit` anyway then `assume yes` automatically. – BarAmber Mar 26 '21 at 08:55
  • Are you debugging a cygwin executable? If yes, could you try it in the cygwin terminal? If not, why are you using a cygwin gdb? – ssbssa Mar 26 '21 at 14:26
  • @ssbssa I've tried to run it in the cygwin terminal and it worked, so first of all thank you because that a great advancement though I would like to understand why it doesn't work on the command-prompt. I'm following an udemy course and the instructor runs it via the command-prompt (tried to ask him for solution and he couldn't answer) – BarAmber Mar 26 '21 at 15:38
  • What gdb version do you use? Because [this answer](https://stackoverflow.com/a/65515071/1983398) says it fixed a similar problem by updating. If you also use an older version, why? – ssbssa Mar 26 '21 at 15:49

1 Answers1

0

I fixed this problem by running gdb in a cygwin window rather than a Windows command window. I get the cygwin window by running (i.e., double-clicking on) mintty.exe, which on my machine is at

C:\cygwin64\bin\mintty.exe
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83