aboutsummaryrefslogtreecommitdiff
path: root/gdb/proc-flags.c
blob: e51ae089ba927cf48c8b6edc5c0d124e5a0ad191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Machine independent support for Solaris /proc (process file system) for GDB.
   Copyright (C) 1999-2020 Free Software Foundation, Inc.
   Written by Michael Snyder at Cygnus Solutions.
   Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.

   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/>.  */

/*
 * Pretty-print the prstatus flags.
 * 
 * Arguments: unsigned long flags, int verbose
 *
 */

#include "defs.h"

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

#include "proc-utils.h"

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

struct trans {
  int value;                    /* The numeric value */
  const char *name;             /* The equivalent symbolic value */
  const char *desc;             /* Short description of value */
};

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

static struct trans pr_flag_table[] =
{
  /* lwp is stopped */
  { PR_STOPPED, "PR_STOPPED", "Process (LWP) is stopped" },
  /* lwp is stopped on an event of interest */
  { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" },
  /* lwp has a stop directive in effect */
  { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" },
  /* lwp has a single-step directive in effect */
  { PR_STEP, "PR_STEP", "A single step directive is in effect" },
  /* lwp is sleeping in a system call */
  { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an (interruptible) system call" },
  /* contents of pr_instr undefined */
  { PR_PCINVAL, "PR_PCINVAL", "PC (pr_instr) is invalid" },
  /* this lwp is the aslwp */
  { PR_ASLWP, "PR_ASLWP", "This is the asynchronous signal LWP" },
  /* this lwp is the /proc agent lwp */
  { PR_AGENT, "PR_AGENT", "This is the /proc agent LWP" },
  /* this is a system process */
  { PR_ISSYS, "PR_ISSYS", "Is a system process/thread" },
  /* process is the parent of a vfork()d child */
  { PR_VFORKP, "PR_VFORKP", "Process is the parent of a vforked child" },
  /* process's process group is orphaned */
  { PR_ORPHAN, "PR_ORPHAN", "Process's process group is orphaned" },
  /* inherit-on-fork is in effect */
  { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" },
  /* run-on-last-close is in effect */
  { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" },
  /* kill-on-last-close is in effect */
  { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" },
  /* asynchronous-stop is in effect */
  { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" },
  /* micro-state usage accounting is in effect */
  { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" },
  /* breakpoint trap pc adjustment is in effect */
  { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" },
  /* ptrace-compatibility mode is in effect */
  { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" },
  /* micro-state accounting inherited on fork */
  { PR_MSFORK, "PR_PCOMPAT", "Micro-state accounting inherited on fork" },
};

void
proc_prettyfprint_flags (FILE *file, unsigned long flags, int verbose)
{
  int i;

  for (i = 0; i < sizeof (pr_flag_table) / sizeof (pr_flag_table[0]); i++)
    if (flags & pr_flag_table[i].value)
      {
	fprintf (file, "%s ", pr_flag_table[i].name);
	if (verbose)
	  fprintf (file, "%s\n", pr_flag_table[i].desc);
      }
  if (!verbose)
    fprintf (file, "\n");
}

void
proc_prettyprint_flags (unsigned long flags, int verbose)
{
  proc_prettyfprint_flags (stdout, flags, verbose);
}