GDB (API)
/home/stan/gdb/src/gdb/proc-flags.c
Go to the documentation of this file.
00001 /* Machine independent support for SVR4 /proc (process file system) for GDB.
00002    Copyright (C) 1999-2013 Free Software Foundation, Inc.
00003    Written by Michael Snyder at Cygnus Solutions.
00004    Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
00005 
00006    This file is part of GDB.
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 3 of the License, or
00011    (at your option) any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00020 
00021 /*
00022  * Pretty-print the prstatus flags.
00023  * 
00024  * Arguments: unsigned long flags, int verbose
00025  *
00026  */
00027 
00028 #include "defs.h"
00029 
00030 #if defined (NEW_PROC_API)
00031 #define _STRUCTURED_PROC 1
00032 #endif
00033 
00034 #include <stdio.h>
00035 #include <sys/types.h>
00036 #include <sys/procfs.h>
00037 
00038 #include "proc-utils.h"
00039 
00040 /*  Much of the information used in the /proc interface, particularly for
00041     printing status information, is kept as tables of structures of the
00042     following form.  These tables can be used to map numeric values to
00043     their symbolic names and to a string that describes their specific use.  */
00044 
00045 struct trans {
00046   int value;                    /* The numeric value */
00047   char *name;                   /* The equivalent symbolic value */
00048   char *desc;                   /* Short description of value */
00049 };
00050 
00051 /* Translate bits in the pr_flags member of the prstatus structure,
00052    into the names and desc information.  */
00053 
00054 static struct trans pr_flag_table[] =
00055 {
00056 #if defined (PR_STOPPED)
00057   /* Sol2.5: lwp is stopped
00058    * Sol2.6: lwp is stopped
00059    * Sol2.7: lwp is stopped
00060    * IRIX6:  process is stopped
00061    * OSF:    task/thread is stopped
00062    * UW:     LWP is stopped
00063    */
00064   { PR_STOPPED, "PR_STOPPED", "Process (LWP) is stopped" },
00065 #endif
00066 #if defined (PR_ISTOP)
00067   /* Sol2.5: lwp is stopped on an event of interest
00068    * Sol2.6: lwp is stopped on an event of interest
00069    * Sol2.7: lwp is stopped on an event of interest
00070    * IRIX6:  process is stopped on event of interest
00071    * OSF:    task/thread stopped on event of interest
00072    * UW:     LWP stopped on an event of interest
00073    */
00074   { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" },
00075 #endif
00076 #if defined (PR_DSTOP)
00077   /* Sol2.5: lwp has a stop directive in effect
00078    * Sol2.6: lwp has a stop directive in effect
00079    * Sol2.7: lwp has a stop directive in effect
00080    * IRIX6:  process has stop directive in effect
00081    * OSF:    task/thread has stop directive in effect
00082    * UW:     A stop directive is in effect
00083    */
00084   { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" },
00085 #endif
00086 #if defined (PR_STEP)
00087   /* Sol2.5: lwp has a single-step directive in effect
00088    * Sol2.6: lwp has a single-step directive in effect
00089    * Sol2.7: lwp has a single-step directive in effect
00090    * IRIX6:  process has single step pending
00091    */
00092   { PR_STEP, "PR_STEP", "A single step directive is in effect" },
00093 #endif
00094 #if defined (PR_ASLEEP)
00095   /* Sol2.5: lwp is sleeping in a system call
00096    * Sol2.6: lwp is sleeping in a system call
00097    * Sol2.7: lwp is sleeping in a system call
00098    * IRIX6:  process is in an interruptible sleep
00099    * OSF:    task/thread is asleep within a system call
00100    * UW:     LWP is sleep()ing in a system call
00101    */
00102   { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an (interruptible) system call" },
00103 #endif
00104 #if defined (PR_PCINVAL)
00105   /* Sol2.5: contents of pr_instr undefined
00106    * Sol2.6: contents of pr_instr undefined
00107    * Sol2.7: contents of pr_instr undefined
00108    * IRIX6:  current pc is invalid
00109    * OSF:    program counter contains invalid address
00110    * UW:     %pc refers to an invalid virtual address
00111    */
00112   { PR_PCINVAL, "PR_PCINVAL", "PC (pr_instr) is invalid" },
00113 #endif
00114 #if defined (PR_ASLWP)
00115   /* Sol2.5: this lwp is the aslwp
00116    * Sol2.6: this lwp is the aslwp
00117    * Sol2.7: this lwp is the aslwp
00118    */
00119   { PR_ASLWP, "PR_ASLWP", "This is the asynchronous signal LWP" },
00120 #endif
00121 #if defined (PR_AGENT)
00122   /* Sol2.6: this lwp is the /proc agent lwp
00123    * Sol2.7: this lwp is the /proc agent lwp
00124    */
00125   { PR_AGENT, "PR_AGENT", "This is the /proc agent LWP" },
00126 #endif
00127 #if defined (PR_ISSYS)
00128   /* Sol2.5: system process
00129    * Sol2.6: this is a system process
00130    * Sol2.7: this is a system process
00131    * IRIX6:  process is a system process
00132    * OSF:    task/thread is a system task/thread
00133    * UW:     System process
00134    */
00135   { PR_ISSYS, "PR_ISSYS", "Is a system process/thread" },
00136 #endif
00137 #if defined (PR_VFORKP)
00138   /* Sol2.6: process is the parent of a vfork()d child
00139    * Sol2.7: process is the parent of a vfork()d child
00140    */
00141   { PR_VFORKP, "PR_VFORKP", "Process is the parent of a vforked child" },
00142 #endif
00143 #ifdef PR_ORPHAN
00144   /* Sol2.6: process's process group is orphaned
00145    * Sol2.7: process's process group is orphaned
00146    */
00147   { PR_ORPHAN, "PR_ORPHAN", "Process's process group is orphaned" },
00148 #endif
00149 #if defined (PR_FORK)
00150   /* Sol2.5: inherit-on-fork is in effect
00151    * Sol2.6: inherit-on-fork is in effect
00152    * Sol2.7: inherit-on-fork is in effect
00153    * IRIX6:  process has inherit-on-fork flag set
00154    * OSF:    task/thread has inherit-on-fork flag set
00155    * UW:     inherit-on-fork is in effect
00156    */
00157   { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" },
00158 #endif
00159 #if defined (PR_RLC)
00160   /* Sol2.5: run-on-last-close is in effect
00161    * Sol2.6: run-on-last-close is in effect
00162    * Sol2.7: run-on-last-close is in effect
00163    * IRIX6:  process has run-on-last-close flag set
00164    * OSF:    task/thread has run-on-last-close flag set
00165    * UW:     Run-on-last-close is in effect
00166    */
00167   { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" },
00168 #endif
00169 #if defined (PR_KLC)
00170   /* Sol2.5: kill-on-last-close is in effect
00171    * Sol2.6: kill-on-last-close is in effect
00172    * Sol2.7: kill-on-last-close is in effect
00173    * IRIX6:  process has kill-on-last-close flag set
00174    * OSF:    kill-on-last-close, superceeds RLC
00175    * UW:     kill-on-last-close is in effect
00176    */
00177   { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" },
00178 #endif
00179 #if defined (PR_ASYNC)
00180   /* Sol2.5: asynchronous-stop is in effect
00181    * Sol2.6: asynchronous-stop is in effect
00182    * Sol2.7: asynchronous-stop is in effect
00183    * OSF:    asynchronous stop mode is in effect
00184    * UW:     asynchronous stop mode is in effect
00185    */
00186   { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" },
00187 #endif
00188 #if defined (PR_MSACCT)
00189   /* Sol2.5: micro-state usage accounting is in effect
00190    * Sol2.6: micro-state usage accounting is in effect
00191    * Sol2.7: micro-state usage accounting is in effect
00192    */
00193   { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" },
00194 #endif
00195 #if defined (PR_BPTADJ)
00196   /* Sol2.5: breakpoint trap pc adjustment is in effect
00197    * Sol2.6: breakpoint trap pc adjustment is in effect
00198    * Sol2.7: breakpoint trap pc adjustment is in effect
00199    */
00200   { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" },
00201 #endif
00202 #if defined (PR_PTRACE)
00203   /* Note: different meanings on Solaris and Irix 6
00204    * Sol2.5: obsolete, never set in SunOS5.0
00205    * Sol2.6: ptrace-compatibility mode is in effect
00206    * Sol2.7: ptrace-compatibility mode is in effect
00207    * IRIX6:  process is traced with ptrace() too
00208    * OSF:    task/thread is being traced by ptrace
00209    * UW:     Process is being controlled by ptrace(2)
00210    */
00211   { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" },
00212 #endif
00213 #if defined (PR_PCOMPAT)
00214   /* Note: PCOMPAT on Sol2.5 means same thing as PTRACE on Sol2.6
00215    * Sol2.5 (only): ptrace-compatibility mode is in effect
00216    */
00217   { PR_PCOMPAT, "PR_PCOMPAT", "Ptrace compatibility mode in effect" },
00218 #endif
00219 #ifdef PR_MSFORK
00220   /* Sol2.6: micro-state accounting inherited on fork
00221    * Sol2.7: micro-state accounting inherited on fork
00222    */
00223   { PR_MSFORK, "PR_PCOMPAT", "Micro-state accounting inherited on fork" },
00224 #endif
00225 
00226 #ifdef PR_ISKTHREAD
00227   /* Irix6: process is a kernel thread */
00228   { PR_ISKTHREAD, "PR_KTHREAD", "Process is a kernel thread" },
00229 #endif
00230 
00231 #ifdef PR_ABORT
00232   /* OSF (only): abort the current stop condition */
00233   { PR_ABORT, "PR_ABORT", "Abort the current stop condition" },
00234 #endif
00235 
00236 #ifdef PR_TRACING
00237   /* OSF: task is traced */
00238   { PR_TRACING, "PR_TRACING", "Task is traced" },
00239 #endif
00240 
00241 #ifdef PR_STOPFORK
00242   /* OSF: stop child on fork */
00243   { PR_STOPFORK, "PR_STOPFORK", "Stop child on fork" },
00244 #endif
00245 
00246 #ifdef PR_STOPEXEC
00247   /* OSF: stop on exec */
00248   { PR_STOPEXEC, "PR_STOPEXEC", "Stop on exec" },
00249 #endif
00250 
00251 #ifdef PR_STOPTERM
00252   /* OSF: stop on task exit */
00253   { PR_STOPTERM, "PR_STOPTERM", "Stop on task exit" },
00254 #endif
00255 
00256 #ifdef PR_STOPTCR
00257   /* OSF: stop on thread creation */
00258   { PR_STOPTCR, "PR_STOPTCR", "Stop on thread creation" },
00259 #endif
00260 
00261 #ifdef PR_STOPTTERM
00262   /* OSF: stop on thread exit */
00263   { PR_STOPTTERM, "PR_STOPTTERM", "Stop on thread exit" },
00264 #endif
00265 
00266 #ifdef PR_USCHED
00267   /* OSF: user level scheduling is in effect */
00268   { PR_USCHED, "PR_USCHED", "User level scheduling is in effect" },
00269 #endif
00270 };
00271 
00272 void
00273 proc_prettyfprint_flags (FILE *file, unsigned long flags, int verbose)
00274 {
00275   int i;
00276 
00277   for (i = 0; i < sizeof (pr_flag_table) / sizeof (pr_flag_table[0]); i++)
00278     if (flags & pr_flag_table[i].value)
00279       {
00280         fprintf (file, "%s ", pr_flag_table[i].name);
00281         if (verbose)
00282           fprintf (file, "%s\n", pr_flag_table[i].desc);
00283       }
00284   if (!verbose)
00285     fprintf (file, "\n");
00286 }
00287 
00288 void
00289 proc_prettyprint_flags (unsigned long flags, int verbose)
00290 {
00291   proc_prettyfprint_flags (stdout, flags, verbose);
00292 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines