{
    "content": [
        {
            "type": "text",
            "text": "# GDB (man)\n\n## NAME\n\ngdb - The GNU Debugger\n\n## SYNOPSIS\n\ngdb [OPTIONS] [prog|prog procID|prog core]\n\n## DESCRIPTION\n\nThe purpose of a debugger such as GDB is to allow you to see what is going on \"inside\"\nanother program while it executes -- or what another program was doing at the moment it\ncrashed.\n\n## TLDR\n\n> The GNU Debugger.\n\n- Debug an executable:\n  `gdb {{path/to/executable}}`\n- Attach a process to `gdb`:\n  `gdb {{-p|--pid}} {{process_id}}`\n- Debug with a core file:\n  `gdb {{-c|--core}} {{path/to/core}} {{path/to/executable}}`\n- Execute given GDB commands upon start:\n  `gdb {{-ex|--eval-command}} \"{{commands}}\" {{path/to/executable}}`\n- Start `gdb` and pass arguments to the executable:\n  `gdb --args {{path/to/executable}} {{argument1 argument2 ...}}`\n- Skip `debuginfod` and pagination prompts and then print the backtrace:\n  `gdb {{-c|--core}} {{path/to/core}} {{path/to/executable}} -iex 'set debuginfod enabled on' -iex 'set pagination off' -ex bt`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (4 subsections)\n- **OPTIONS** (30 subsections)\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "GDB",
        "section": "",
        "mode": "man",
        "summary": "gdb - The GNU Debugger",
        "synopsis": "gdb [OPTIONS] [prog|prog procID|prog core]",
        "tldr_summary": "The GNU Debugger.",
        "tldr_examples": [
            {
                "description": "Debug an executable",
                "command": "gdb {{path/to/executable}}"
            },
            {
                "description": "Attach a process to `gdb`",
                "command": "gdb {{-p|--pid}} {{process_id}}"
            },
            {
                "description": "Debug with a core file",
                "command": "gdb {{-c|--core}} {{path/to/core}} {{path/to/executable}}"
            },
            {
                "description": "Execute given GDB commands upon start",
                "command": "gdb {{-ex|--eval-command}} \"{{commands}}\" {{path/to/executable}}"
            },
            {
                "description": "Start `gdb` and pass arguments to the executable",
                "command": "gdb --args {{path/to/executable}} {{argument1 argument2 ...}}"
            },
            {
                "description": "Skip `debuginfod` and pagination prompts and then print the backtrace",
                "command": "gdb {{-c|--core}} {{path/to/core}} {{path/to/executable}} -iex 'set debuginfod enabled on' -iex 'set pagination off' -ex bt"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": "--help",
                "arg": null,
                "description": ""
            },
            {
                "flag": "-h",
                "long": null,
                "arg": null,
                "description": "--symbols=file"
            },
            {
                "flag": "-s",
                "long": null,
                "arg": null,
                "description": "Read symbol table from file."
            },
            {
                "flag": "",
                "long": "--write",
                "arg": null,
                "description": "Enable writing into executable and core files. --exec=file"
            },
            {
                "flag": "-e",
                "long": null,
                "arg": null,
                "description": "Use file as the executable file to execute when appropriate, and for examining pure data in conjunction with a core dump. --se=file Read symbol table from file and use it as the executable file. --core=file"
            },
            {
                "flag": "-c",
                "long": null,
                "arg": null,
                "description": "Use file as a core dump to examine. --command=file"
            },
            {
                "flag": "-x",
                "long": null,
                "arg": null,
                "description": "Execute GDB commands from file. --eval-command=command"
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Execute given GDB command. --init-eval-command=command"
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Execute GDB command before loading the inferior. --directory=directory"
            },
            {
                "flag": "-d",
                "long": null,
                "arg": null,
                "description": "Add directory to the path to search for source files."
            },
            {
                "flag": "",
                "long": "--nh",
                "arg": null,
                "description": "Do not execute commands from ~/.config/gdb/gdbinit, ~/.gdbinit, ~/.config/gdb/gdbearlyinit, or ~/.gdbearlyinit"
            },
            {
                "flag": "",
                "long": "--nx",
                "arg": null,
                "description": ""
            },
            {
                "flag": "-n",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "",
                "long": "--quiet",
                "arg": null,
                "description": ""
            },
            {
                "flag": "",
                "long": "--silent",
                "arg": null,
                "description": ""
            },
            {
                "flag": "-q",
                "long": null,
                "arg": null,
                "description": "suppressed in batch mode."
            },
            {
                "flag": "",
                "long": "--batch",
                "arg": null,
                "description": "Run in batch mode. Exit with status 0 after processing all the command files specified with -x (and .gdbinit, if not inhibited). Exit with nonzero status if an error occurs in executing the GDB commands in the command files. Batch mode may be useful for running GDB as a filter, for example to download and run a program on another computer; in order to make this more useful, the message Program exited normally. (which is ordinarily issued whenever a program running under GDB control terminates) is not issued when running in batch mode."
            },
            {
                "flag": "",
                "long": "--batch-silent",
                "arg": null,
                "description": "Run in batch mode, just like --batch, but totally silent. All GDB output is supressed (stderr is unaffected). This is much quieter than --silent and would be useless for an interactive session. This is particularly useful when using targets that give Loading section messages, for example. Note that targets that give their output via GDB, as opposed to writing directly to \"stdout\", will also be made silent. --args prog [arglist] Change interpretation of command line so that arguments following this option are passed as arguments to the inferior. As an example, take the following command: gdb ./a.out -q It would start GDB with -q, not printing the introductory message. On the other hand, using: gdb --args ./a.out -q starts GDB with the introductory message, and passes the option to the inferior. --pid=pid Attach GDB to an already running program, with the PID pid."
            },
            {
                "flag": "",
                "long": "--tui",
                "arg": null,
                "description": "Open the terminal user interface."
            },
            {
                "flag": "",
                "long": "--readnow",
                "arg": null,
                "description": "Read all symbols from the given symfile on the first access."
            },
            {
                "flag": "",
                "long": "--readnever",
                "arg": null,
                "description": "Do not read symbol files."
            },
            {
                "flag": "",
                "long": "--dbx",
                "arg": null,
                "description": "Run in DBX compatibility mode."
            },
            {
                "flag": "",
                "long": "--return-child-result",
                "arg": null,
                "description": "GDB's exit code will be the same as the child's exit code."
            },
            {
                "flag": "",
                "long": "--configuration",
                "arg": null,
                "description": "Print details about GDB configuration and then exit."
            },
            {
                "flag": "",
                "long": "--version",
                "arg": null,
                "description": "Print version information and then exit. --cd=directory Run GDB using directory as its working directory, instead of the current directory. --data-directory=directory"
            },
            {
                "flag": "-D",
                "long": null,
                "arg": null,
                "description": "for its auxiliary files."
            },
            {
                "flag": "",
                "long": "--fullname",
                "arg": null,
                "description": ""
            },
            {
                "flag": "-f",
                "long": null,
                "arg": null,
                "description": "file name and line number in a standard, recognizable fashion each time a stack frame is displayed (which includes each time the program stops). This recognizable format looks like two \\032 characters, followed by the file name, line number and character position separated by colons, and a newline. The Emacs-to-GDB interface program uses the two \\032 characters as a signal to display the source code for the frame."
            },
            {
                "flag": "-b",
                "long": null,
                "arg": null,
                "description": "Set the line speed (baud rate or bits per second) of any serial interface used by GDB for remote debugging."
            },
            {
                "flag": "-l",
                "long": null,
                "arg": null,
                "description": "Set timeout, in seconds, for remote debugging. --tty=device Run using device for your program's standard input and output."
            }
        ],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 54,
                "subsections": [
                    {
                        "name": "next",
                        "lines": 8
                    },
                    {
                        "name": "step",
                        "lines": 5
                    },
                    {
                        "name": "quit",
                        "lines": 1
                    },
                    {
                        "name": "exit",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 23,
                "subsections": [
                    {
                        "name": "--help",
                        "lines": 1,
                        "long": "--help"
                    },
                    {
                        "name": "-h",
                        "lines": 1,
                        "flag": "-h"
                    },
                    {
                        "name": "-s",
                        "lines": 2,
                        "flag": "-s"
                    },
                    {
                        "name": "--write",
                        "lines": 3,
                        "long": "--write"
                    },
                    {
                        "name": "-e",
                        "lines": 7,
                        "flag": "-e"
                    },
                    {
                        "name": "-c",
                        "lines": 3,
                        "flag": "-c"
                    },
                    {
                        "name": "-x",
                        "lines": 3,
                        "flag": "-x"
                    },
                    {
                        "name": "-ex",
                        "lines": 3
                    },
                    {
                        "name": "-iex",
                        "lines": 3
                    },
                    {
                        "name": "-d",
                        "lines": 2,
                        "flag": "-d"
                    },
                    {
                        "name": "--nh",
                        "lines": 3,
                        "long": "--nh"
                    },
                    {
                        "name": "--nx",
                        "lines": 1,
                        "long": "--nx"
                    },
                    {
                        "name": "-n",
                        "lines": 1,
                        "flag": "-n"
                    },
                    {
                        "name": "--quiet",
                        "lines": 1,
                        "long": "--quiet"
                    },
                    {
                        "name": "--silent",
                        "lines": 1,
                        "long": "--silent"
                    },
                    {
                        "name": "-q",
                        "lines": 2,
                        "flag": "-q"
                    },
                    {
                        "name": "--batch",
                        "lines": 12,
                        "long": "--batch"
                    },
                    {
                        "name": "--batch-silent",
                        "lines": 26,
                        "long": "--batch-silent"
                    },
                    {
                        "name": "--tui",
                        "lines": 2,
                        "long": "--tui"
                    },
                    {
                        "name": "--readnow",
                        "lines": 2,
                        "long": "--readnow"
                    },
                    {
                        "name": "--readnever",
                        "lines": 2,
                        "long": "--readnever"
                    },
                    {
                        "name": "--dbx",
                        "lines": 2,
                        "long": "--dbx"
                    },
                    {
                        "name": "--return-child-result",
                        "lines": 2,
                        "long": "--return-child-result"
                    },
                    {
                        "name": "--configuration",
                        "lines": 2,
                        "long": "--configuration"
                    },
                    {
                        "name": "--version",
                        "lines": 6,
                        "long": "--version"
                    },
                    {
                        "name": "-D",
                        "lines": 2,
                        "flag": "-D"
                    },
                    {
                        "name": "--fullname",
                        "lines": 1,
                        "long": "--fullname"
                    },
                    {
                        "name": "-f",
                        "lines": 6,
                        "flag": "-f"
                    },
                    {
                        "name": "-b",
                        "lines": 3,
                        "flag": "-b"
                    },
                    {
                        "name": "-l",
                        "lines": 5,
                        "flag": "-l"
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 14,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "gdb - The GNU Debugger\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "gdb [OPTIONS] [prog|prog procID|prog core]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The purpose of a debugger such as GDB is to allow you to see what is going on \"inside\"\nanother program while it executes -- or what another program was doing at the moment it\ncrashed.\n\nGDB can do four main kinds of things (plus other things in support of these) to help you\ncatch bugs in the act:\n\n•   Start your program, specifying anything that might affect its behavior.\n\n•   Make your program stop on specified conditions.\n\n•   Examine what has happened, when your program has stopped.\n\n•   Change things in your program, so you can experiment with correcting the effects of one\nbug and go on to learn about another.\n\nYou can use GDB to debug programs written in C, C++, Fortran and Modula-2.\n\nGDB is invoked with the shell command \"gdb\".  Once started, it reads commands from the\nterminal until you tell it to exit with the GDB command \"quit\" or \"exit\".  You can get online\nhelp from GDB itself by using the command \"help\".\n\nYou can run \"gdb\" with no arguments or options; but the most usual way to start GDB is with\none argument or two, specifying an executable program as the argument:\n\ngdb program\n\nYou can also start with both an executable program and a core file specified:\n\ngdb program core\n\nYou can, instead, specify a process ID as a second argument or use option \"-p\", if you want\nto debug a running process:\n\ngdb program 1234\ngdb -p 1234\n\nwould attach GDB to process 1234.  With option -p you can omit the program filename.\n\nHere are some of the most frequently needed GDB commands:\n\nbreak [file:][function|line]\nSet a breakpoint at function or line (in file).\n\nrun [arglist]\nStart your program (with arglist, if specified).\n\nbt  Backtrace: display the program stack.\n\nprint expr\nDisplay the value of an expression.\n\nc   Continue running your program (after stopping, e.g. at a breakpoint).\n",
                "subsections": [
                    {
                        "name": "next",
                        "content": "Execute next program line (after stopping); step over any function calls in the line.\n\nedit [file:]function\nlook at the program line where it is presently stopped.\n\nlist [file:]function\ntype the text of the program in the vicinity of where it is presently stopped.\n"
                    },
                    {
                        "name": "step",
                        "content": "Execute next program line (after stopping); step into any function calls in the line.\n\nhelp [name]\nShow information about GDB command name, or general information about using GDB.\n"
                    },
                    {
                        "name": "quit",
                        "content": ""
                    },
                    {
                        "name": "exit",
                        "content": "Exit from GDB.\n\nFor full details on GDB, see Using GDB: A Guide to the GNU Source-Level Debugger, by Richard\nM. Stallman and Roland H. Pesch.  The same text is available online as the \"gdb\" entry in the\n\"info\" program.\n"
                    }
                ]
            },
            "OPTIONS": {
                "content": "Any arguments other than options specify an executable file and core file (or process ID);\nthat is, the first argument encountered with no associated option flag is equivalent to a\n--se option, and the second, if any, is equivalent to a -c option if it's the name of a file.\nMany options have both long and abbreviated forms; both are shown here.  The long forms are\nalso recognized if you truncate them, so long as enough of the option is present to be\nunambiguous.\n\nThe abbreviated forms are shown here with - and long forms are shown with -- to reflect how\nthey are shown in --help. However, GDB recognizes all of the following conventions for most\noptions:\n\n\"--option=value\"\n\"--option value\"\n\"-option=value\"\n\"-option value\"\n\"--o=value\"\n\"--o value\"\n\"-o=value\"\n\"-o value\"\n\nAll the options and command line arguments you give are processed in sequential order.  The\norder makes a difference when the -x option is used.\n",
                "subsections": [
                    {
                        "name": "--help",
                        "content": "",
                        "long": "--help"
                    },
                    {
                        "name": "-h",
                        "content": "--symbols=file",
                        "flag": "-h"
                    },
                    {
                        "name": "-s",
                        "content": "Read symbol table from file.\n",
                        "flag": "-s"
                    },
                    {
                        "name": "--write",
                        "content": "Enable writing into executable and core files.\n\n--exec=file",
                        "long": "--write"
                    },
                    {
                        "name": "-e",
                        "content": "Use file as the executable file to execute when appropriate, and for examining pure data\nin conjunction with a core dump.\n\n--se=file\nRead symbol table from file and use it as the executable file.\n\n--core=file",
                        "flag": "-e"
                    },
                    {
                        "name": "-c",
                        "content": "Use file as a core dump to examine.\n\n--command=file",
                        "flag": "-c"
                    },
                    {
                        "name": "-x",
                        "content": "Execute GDB commands from file.\n\n--eval-command=command",
                        "flag": "-x"
                    },
                    {
                        "name": "-ex",
                        "content": "Execute given GDB command.\n\n--init-eval-command=command"
                    },
                    {
                        "name": "-iex",
                        "content": "Execute GDB command before loading the inferior.\n\n--directory=directory"
                    },
                    {
                        "name": "-d",
                        "content": "Add directory to the path to search for source files.\n",
                        "flag": "-d"
                    },
                    {
                        "name": "--nh",
                        "content": "Do not execute commands from ~/.config/gdb/gdbinit, ~/.gdbinit,\n~/.config/gdb/gdbearlyinit, or ~/.gdbearlyinit\n",
                        "long": "--nh"
                    },
                    {
                        "name": "--nx",
                        "content": "",
                        "long": "--nx"
                    },
                    {
                        "name": "-n",
                        "content": "",
                        "flag": "-n"
                    },
                    {
                        "name": "--quiet",
                        "content": "",
                        "long": "--quiet"
                    },
                    {
                        "name": "--silent",
                        "content": "",
                        "long": "--silent"
                    },
                    {
                        "name": "-q",
                        "content": "suppressed in batch mode.\n",
                        "flag": "-q"
                    },
                    {
                        "name": "--batch",
                        "content": "Run in batch mode.  Exit with status 0 after processing all the command files specified\nwith -x (and .gdbinit, if not inhibited).  Exit with nonzero status if an error occurs in\nexecuting the GDB commands in the command files.\n\nBatch mode may be useful for running GDB as a filter, for example to download and run a\nprogram on another computer; in order to make this more useful, the message\n\nProgram exited normally.\n\n(which is ordinarily issued whenever a program running under GDB control terminates) is\nnot issued when running in batch mode.\n",
                        "long": "--batch"
                    },
                    {
                        "name": "--batch-silent",
                        "content": "Run in batch mode, just like --batch, but totally silent.  All GDB output is supressed\n(stderr is unaffected).  This is much quieter than --silent and would be useless for an\ninteractive session.\n\nThis is particularly useful when using targets that give Loading section messages, for\nexample.\n\nNote that targets that give their output via GDB, as opposed to writing directly to\n\"stdout\", will also be made silent.\n\n--args prog [arglist]\nChange interpretation of command line so that arguments following this option are passed\nas arguments to the inferior.  As an example, take the following command:\n\ngdb ./a.out -q\n\nIt would start GDB with -q, not printing the introductory message.  On the other hand,\nusing:\n\ngdb --args ./a.out -q\n\nstarts GDB with the introductory message, and passes the option to the inferior.\n\n--pid=pid\nAttach GDB to an already running program, with the PID pid.\n",
                        "long": "--batch-silent"
                    },
                    {
                        "name": "--tui",
                        "content": "Open the terminal user interface.\n",
                        "long": "--tui"
                    },
                    {
                        "name": "--readnow",
                        "content": "Read all symbols from the given symfile on the first access.\n",
                        "long": "--readnow"
                    },
                    {
                        "name": "--readnever",
                        "content": "Do not read symbol files.\n",
                        "long": "--readnever"
                    },
                    {
                        "name": "--dbx",
                        "content": "Run in DBX compatibility mode.\n",
                        "long": "--dbx"
                    },
                    {
                        "name": "--return-child-result",
                        "content": "GDB's exit code will be the same as the child's exit code.\n",
                        "long": "--return-child-result"
                    },
                    {
                        "name": "--configuration",
                        "content": "Print details about GDB configuration and then exit.\n",
                        "long": "--configuration"
                    },
                    {
                        "name": "--version",
                        "content": "Print version information and then exit.\n\n--cd=directory\nRun GDB using directory as its working directory, instead of the current directory.\n\n--data-directory=directory",
                        "long": "--version"
                    },
                    {
                        "name": "-D",
                        "content": "for its auxiliary files.\n",
                        "flag": "-D"
                    },
                    {
                        "name": "--fullname",
                        "content": "",
                        "long": "--fullname"
                    },
                    {
                        "name": "-f",
                        "content": "file name and line number in a standard, recognizable fashion each time a stack frame is\ndisplayed (which includes each time the program stops).  This recognizable format looks\nlike two \\032 characters, followed by the file name, line number and character position\nseparated by colons, and a newline.  The Emacs-to-GDB interface program uses the two \\032\ncharacters as a signal to display the source code for the frame.\n",
                        "flag": "-f"
                    },
                    {
                        "name": "-b",
                        "content": "Set the line speed (baud rate or bits per second) of any serial interface used by GDB for\nremote debugging.\n",
                        "flag": "-b"
                    },
                    {
                        "name": "-l",
                        "content": "Set timeout, in seconds, for remote debugging.\n\n--tty=device\nRun using device for your program's standard input and output.\n",
                        "flag": "-l"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "The full documentation for GDB is maintained as a Texinfo manual.  If the \"info\" and \"gdb\"\nprograms and GDB's Texinfo documentation are properly installed at your site, the command\n\ninfo gdb\n\nshould give you access to the complete manual.\n\nUsing GDB: A Guide to the GNU Source-Level Debugger, Richard M. Stallman and Roland H. Pesch,\nJuly 1991.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 1988-2022 Free Software Foundation, Inc.\n\nPermission is granted to copy, distribute and/or modify this document under the terms of the\nGNU Free Documentation License, Version 1.3 or any later version published by the Free\nSoftware Foundation; with the Invariant Sections being \"Free Software\" and \"Free Software\nNeeds Free Documentation\", with the Front-Cover Texts being \"A GNU Manual,\" and with the\nBack-Cover Texts as in (a) below.\n\n(a) The FSF's Back-Cover Text is: \"You are free to copy and modify this GNU Manual.  Buying\ncopies from GNU Press supports the FSF in developing GNU and promoting software freedom.\"\n\n\n\ngdb-                                         2024-06-13                                       GDB(1)",
                "subsections": []
            }
        }
    }
}