aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorVyacheslav Barinov <v.barinov@samsung.com>2018-07-04 16:13:29 +0100
committerPedro Alves <palves@redhat.com>2018-07-04 16:13:29 +0100
commit1b919490e8ba30bf1d6941df0ed112b0e557017e (patch)
tree64d78f15a4de41831739f508ab170231b2c35ee4 /gdb
parent94d401b8b88a76b1372ce44e805516756a4f737b (diff)
downloadgdb-1b919490e8ba30bf1d6941df0ed112b0e557017e.zip
gdb-1b919490e8ba30bf1d6941df0ed112b0e557017e.tar.gz
gdb-1b919490e8ba30bf1d6941df0ed112b0e557017e.tar.bz2
Warn if /proc is not accessiblegdb-8.2-branchpoint
There's a buildroot where I want to debug a binary, and I tried to connect to it from outside, but got very weird errors like architecture mismatch or protocol errors. At last, after switching on '--debug' for gdbserver I found a message 'Can't open /proc/pid/' message and suddenly found that I forgot to mount procfs in my buildroot. Make discovering the problem easier by making GDB / GDBserver warn (even without --debug) if /proc can not be accessed. Native debugging: (gdb) start Temporary breakpoint 1 at 0x400835: file test.c, line 10. Starting program: /tmp/test warning: /proc is not accessible. GDBserver/remote debugging: $ ./gdbserver :9999 ./gdbserver gdbserver: /proc is not accessible. gdb/ChangeLog: 2018-07-04 Vyacheslav Barinov <v.barinov@samsung.com> Pedro Alves <palves@redhat.com> * linux-nat.c (linux_init_ptrace): Rename to ... (linux_init_ptrace_procfs): ... this. Call linux_proc_init_warnings. (linux_nat_target::post_attach) (linux_nat_target::post_startup_inferior): Adjust. * nat/linux-procfs.c (linux_proc_init_warnings): Define function. * nat/linux-procfs.h (linux_proc_init_warnings): Declare function. gdb/gdbserver/ChangeLog: 2018-07-04 Vyacheslav Barinov <v.barinov@samsung.com> Pedro Alves <palves@redhat.com> * linux-low.c (initialize_low): Call linux_proc_init_warnings.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/gdbserver/ChangeLog5
-rw-r--r--gdb/gdbserver/linux-low.c1
-rw-r--r--gdb/linux-nat.c11
-rw-r--r--gdb/nat/linux-procfs.c17
-rw-r--r--gdb/nat/linux-procfs.h5
6 files changed, 45 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ea1e7e3..0cece38 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2018-07-04 Vyacheslav Barinov <v.barinov@samsung.com>
+ Pedro Alves <palves@redhat.com>
+
+ * linux-nat.c (linux_init_ptrace): Rename to ...
+ (linux_init_ptrace_procfs): ... this. Call
+ linux_proc_init_warnings.
+ (linux_nat_target::post_attach)
+ (linux_nat_target::post_startup_inferior): Adjust.
+ * nat/linux-procfs.c (linux_proc_init_warnings): Define function.
+ * nat/linux-procfs.h (linux_proc_init_warnings): Declare function.
+
2018-07-04 Tom de Vries <tdevries@suse.de>
* dwarf2read.c (error_check_comp_unit_head): Move dwarf version
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index a59999a..ac644ce 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-04 Vyacheslav Barinov <v.barinov@samsung.com>
+ Pedro Alves <palves@redhat.com>
+
+ * linux-low.c (initialize_low): Call linux_proc_init_warnings.
+
2018-07-03 Tom Tromey <tom@tromey.com>
* linux-low.c: Update.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 6e026f1..7c396ae 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -7558,6 +7558,7 @@ initialize_low (void)
set_target_ops (&linux_target_ops);
linux_ptrace_init_warnings ();
+ linux_proc_init_warnings ();
sigchld_action.sa_handler = sigchld_handler;
sigemptyset (&sigchld_action.sa_mask);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 567cb06..18d9a38 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -384,18 +384,19 @@ linux_nat_ptrace_options (int attached)
return options;
}
-/* Initialize ptrace warnings and check for supported ptrace
- features given PID.
+/* Initialize ptrace and procfs warnings and check for supported
+ ptrace features given PID.
ATTACHED should be nonzero iff we attached to the inferior. */
static void
-linux_init_ptrace (pid_t pid, int attached)
+linux_init_ptrace_procfs (pid_t pid, int attached)
{
int options = linux_nat_ptrace_options (attached);
linux_enable_event_reporting (pid, options);
linux_ptrace_init_warnings ();
+ linux_proc_init_warnings ();
}
linux_nat_target::~linux_nat_target ()
@@ -404,13 +405,13 @@ linux_nat_target::~linux_nat_target ()
void
linux_nat_target::post_attach (int pid)
{
- linux_init_ptrace (pid, 1);
+ linux_init_ptrace_procfs (pid, 1);
}
void
linux_nat_target::post_startup_inferior (ptid_t ptid)
{
- linux_init_ptrace (ptid.pid (), 0);
+ linux_init_ptrace_procfs (ptid.pid (), 0);
}
/* Return the number of known LWPs in the tgid given by PID. */
diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
index 1c236c5..6c15ea5 100644
--- a/gdb/nat/linux-procfs.c
+++ b/gdb/nat/linux-procfs.c
@@ -357,3 +357,20 @@ linux_proc_pid_to_exec_file (int pid)
return buf;
}
+
+/* See linux-procfs.h. */
+
+void
+linux_proc_init_warnings ()
+{
+ static bool warned = false;
+
+ if (warned)
+ return;
+ warned = true;
+
+ struct stat st;
+
+ if (stat ("/proc/self", &st) != 0)
+ warning (_("/proc is not accessible."));
+}
diff --git a/gdb/nat/linux-procfs.h b/gdb/nat/linux-procfs.h
index efb2911..2f8932e 100644
--- a/gdb/nat/linux-procfs.h
+++ b/gdb/nat/linux-procfs.h
@@ -80,4 +80,9 @@ extern int linux_proc_task_list_dir_exists (pid_t pid);
extern char *linux_proc_pid_to_exec_file (int pid);
+/* Display possible problems on this system. Display them only once
+ per GDB execution. */
+
+extern void linux_proc_init_warnings ();
+
#endif /* COMMON_LINUX_PROCFS_H */