| 1 | /* Machine independent support for Solaris /proc (process file system) for GDB. |
| 2 | Copyright (C) 1999-2018 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 | |
| 6 | This file is part of GDB. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 20 | |
| 21 | /* |
| 22 | * Pretty-print the prstatus flags. |
| 23 | * |
| 24 | * Arguments: unsigned long flags, int verbose |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include "defs.h" |
| 29 | |
| 30 | #define _STRUCTURED_PROC 1 |
| 31 | |
| 32 | #include <sys/types.h> |
| 33 | #include <sys/procfs.h> |
| 34 | |
| 35 | #include "proc-utils.h" |
| 36 | |
| 37 | /* Much of the information used in the /proc interface, particularly for |
| 38 | printing status information, is kept as tables of structures of the |
| 39 | following form. These tables can be used to map numeric values to |
| 40 | their symbolic names and to a string that describes their specific use. */ |
| 41 | |
| 42 | struct trans { |
| 43 | int value; /* The numeric value */ |
| 44 | const char *name; /* The equivalent symbolic value */ |
| 45 | const char *desc; /* Short description of value */ |
| 46 | }; |
| 47 | |
| 48 | /* Translate bits in the pr_flags member of the prstatus structure, |
| 49 | into the names and desc information. */ |
| 50 | |
| 51 | static struct trans pr_flag_table[] = |
| 52 | { |
| 53 | /* lwp is stopped */ |
| 54 | { PR_STOPPED, "PR_STOPPED", "Process (LWP) is stopped" }, |
| 55 | /* lwp is stopped on an event of interest */ |
| 56 | { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" }, |
| 57 | /* lwp has a stop directive in effect */ |
| 58 | { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" }, |
| 59 | /* lwp has a single-step directive in effect */ |
| 60 | { PR_STEP, "PR_STEP", "A single step directive is in effect" }, |
| 61 | /* lwp is sleeping in a system call */ |
| 62 | { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an (interruptible) system call" }, |
| 63 | /* contents of pr_instr undefined */ |
| 64 | { PR_PCINVAL, "PR_PCINVAL", "PC (pr_instr) is invalid" }, |
| 65 | /* this lwp is the aslwp */ |
| 66 | { PR_ASLWP, "PR_ASLWP", "This is the asynchronous signal LWP" }, |
| 67 | /* this lwp is the /proc agent lwp */ |
| 68 | { PR_AGENT, "PR_AGENT", "This is the /proc agent LWP" }, |
| 69 | /* this is a system process */ |
| 70 | { PR_ISSYS, "PR_ISSYS", "Is a system process/thread" }, |
| 71 | /* process is the parent of a vfork()d child */ |
| 72 | { PR_VFORKP, "PR_VFORKP", "Process is the parent of a vforked child" }, |
| 73 | /* process's process group is orphaned */ |
| 74 | { PR_ORPHAN, "PR_ORPHAN", "Process's process group is orphaned" }, |
| 75 | /* inherit-on-fork is in effect */ |
| 76 | { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" }, |
| 77 | /* run-on-last-close is in effect */ |
| 78 | { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" }, |
| 79 | /* kill-on-last-close is in effect */ |
| 80 | { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" }, |
| 81 | /* asynchronous-stop is in effect */ |
| 82 | { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" }, |
| 83 | /* micro-state usage accounting is in effect */ |
| 84 | { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" }, |
| 85 | /* breakpoint trap pc adjustment is in effect */ |
| 86 | { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" }, |
| 87 | /* ptrace-compatibility mode is in effect */ |
| 88 | { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" }, |
| 89 | /* micro-state accounting inherited on fork */ |
| 90 | { PR_MSFORK, "PR_PCOMPAT", "Micro-state accounting inherited on fork" }, |
| 91 | }; |
| 92 | |
| 93 | void |
| 94 | proc_prettyfprint_flags (FILE *file, unsigned long flags, int verbose) |
| 95 | { |
| 96 | int i; |
| 97 | |
| 98 | for (i = 0; i < sizeof (pr_flag_table) / sizeof (pr_flag_table[0]); i++) |
| 99 | if (flags & pr_flag_table[i].value) |
| 100 | { |
| 101 | fprintf (file, "%s ", pr_flag_table[i].name); |
| 102 | if (verbose) |
| 103 | fprintf (file, "%s\n", pr_flag_table[i].desc); |
| 104 | } |
| 105 | if (!verbose) |
| 106 | fprintf (file, "\n"); |
| 107 | } |
| 108 | |
| 109 | void |
| 110 | proc_prettyprint_flags (unsigned long flags, int verbose) |
| 111 | { |
| 112 | proc_prettyfprint_flags (stdout, flags, verbose); |
| 113 | } |