CLion Tutorial – Debugger Console & Attach to Process

The debugger console allows you to directly access the GDB/LLDB console from CLion during a debugging session. The debugger console is only available when the program is paused. Open the tab marked LLDB or GDB in the debugging tool window:

This tab shows the debugger's output/error stream and allows you to run GDB/LLDB commands.

👇 Click to claim 👇
👉 C Language Knowledge Resource Collection

Useful Shortcuts

Ctrl+Shift+F10 quickly switches to the debugger console (available only during debugging sessions). If the debugging tool window is hidden, this action will open it and focus on the debugger console tab. Ctrl+Space or Tab calls command completion provided by GDB or LLDB.

Attach to Process
CLion provides a way to attach the debugger to local and remote processes. For C/C++ applications, you can use GDB or MSVC LLDB (on Windows), LLDB (on macOS), and GDB and LLDB on Linux to attach to processes. If applicable, you can also use debuggers for other languages (such as the Python debugger). The best way to debug a program that can be started from CLion is to start a local debugging session.

Prerequisites for Ubuntu
On Ubuntu and some other Linux distributions, you may receive a ptrace: Operation not permitted error message the first time you try to attach to a process. Please do one of the following:
To temporarily disable this restriction, enter the following command:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

To permanently disable this restriction, open the /etc/sysctl.d/10-ptrace.conf file for editing and change the line kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0.

To apply the changes immediately, enter the command above echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope. Alternatively, run sudo service procps restart or restart the system.

Attach to Process
Press Ctrl+Alt+F5 or select Run | Attach to Process from the main menu.

In "Attach to Process," a list of running processes is displayed. For each process, you can find the executable name, process ID, the user who started it, available debuggers, and the command used to start it.

You can display processes as a list or tree and search for specific processes by name:

Use the dropdown menu to filter the process list by debugger type:

You can also filter the list by setting "Show only my processes":

You can attach to remote processes started with administrator privileges.

Switch to the SSH tab to view the list of remote processes. Be sure to configure the remote toolchain with SSH credentials in advance.

On Windows, switch to the WSL tab to open the WSL process list. You will be able to attach to them using the WSL GDB debugger (if you have configured at least one WSL toolchain in your project).

Then, continue debugging as usual in CLion (set breakpoints, step through, pause and continue processes, evaluate expressions, etc.).

<blockquote><p>If the attached process does not provide debugging information, breakpoints will not be usable, and stepping through will execute in the disassembly view.</p></blockquote>

<strong>Detach from Process</strong>
The process of detaching from a remote process is the same as stopping a debugging session. But please note that when you detach, the debugging session closes, but the process continues to run.

Click the stop button on the main toolbar <img alt="CLion Tutorial - Debugger Console & Attach to Process" src="https://boardor.com/wp-content/uploads/2025/02/9adab511-ee28-477e-a881-6e489ea1a892.svg"/> or click stop in the debugging tool window <img alt="CLion Tutorial - Debugger Console & Attach to Process" src="https://boardor.com/wp-content/uploads/2025/02/97db9ed4-d1fc-4d26-ab9f-1df946e734c2.svg"/>.

Or, click the stop button on the main toolbar <img alt="CLion Tutorial - Debugger Console & Attach to Process" src="https://boardor.com/wp-content/uploads/2025/02/314d9255-06c8-4328-8ce5-f1769bf87c42.svg"/> and select the session to close.<pre><code class="language-plaintext">
Hot Recommendations
  • Programmers Crazy Job Hopping Salary Increase, Annual Salary from 50,000 to 580,000~

  • Feishu, Layoffs of 1,000 People…

  • Is it Only the Frontend Crash? Backend and Testing are Okay? Netizens: All the Same~

Leave a Comment