From 900e124d58927ef3bdaecc75074ecfa75d1b9e97 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Mon, 6 Jul 2020 15:31:50 -0700 Subject: [PATCH 1/2] [cpp] Include extra info for Linux to Attach This PR adds the additional info to attach to a process in Linux with GDB. This information comes from https://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process --- docs/cpp/cpp-debug.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/cpp/cpp-debug.md b/docs/cpp/cpp-debug.md index fd82d50b15..82611d9c58 100644 --- a/docs/cpp/cpp-debug.md +++ b/docs/cpp/cpp-debug.md @@ -138,7 +138,13 @@ Windows: Linux: -* GDB needs elevated permissions to attach to a process. When using *attach to process*, you need to provide your password before the debugging session can begin. +* You may see an error saying: `ptrace: Operation not permitted`. This is due to GDB needing elevated permissions in order to attach to a process. This can be solved using the solutions below: + 1. When using *attach to process*, you need to provide your password before the debugging session can begin. + 1. To disable this error temporarily, use the following command: + + `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope` + + 1. To remove the error permanently, edit `/etc/sysctl.d/10-ptrace.conf` and modify `kernel.yama.ptrace_scope` value of `1` to `0`. macOS: From a3276c1dbc6d2e66ebb2c612a6abaeaab4262ea3 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 8 Jul 2020 13:55:35 -0700 Subject: [PATCH 2/2] Generalize permanent solution. --- docs/cpp/cpp-debug.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cpp/cpp-debug.md b/docs/cpp/cpp-debug.md index 82611d9c58..247b2438e4 100644 --- a/docs/cpp/cpp-debug.md +++ b/docs/cpp/cpp-debug.md @@ -144,7 +144,7 @@ Linux: `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope` - 1. To remove the error permanently, edit `/etc/sysctl.d/10-ptrace.conf` and modify `kernel.yama.ptrace_scope` value of `1` to `0`. + 1. To remove the error permanently, add a file called `10-ptrace.conf` to `/etc/sysctl.d/` and add the following `kernel.yama.ptrace_scope = 0`. macOS: