GDBSERVER(1)

๐Ÿ“ฆ
version 7.2.4 ยท 2 versions
, in arch rolling

๐ŸŽ€ gdbserver(1) โ€” GNU Development Tools ๐ŸŽ€

okay bestie, this is the manual page for gdbserver, and it's literally the remote server for the GNU Debugger. It's giving โ€œdebug from another machineโ€ main character energy, so let's get into it. ๐Ÿ’…


โœจ NAME โœจ

gdbserver โ€” Remote Server for the GNU Debugger ๐Ÿซถ


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

gdbserver comm prog [args...]

gdbserver --attach comm pid

gdbserver --multi comm

๐Ÿ’– DESCRIPTION ๐Ÿ’–

gdbserver is a program that lets you run ROCGDB on a different machine than the one running the program you're debugging. Yes, bestie โ€” remote debugging. Iconic. โœจ

๐Ÿ–ฅ๏ธ Usage (server (target) side) ๐Ÿ–ฅ๏ธ

First, you need to have a copy of the program you want to debug put onto the target system. The program can be stripped to save space if needed, because gdbserver doesn't care about symbols. All symbol handling is taken care of by the ROCGDB running on the host system. ๐ŸŽ€

To use the server, you log on to the target system and run the gdbserver program. You must tell it:

  • how to communicate with ROCGDB
  • the name of your program
  • its arguments

The general syntax is:

target> gdbserver <comm> <program> [<args> ...]

For example, using a serial port, you might say:

target> gdbserver /dev/com1 emacs foo.txt

This tells gdbserver to debug emacs with an argument of foo.txt, and to communicate with ROCGDB via /dev/com1. Then gdbserver waits patiently for the host ROCGDB to communicate with it. Patient queen behavior. ๐Ÿ‘‘

To use a TCP connection, you could say:

target> gdbserver host:2345 emacs foo.txt

This says pretty much the same thing as the last example, except that we're going to communicate with the "host" ROCGDB via TCP. The "host:2345" argument means we're expecting to see a TCP connection from "host" to local TCP port 2345. (Currently, the "host" part is ignored.) You can choose any number you want for the port number as long as it doesn't conflict with any existing TCP ports on the target system. This same port number must be used in the host ROCGDB's "target remote" command, which will be described shortly. Note that if you chose a port number that conflicts with another service, gdbserver will print an error message and exit. ๐Ÿซ 

gdbserver can also attach to running programs. This is accomplished via the --attach argument. The syntax is:

target> gdbserver --attach <comm> <pid>

pid is the process ID of a currently running process. It isn't necessary to point gdbserver at a binary for the running process. Lowkey convenient. ๐Ÿฆ‹

To start "gdbserver" without supplying an initial command to run or process ID to attach, use the --multi command line option. In such case you should connect using "target extended-remote" to start the program you want to debug.

target> gdbserver --multi <comm>

๐Ÿ’ป Usage (host side) ๐Ÿ’ป

You need an unstripped copy of the target program on your host system, since ROCGDB needs to examine its symbol tables and such. Start up ROCGDB as you normally would, with the target program as the first argument. (You may need to use the --baud option if the serial line is running at anything except 9600 baud.) That is gdb TARGET-PROG, or gdb --baud BAUD TARGET-PROG. After that, the only new command you need to know about is "target remote" (or "target extended-remote"). Its argument is either a device name (usually a serial device, like /dev/ttyb), or a "HOST:PORT" descriptor. For example:

(gdb) target remote /dev/ttyb

communicates with the server via serial line /dev/ttyb, and:

(gdb) target remote the-target:2345

communicates via a TCP connection to port 2345 on host `the-target', where you previously started up gdbserver with the same port number. Note that for TCP connections, you must start up gdbserver prior to using the `target remote' command, otherwise you may get an error that looks something like `Connection refused'. ๐Ÿ˜ญ

gdbserver can also debug multiple inferiors at once, described in the ROCGDB manual in node "Inferiors Connections and Programs" โ€” shell command "info -f gdb -n 'Inferiors Connections and Programs'". In such case use the "extended-remote" ROCGDB command variant:

(gdb) target extended-remote the-target:2345

The gdbserver option --multi may or may not be used in such case. No cap. ๐Ÿ’€


๐ŸŽ›๏ธ OPTIONS ๐ŸŽ›๏ธ

There are three different modes for invoking gdbserver:

  • Debug a specific program specified by its program name:
gdbserver <comm> <prog> [<args>...]

The comm parameter specifies how the server should communicate with ROCGDB; it is either a device name (to use a serial line), a TCP port number (":1234"), or "-" or "stdio" to use stdin/stdout of "gdbserver". Specify the name of the program to debug in prog. Any remaining arguments will be passed to the program verbatim. When the program exits, ROCGDB will close the connection, and "gdbserver" will exit. ๐ŸŽ€

  • Debug a specific program by specifying the process ID of a running program:
gdbserver --attach <comm> <pid>

The comm parameter is as described above. Supply the process ID of a running program in pid; ROCGDB will do everything else. Like with the previous mode, when the process pid exits, ROCGDB will close the connection, and "gdbserver" will exit. โœจ

  • Multi-process mode โ€” debug more than one program/process:
gdbserver --multi <comm>

In this mode, ROCGDB can instruct gdbserver which command(s) to run. Unlike the other 2 modes, ROCGDB will not close the connection when a process being debugged exits, so you can debug several processes in the same session. Main character multi-tasking energy. ๐Ÿ‘‘

In each of the modes you may specify these options:

  • --help โ€” List all options, with brief explanations. ๐Ÿซถ
  • --version โ€” This option causes gdbserver to print its version number and exit. ๐Ÿ’…
  • --attach โ€” gdbserver will attach to a running program. The syntax is:
target> gdbserver --attach <comm> <pid>

pid is the process ID of a currently running process. It isn't necessary to point gdbserver at a binary for the running process. ๐Ÿฆ‹

  • --multi โ€” To start "gdbserver" without supplying an initial command to run or process ID to attach, use this command line option. Then you can connect using "target extended-remote" and start the program you want to debug. The syntax is:
target> gdbserver --multi <comm>
  • --debug[=option1,option2,...] โ€” Instruct "gdbserver" to display extra status information about the debugging process. This option is intended for "gdbserver" development and for bug reports to the developers. ๐Ÿงš

Each option is the name of a component for which debugging should be enabled. The list of possible options is all, threads, event-loop, remote. The special option all enables all components. The option list is processed left to right, and an option can be prefixed with the - character to disable output for that component, so you could write:

target> gdbserver --debug=all,-event-loop

to turn on debug output for all components except event-loop. If no options are passed to --debug then this is treated as equivalent to --debug=threads. This could change in future releases of "gdbserver". ๐Ÿ‘€

  • --debug-file=filename โ€” Instruct "gdbserver" to send any debug output to the given filename. This option is intended for "gdbserver" development and for bug reports to the developers. ๐Ÿ“
  • --debug-format=option1[,option2,...] โ€” Instruct "gdbserver" to include extra information in each line of debugging output. ๐ŸŒธ
  • --wrapper โ€” Specify a wrapper to launch programs for debugging. The option should be followed by the name of the wrapper, then any command-line arguments to pass to the wrapper, then -- indicating the end of the wrapper arguments. ๐ŸŽ€
  • --once โ€” By default, gdbserver keeps the listening TCP port open, so that additional connections are possible. However, if you start "gdbserver" with the --once option, it will stop listening for any further connection attempts after connecting to the first ROCGDB session. One and done, periodt. ๐Ÿ’…

๐ŸŒฑ ENVIRONMENT ๐ŸŒฑ

This section is empty in the original page, bestie โ€” no environment variables are listed here. The vibe check is literally a clean slate. ๐Ÿซถ


๐Ÿ”Ž SEE ALSO ๐Ÿ”Ž

The full documentation for ROCGDB is maintained as a Texinfo manual. If the "info" and "gdb" programs and ROCGDB's Texinfo documentation are properly installed at your site, the command

info gdb

should give you access to the complete manual. โœจ

Using GDB: A Guide to the GNU Source-Level Debugger, Richard M. Stallman and Roland H. Pesch, July 1991. ๐Ÿ“š

okay so first things first, the legal stuff, and honestly it's giving very important, so pay attention bestie โœจ

Copyright ยฉ 1988-2024 Free Software Foundation, Inc.

You are so allowed to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation โ€” with the Invariant Sections being "Free Software" and "Free Software Needs Free Documentation", with the Front-Cover Texts being "A GNU Manual," and with the Back-Cover Texts as in (a) down below. iykyk ๐Ÿ’…

(a) โ€” the FSF's Back-Cover Text goes, and I quote, exactly like this:

"You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom."

like, literally buying a copy supports free software. that's the whole vibe ๐Ÿซถ


so this next bit is the AMD part, no cap. AMD ROCm software is made available by Advanced Micro Devices, Inc. under the open source license identified in the top-level directory for the library in the repository on Github.com โ€” the fancy way of writing that is:

@url{https://github.com/ROCm/,Github.com}

(portions of AMD ROCm software are licensed under MITx11 and UIL/NCSA, fr fr โ€” for more info on the license, review the license.txt in the top-level directory for the library on that same Github.com link). and bestie, the additional terms and conditions below apply to your use of AMD ROCm technical documentation ๐Ÿ‘‘

ยฉ2019-2024 Advanced Micro Devices, Inc. All rights reserved.

okay so the info in this document is for informational purposes only and may contain technical inaccuracies, omissions, and typographical errors ๐Ÿ˜ญ it is subject to change and may be rendered inaccurate for many reasons, including but not limited to:

  • product and roadmap changes
  • component and motherboard version changes
  • new model and/or product releases
  • product differences between differing manufacturers
  • software changes
  • BIOS flashes
  • firmware upgrades
  • or the like

and any computer system has risks of security vulnerabilities that cannot be completely prevented or mitigated โ€” yeah, that's just how it is ๐Ÿ’€ AMD assumes no obligation to update or otherwise correct or revise this information. however, AMD reserves the right to revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes. so like, keep an eye out ๐Ÿ‘€

THIS INFORMATION IS PROVIDED "AS IS." AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS, OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION. AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO ANY PERSON FOR ANY RELIANCE, DIRECT, INDIRECT, SPECIAL, OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

like that's the whole disclaimer, in all its dramatic glory, and yes it's loud on purpose ๐Ÿ—ฃ๏ธ๐Ÿ”ฅ

lastly, the trademarks, because we respect IP in this house:

  • AMD, the AMD Arrow logo, AMD Instinctโ„ข, Radeonโ„ข, AMD ROCmโ„ข, and combinations thereof are trademarks of Advanced Micro Devices, Inc.
  • Linuxยฎ is the registered trademark of Linus Torvalds in the U.S. and other countries.
  • PCIeยฎ is a registered trademark of PCI-SIG Corporation.
  • Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.

and that's the page, bestie ๐ŸŽ€ this was gdb-16.3, all dated 2026-05-31 โ€” iconic, timeless, periodt ๐Ÿ’…โœจ go debug something slay-worthy ๐ŸŒธ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from