How to Stop Continue in Gdb

How do I halt the continuing in GDB

Solution 1

You should interrupt the process that is attached by gdb. Do not interrupt gdb itself. Interrupt the process by either ctrl-c in the terminal in which the process was started or send the process the SIGINT by kill -2 procid. With procid the id of the process being attached.

Solution 2

Control+C in the gdb process should bring you back to the command prompt.

Solution 3

Here's a short GDB tutorial, and here's a full GDB manual.

The point of debugging is to inspect interesting/suspicious parts of the program. Breakpoints allow you to stop execution at some source location, and watchpoints allow you to stop when interesting data changes.

Simple examples:

            (gdb) break my_function (gdb) cont                      

This will insert a breakpoint at the beginning of my_function, so when execution of the program enters the function the program will be suspended and you get GDB prompt back, and be able to inspect program's state. Or you can step through the code.

            (gdb) watch my_var (gdb) cont                      

Same, but now the program will be stopped at whatever location that modifies the value of my_var.

Shameless plug - here's a link to my GDB presentation at NYC BSD User Group. Hope this helps.

Related videos on Youtube

Comments

  • I'm pretty much using GDB for the first time. I run

                        $ gdb                                      

    then I'm running

                        attach <mypid>                                      

    then I see that my process is stuck (which is probably ok). Now I want it to continue running, so I run

                        continue                                      

    and my process continues running but from here I'm stuck if I want again to watch my current stack trace etc. I couldn't get out of continuing... I tried Ctrl-D etc. but nothing worked for me... (was just a guess).

    • i tried also CTRL-C it didn't

  • ctrl-c does not work for me have a look please: ' bash-3.00# gdb GNU gdb 6.8 Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i386-pc-solaris2.10". (gdb) attach 4305 Attaching to process 4305 Retry #1: Retry #2: '

  • <pre> Retry #3: Retry #4: [New LWP 1] 0xfef298b5 in ?? () (gdb) info frame Stack level 0, frame at 0x80477c8: eip = 0xfef298b5; saved eip 0xfef1b5d2 Arglist at 0x80477c0, args: Locals at 0x80477c0, Previous frame's sp is 0x80477c8 Saved registers: eip at 0x80477c4 (gdb) print The history is empty. (gdb) continue Continuing. ^D ^C quit ^C^C^C ^C </pre>

  • how can i format this plz? i had this in separate lines how do i have it also in comments what i pasted in separate lines please?

  • You can't format (much) in comments. Edit it into your question.

  • but i just wanted to pick a point in time of my own and at that point to examine the stack trace... and afterwards to continue the program, i didn't want breakpoints... in my case I want to examine the stack trace of the program at a time of my own.

  • OK, what does info signal says about SIGINT?

  • Shame there isn't a way to do this from the host when using gdbserver/client.

  • Not wanting to state the obvious, but it'll only work if the program doesn't handle SIGINT. If there's a sigaddset frenzy in main() or some init()... ;)

  • @Jas what possible use is it to randomly interrupt a running program to examine the stack trace? All you're going to find is that the code that is currently on the stack is the code that is running. Usually this is a loop waiting for user input. Ho hum.

  • This is hardly the best answer. You should not assume that the problem doesn't handle interruptions. The best answer should state how to gain interactivity with gdb (within gdb): "Control+C in the gdb process should bring you back to the command prompt."

Recents

Related

allisonrither.blogspot.com

Source: https://9to5answer.com/how-do-i-halt-the-continuing-in-gdb

0 Response to "How to Stop Continue in Gdb"

Enviar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel