gdb/nat/linux-procfs.h - gdb

Data types defined

Macros defined

Source code

  1. /* Linux-specific PROCFS manipulation routines.
  2.    Copyright (C) 2011-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef COMMON_LINUX_PROCFS_H
  15. #define COMMON_LINUX_PROCFS_H

  16. #include <unistd.h>

  17. /* Return the TGID of LWPID from /proc/pid/status.  Returns -1 if not
  18.    found.  Failure to open the /proc file results in a warning.  */

  19. extern int linux_proc_get_tgid (pid_t lwpid);

  20. /* Return the TracerPid of LWPID from /proc/pid/status.  Returns -1 if
  21.    not found.  Does not warn on failure to open the /proc file.  */

  22. extern pid_t linux_proc_get_tracerpid_nowarn (pid_t lwpid);

  23. /* Detect `T (stopped)' in `/proc/PID/status'.
  24.    Other states including `T (tracing stop)' are reported as false.  */

  25. extern int linux_proc_pid_is_stopped (pid_t pid);

  26. /* Return non-zero if PID is a zombie.  Failure to open the
  27.    /proc/pid/status file results in a warning.  */

  28. extern int linux_proc_pid_is_zombie (pid_t pid);

  29. /* Return non-zero if PID is a zombie.  Does not warn on failure to
  30.    open the /proc file.  */

  31. extern int linux_proc_pid_is_zombie_nowarn (pid_t pid);

  32. /* Return non-zero if /proc/PID/status indicates that PID is gone
  33.    (i.e., in Z/Zombie or X/Dead state).  Failure to open the /proc
  34.    file is assumed to indicate the thread is gone.  */

  35. extern int linux_proc_pid_is_gone (pid_t pid);

  36. /* Return an opaque string identifying PID's NS namespace or NULL if
  37. * the information is unavailable.  The returned string must be
  38. * released with xfree.  */

  39. extern char *linux_proc_pid_get_ns (pid_t pid, const char *ns);

  40. /* Callback function for linux_proc_attach_tgid_threads.  If the PTID
  41.    thread is not yet known, try to attach to it and return true,
  42.    otherwise return false.  */
  43. typedef int (*linux_proc_attach_lwp_func) (ptid_t ptid);

  44. /* If PID is a tgid, scan the /proc/PID/task/ directory for existing
  45.    threads, and call FUNC for each thread found.  */
  46. extern void linux_proc_attach_tgid_threads (pid_t pid,
  47.                                             linux_proc_attach_lwp_func func);

  48. #endif /* COMMON_LINUX_PROCFS_H */