gdb/proc-flags.c - gdb

Global variables defined

Data types defined

Functions defined

Macros defined

Source code

  1. /* Machine independent support for SVR4 /proc (process file system) for GDB.
  2.    Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3.    Written by Michael Snyder at Cygnus Solutions.
  4.    Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.

  5.    This file is part of GDB.

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

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

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

  16. /*
  17. * Pretty-print the prstatus flags.
  18. *
  19. * Arguments: unsigned long flags, int verbose
  20. *
  21. */

  22. #include "defs.h"

  23. #if defined (NEW_PROC_API)
  24. #define _STRUCTURED_PROC 1
  25. #endif

  26. #include <sys/types.h>
  27. #include <sys/procfs.h>

  28. #include "proc-utils.h"

  29. /*  Much of the information used in the /proc interface, particularly for
  30.     printing status information, is kept as tables of structures of the
  31.     following form.  These tables can be used to map numeric values to
  32.     their symbolic names and to a string that describes their specific use.  */

  33. struct trans {
  34.   int value;                    /* The numeric value */
  35.   char *name;                   /* The equivalent symbolic value */
  36.   char *desc;                   /* Short description of value */
  37. };

  38. /* Translate bits in the pr_flags member of the prstatus structure,
  39.    into the names and desc information.  */

  40. static struct trans pr_flag_table[] =
  41. {
  42. #if defined (PR_STOPPED)
  43.   /* Sol2.5: lwp is stopped
  44.    * Sol2.6: lwp is stopped
  45.    * Sol2.7: lwp is stopped
  46.    * IRIX6:  process is stopped
  47.    * OSF:    task/thread is stopped
  48.    * UW:     LWP is stopped
  49.    */
  50.   { PR_STOPPED, "PR_STOPPED", "Process (LWP) is stopped" },
  51. #endif
  52. #if defined (PR_ISTOP)
  53.   /* Sol2.5: lwp is stopped on an event of interest
  54.    * Sol2.6: lwp is stopped on an event of interest
  55.    * Sol2.7: lwp is stopped on an event of interest
  56.    * IRIX6:  process is stopped on event of interest
  57.    * OSF:    task/thread stopped on event of interest
  58.    * UW:     LWP stopped on an event of interest
  59.    */
  60.   { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" },
  61. #endif
  62. #if defined (PR_DSTOP)
  63.   /* Sol2.5: lwp has a stop directive in effect
  64.    * Sol2.6: lwp has a stop directive in effect
  65.    * Sol2.7: lwp has a stop directive in effect
  66.    * IRIX6:  process has stop directive in effect
  67.    * OSF:    task/thread has stop directive in effect
  68.    * UW:     A stop directive is in effect
  69.    */
  70.   { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" },
  71. #endif
  72. #if defined (PR_STEP)
  73.   /* Sol2.5: lwp has a single-step directive in effect
  74.    * Sol2.6: lwp has a single-step directive in effect
  75.    * Sol2.7: lwp has a single-step directive in effect
  76.    * IRIX6:  process has single step pending
  77.    */
  78.   { PR_STEP, "PR_STEP", "A single step directive is in effect" },
  79. #endif
  80. #if defined (PR_ASLEEP)
  81.   /* Sol2.5: lwp is sleeping in a system call
  82.    * Sol2.6: lwp is sleeping in a system call
  83.    * Sol2.7: lwp is sleeping in a system call
  84.    * IRIX6:  process is in an interruptible sleep
  85.    * OSF:    task/thread is asleep within a system call
  86.    * UW:     LWP is sleep()ing in a system call
  87.    */
  88.   { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an (interruptible) system call" },
  89. #endif
  90. #if defined (PR_PCINVAL)
  91.   /* Sol2.5: contents of pr_instr undefined
  92.    * Sol2.6: contents of pr_instr undefined
  93.    * Sol2.7: contents of pr_instr undefined
  94.    * IRIX6:  current pc is invalid
  95.    * OSF:    program counter contains invalid address
  96.    * UW:     %pc refers to an invalid virtual address
  97.    */
  98.   { PR_PCINVAL, "PR_PCINVAL", "PC (pr_instr) is invalid" },
  99. #endif
  100. #if defined (PR_ASLWP)
  101.   /* Sol2.5: this lwp is the aslwp
  102.    * Sol2.6: this lwp is the aslwp
  103.    * Sol2.7: this lwp is the aslwp
  104.    */
  105.   { PR_ASLWP, "PR_ASLWP", "This is the asynchronous signal LWP" },
  106. #endif
  107. #if defined (PR_AGENT)
  108.   /* Sol2.6: this lwp is the /proc agent lwp
  109.    * Sol2.7: this lwp is the /proc agent lwp
  110.    */
  111.   { PR_AGENT, "PR_AGENT", "This is the /proc agent LWP" },
  112. #endif
  113. #if defined (PR_ISSYS)
  114.   /* Sol2.5: system process
  115.    * Sol2.6: this is a system process
  116.    * Sol2.7: this is a system process
  117.    * IRIX6:  process is a system process
  118.    * OSF:    task/thread is a system task/thread
  119.    * UW:     System process
  120.    */
  121.   { PR_ISSYS, "PR_ISSYS", "Is a system process/thread" },
  122. #endif
  123. #if defined (PR_VFORKP)
  124.   /* Sol2.6: process is the parent of a vfork()d child
  125.    * Sol2.7: process is the parent of a vfork()d child
  126.    */
  127.   { PR_VFORKP, "PR_VFORKP", "Process is the parent of a vforked child" },
  128. #endif
  129. #ifdef PR_ORPHAN
  130.   /* Sol2.6: process's process group is orphaned
  131.    * Sol2.7: process's process group is orphaned
  132.    */
  133.   { PR_ORPHAN, "PR_ORPHAN", "Process's process group is orphaned" },
  134. #endif
  135. #if defined (PR_FORK)
  136.   /* Sol2.5: inherit-on-fork is in effect
  137.    * Sol2.6: inherit-on-fork is in effect
  138.    * Sol2.7: inherit-on-fork is in effect
  139.    * IRIX6:  process has inherit-on-fork flag set
  140.    * OSF:    task/thread has inherit-on-fork flag set
  141.    * UW:     inherit-on-fork is in effect
  142.    */
  143.   { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" },
  144. #endif
  145. #if defined (PR_RLC)
  146.   /* Sol2.5: run-on-last-close is in effect
  147.    * Sol2.6: run-on-last-close is in effect
  148.    * Sol2.7: run-on-last-close is in effect
  149.    * IRIX6:  process has run-on-last-close flag set
  150.    * OSF:    task/thread has run-on-last-close flag set
  151.    * UW:     Run-on-last-close is in effect
  152.    */
  153.   { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" },
  154. #endif
  155. #if defined (PR_KLC)
  156.   /* Sol2.5: kill-on-last-close is in effect
  157.    * Sol2.6: kill-on-last-close is in effect
  158.    * Sol2.7: kill-on-last-close is in effect
  159.    * IRIX6:  process has kill-on-last-close flag set
  160.    * OSF:    kill-on-last-close, superceeds RLC
  161.    * UW:     kill-on-last-close is in effect
  162.    */
  163.   { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" },
  164. #endif
  165. #if defined (PR_ASYNC)
  166.   /* Sol2.5: asynchronous-stop is in effect
  167.    * Sol2.6: asynchronous-stop is in effect
  168.    * Sol2.7: asynchronous-stop is in effect
  169.    * OSF:    asynchronous stop mode is in effect
  170.    * UW:     asynchronous stop mode is in effect
  171.    */
  172.   { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" },
  173. #endif
  174. #if defined (PR_MSACCT)
  175.   /* Sol2.5: micro-state usage accounting is in effect
  176.    * Sol2.6: micro-state usage accounting is in effect
  177.    * Sol2.7: micro-state usage accounting is in effect
  178.    */
  179.   { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" },
  180. #endif
  181. #if defined (PR_BPTADJ)
  182.   /* Sol2.5: breakpoint trap pc adjustment is in effect
  183.    * Sol2.6: breakpoint trap pc adjustment is in effect
  184.    * Sol2.7: breakpoint trap pc adjustment is in effect
  185.    */
  186.   { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" },
  187. #endif
  188. #if defined (PR_PTRACE)
  189.   /* Note: different meanings on Solaris and Irix 6
  190.    * Sol2.5: obsolete, never set in SunOS5.0
  191.    * Sol2.6: ptrace-compatibility mode is in effect
  192.    * Sol2.7: ptrace-compatibility mode is in effect
  193.    * IRIX6:  process is traced with ptrace() too
  194.    * OSF:    task/thread is being traced by ptrace
  195.    * UW:     Process is being controlled by ptrace(2)
  196.    */
  197.   { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" },
  198. #endif
  199. #if defined (PR_PCOMPAT)
  200.   /* Note: PCOMPAT on Sol2.5 means same thing as PTRACE on Sol2.6
  201.    * Sol2.5 (only): ptrace-compatibility mode is in effect
  202.    */
  203.   { PR_PCOMPAT, "PR_PCOMPAT", "Ptrace compatibility mode in effect" },
  204. #endif
  205. #ifdef PR_MSFORK
  206.   /* Sol2.6: micro-state accounting inherited on fork
  207.    * Sol2.7: micro-state accounting inherited on fork
  208.    */
  209.   { PR_MSFORK, "PR_PCOMPAT", "Micro-state accounting inherited on fork" },
  210. #endif

  211. #ifdef PR_ISKTHREAD
  212.   /* Irix6: process is a kernel thread */
  213.   { PR_ISKTHREAD, "PR_KTHREAD", "Process is a kernel thread" },
  214. #endif

  215. #ifdef PR_ABORT
  216.   /* OSF (only): abort the current stop condition */
  217.   { PR_ABORT, "PR_ABORT", "Abort the current stop condition" },
  218. #endif

  219. #ifdef PR_TRACING
  220.   /* OSF: task is traced */
  221.   { PR_TRACING, "PR_TRACING", "Task is traced" },
  222. #endif

  223. #ifdef PR_STOPFORK
  224.   /* OSF: stop child on fork */
  225.   { PR_STOPFORK, "PR_STOPFORK", "Stop child on fork" },
  226. #endif

  227. #ifdef PR_STOPEXEC
  228.   /* OSF: stop on exec */
  229.   { PR_STOPEXEC, "PR_STOPEXEC", "Stop on exec" },
  230. #endif

  231. #ifdef PR_STOPTERM
  232.   /* OSF: stop on task exit */
  233.   { PR_STOPTERM, "PR_STOPTERM", "Stop on task exit" },
  234. #endif

  235. #ifdef PR_STOPTCR
  236.   /* OSF: stop on thread creation */
  237.   { PR_STOPTCR, "PR_STOPTCR", "Stop on thread creation" },
  238. #endif

  239. #ifdef PR_STOPTTERM
  240.   /* OSF: stop on thread exit */
  241.   { PR_STOPTTERM, "PR_STOPTTERM", "Stop on thread exit" },
  242. #endif

  243. #ifdef PR_USCHED
  244.   /* OSF: user level scheduling is in effect */
  245.   { PR_USCHED, "PR_USCHED", "User level scheduling is in effect" },
  246. #endif
  247. };

  248. void
  249. proc_prettyfprint_flags (FILE *file, unsigned long flags, int verbose)
  250. {
  251.   int i;

  252.   for (i = 0; i < sizeof (pr_flag_table) / sizeof (pr_flag_table[0]); i++)
  253.     if (flags & pr_flag_table[i].value)
  254.       {
  255.         fprintf (file, "%s ", pr_flag_table[i].name);
  256.         if (verbose)
  257.           fprintf (file, "%s\n", pr_flag_table[i].desc);
  258.       }
  259.   if (!verbose)
  260.     fprintf (file, "\n");
  261. }

  262. void
  263. proc_prettyprint_flags (unsigned long flags, int verbose)
  264. {
  265.   proc_prettyfprint_flags (stdout, flags, verbose);
  266. }