OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [proc-why.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* Machine independent support for SVR4 /proc (process file system) for GDB.
2
   Copyright 1999 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 2 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, write to the Free Software Foundation,
20
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21
 
22
/*
23
 * Pretty-print the pr_why value.
24
 *
25
 * Arguments: unsigned long flags, int verbose
26
 *
27
 */
28
 
29
#include "defs.h"
30
 
31
#if defined(NEW_PROC_API)
32
#define _STRUCTURED_PROC 1
33
#endif
34
 
35
#include <stdio.h>
36
#include <sys/types.h>
37
#include <sys/procfs.h>
38
 
39
#include "proc-utils.h"
40
 
41
/*  Much of the information used in the /proc interface, particularly for
42
    printing status information, is kept as tables of structures of the
43
    following form.  These tables can be used to map numeric values to
44
    their symbolic names and to a string that describes their specific use. */
45
 
46
struct trans {
47
  int value;                    /* The numeric value */
48
  char *name;                   /* The equivalent symbolic value */
49
  char *desc;                   /* Short description of value */
50
};
51
 
52
/*  Translate values in the pr_why field of the prstatus struct. */
53
 
54
static struct trans pr_why_table[] =
55
{
56
#if defined (PR_REQUESTED)
57
  /* All platforms */
58
  { PR_REQUESTED, "PR_REQUESTED",
59
    "Directed to stop by debugger via P(IO)CSTOP or P(IO)CWSTOP" },
60
#endif
61
#if defined (PR_SIGNALLED)
62
  /* All platforms */
63
  { PR_SIGNALLED, "PR_SIGNALLED", "Receipt of a traced signal" },
64
#endif
65
#if defined (PR_SYSENTRY)
66
  /* All platforms */
67
  { PR_SYSENTRY, "PR_SYSENTRY", "Entry to a traced system call" },
68
#endif
69
#if defined (PR_SYSEXIT)
70
  /* All platforms */
71
  { PR_SYSEXIT, "PR_SYSEXIT", "Exit from a traced system call" },
72
#endif
73
#if defined (PR_JOBCONTROL)
74
  /* All platforms */
75
  { PR_JOBCONTROL, "PR_JOBCONTROL", "Default job control stop signal action" },
76
#endif
77
#if defined (PR_FAULTED)
78
  /* All platforms */
79
  { PR_FAULTED, "PR_FAULTED", "Incurred a traced hardware fault" },
80
#endif
81
#if defined (PR_SUSPENDED)
82
  /* Solaris and UnixWare */
83
  { PR_SUSPENDED, "PR_SUSPENDED", "Process suspended" },
84
#endif
85
#if defined (PR_CHECKPOINT)
86
  /* Solaris only */
87
  { PR_CHECKPOINT, "PR_CHECKPOINT", "Process stopped at checkpoint" },
88
#endif
89
#if defined (PR_FORKSTOP)
90
  /* OSF only */
91
  { PR_FORKSTOP, "PR_FORKSTOP", "Process stopped at end of fork call" },
92
#endif
93
#if defined (PR_TCRSTOP)
94
  /* OSF only */
95
  { PR_TCRSTOP, "PR_TCRSTOP", "Process stopped on thread creation" },
96
#endif
97
#if defined (PR_TTSTOP)
98
  /* OSF only */
99
  { PR_TTSTOP, "PR_TTSTOP", "Process stopped on thread termination" },
100
#endif
101
#if defined (PR_DEAD)
102
  /* OSF only */
103
  { PR_DEAD, "PR_DEAD", "Process stopped in exit system call" },
104
#endif
105
};
106
 
107
void
108
proc_prettyfprint_why (file, why, what, verbose)
109
     FILE         *file;
110
     unsigned long why;
111
     unsigned long what;
112
     int           verbose;
113
{
114
  int i;
115
 
116
  if (why == 0)
117
    return;
118
 
119
  for (i = 0; i < sizeof (pr_why_table) / sizeof (pr_why_table[0]); i++)
120
    if (why == pr_why_table[i].value)
121
      {
122
        fprintf (file, "%s ", pr_why_table[i].name);
123
        if (verbose)
124
          fprintf (file, ": %s ", pr_why_table[i].desc);
125
 
126
        switch (why) {
127
#ifdef PR_REQUESTED
128
        case PR_REQUESTED:
129
          break;        /* Nothing more to print. */
130
#endif
131
#ifdef PR_SIGNALLED
132
        case PR_SIGNALLED:
133
          proc_prettyfprint_signal (file, what, verbose);
134
          break;
135
#endif
136
#ifdef PR_FAULTED
137
        case PR_FAULTED:
138
          proc_prettyfprint_fault (file, what, verbose);
139
          break;
140
#endif
141
#ifdef PR_SYSENTRY
142
        case PR_SYSENTRY:
143
          fprintf (file, "Entry to ");
144
          proc_prettyfprint_syscall (file, what, verbose);
145
          break;
146
#endif
147
#ifdef PR_SYSEXIT
148
        case PR_SYSEXIT:
149
          fprintf (file, "Exit from ");
150
          proc_prettyfprint_syscall (file, what, verbose);
151
          break;
152
#endif
153
#ifdef PR_JOBCONTROL
154
        case PR_JOBCONTROL:
155
          proc_prettyfprint_signal (file, what, verbose);
156
          break;
157
#endif
158
#ifdef PR_DEAD
159
        case PR_DEAD:
160
          fprintf (file, "Exit status: %d\n", what);
161
          break;
162
#endif
163
        default:
164
          fprintf (file, "Unknown why %ld, what %ld\n", why, what);
165
          break;
166
        }
167
        fprintf (file, "\n");
168
 
169
        return;
170
      }
171
  fprintf (file, "Unknown pr_why.\n");
172
}
173
 
174
void
175
proc_prettyprint_why (why, what, verbose)
176
     unsigned long why;
177
     unsigned long what;
178
     int           verbose;
179
{
180
  proc_prettyfprint_why (stdout, why, what, verbose);
181
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.