mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
1b919490e8
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.
89 lines
3.2 KiB
C
89 lines
3.2 KiB
C
/* Linux-specific PROCFS manipulation routines.
|
|
Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef COMMON_LINUX_PROCFS_H
|
|
#define COMMON_LINUX_PROCFS_H
|
|
|
|
#include <unistd.h>
|
|
|
|
/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not
|
|
found. Failure to open the /proc file results in a warning. */
|
|
|
|
extern int linux_proc_get_tgid (pid_t lwpid);
|
|
|
|
/* Return the TracerPid of LWPID from /proc/pid/status. Returns -1 if
|
|
not found. Does not warn on failure to open the /proc file. */
|
|
|
|
extern pid_t linux_proc_get_tracerpid_nowarn (pid_t lwpid);
|
|
|
|
/* Detect `T (stopped)' in `/proc/PID/status'.
|
|
Other states including `T (tracing stop)' are reported as false. */
|
|
|
|
extern int linux_proc_pid_is_stopped (pid_t pid);
|
|
|
|
extern int linux_proc_pid_is_trace_stopped_nowarn (pid_t pid);
|
|
|
|
/* Return non-zero if PID is a zombie. Failure to open the
|
|
/proc/pid/status file results in a warning. */
|
|
|
|
extern int linux_proc_pid_is_zombie (pid_t pid);
|
|
|
|
/* Return non-zero if PID is a zombie. Does not warn on failure to
|
|
open the /proc file. */
|
|
|
|
extern int linux_proc_pid_is_zombie_nowarn (pid_t pid);
|
|
|
|
/* Return non-zero if /proc/PID/status indicates that PID is gone
|
|
(i.e., in Z/Zombie or X/Dead state). Failure to open the /proc
|
|
file is assumed to indicate the thread is gone. */
|
|
|
|
extern int linux_proc_pid_is_gone (pid_t pid);
|
|
|
|
/* Return a string giving the thread's name or NULL if the
|
|
information is unavailable. The returned value points to a statically
|
|
allocated buffer. The value therefore becomes invalid at the next
|
|
linux_proc_tid_get_name call. */
|
|
|
|
extern const char *linux_proc_tid_get_name (ptid_t ptid);
|
|
|
|
/* Callback function for linux_proc_attach_tgid_threads. If the PTID
|
|
thread is not yet known, try to attach to it and return true,
|
|
otherwise return false. */
|
|
typedef int (*linux_proc_attach_lwp_func) (ptid_t ptid);
|
|
|
|
/* If PID is a tgid, scan the /proc/PID/task/ directory for existing
|
|
threads, and call FUNC for each thread found. */
|
|
extern void linux_proc_attach_tgid_threads (pid_t pid,
|
|
linux_proc_attach_lwp_func func);
|
|
|
|
/* Return true if the /proc/PID/task/ directory exists. */
|
|
extern int linux_proc_task_list_dir_exists (pid_t pid);
|
|
|
|
/* Return the full absolute name of the executable file that was run
|
|
to create the process PID. The returned value persists until this
|
|
function is next called. */
|
|
|
|
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 */
|