# Debugging with gdbserver

gdbserver is a GDB stub implemented as a separate program. It runs a program to be debugged or attaches to a process and then waits for commands. The remote GDB debugger module has been tested with gdbserver available with Cygwin and Linux.

To debug a specific program from the start, run the following command:

```
    gdbserver localhost:23946 <program>
```

and then choose Debugger → Attach → \<process running on target> in IDA.

To debug a running process:

```
    gdbserver --multi localhost:23947
```

then choose Debugger → Attach → \<enter PID to attach> in IDA and enter the PID of the process to attach to.

Another method of debugging a running process is:

```
    gdbserver localhost:23947 --attach <PID>
```

then choose Debugger → Attach → \<process running on target> in IDA.

To start a program from inside IDA, first launch the debugger server:

```
    gdbserver --multi localhost:23947
```

Then use Debugger → Start process or Debugger → Run in IDA.

{% hint style="info" %}
The `--multi` option is only available in GDB 6.8 or higher.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/core/debugger/concepts/remote-debugging/remote-gdb-debugger/debugging-with-gdbserver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
