projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove "\nError: " suffix from nat/fork-inferior.c:trace_start_error warning message
[deliverable/binutils-gdb.git]
/
gdb
/
nat
/
linux-procfs.c
diff --git
a/gdb/nat/linux-procfs.c
b/gdb/nat/linux-procfs.c
index 5d63e1b502496cc76a63ef1fa0e0c02b0302b7e6..2afc53d27aae03b2869ffedc37f57eacd79e0e66 100644
(file)
--- a/
gdb/nat/linux-procfs.c
+++ b/
gdb/nat/linux-procfs.c
@@
-1,5
+1,5
@@
/* Linux-specific PROCFS manipulation routines.
/* Linux-specific PROCFS manipulation routines.
- Copyright (C) 2009-201
6
Free Software Foundation, Inc.
+ Copyright (C) 2009-201
9
Free Software Foundation, Inc.
This file is part of GDB.
This file is part of GDB.
@@
-16,9
+16,9
@@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "common-defs.h"
+#include "
gdbsupport/
common-defs.h"
#include "linux-procfs.h"
#include "linux-procfs.h"
-#include "filestuff.h"
+#include "
gdbsupport/
filestuff.h"
#include <dirent.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/stat.h>
@@
-29,12
+29,11
@@
static int
linux_proc_get_int (pid_t lwpid, const char *field, int warn)
{
size_t field_len = strlen (field);
linux_proc_get_int (pid_t lwpid, const char *field, int warn)
{
size_t field_len = strlen (field);
- FILE *status_file;
char buf[100];
int retval = -1;
snprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid);
char buf[100];
int retval = -1;
snprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid);
- status_file = gdb_fopen_cloexec (buf, "r");
+
gdb_file_up
status_file = gdb_fopen_cloexec (buf, "r");
if (status_file == NULL)
{
if (warn)
if (status_file == NULL)
{
if (warn)
@@
-42,14
+41,13
@@
linux_proc_get_int (pid_t lwpid, const char *field, int warn)
return -1;
}
return -1;
}
- while (fgets (buf, sizeof (buf), status_file))
+ while (fgets (buf, sizeof (buf), status_file
.get ()
))
if (strncmp (buf, field, field_len) == 0 && buf[field_len] == ':')
{
retval = strtol (&buf[field_len + 1], NULL, 10);
break;
}
if (strncmp (buf, field, field_len) == 0 && buf[field_len] == ':')
{
retval = strtol (&buf[field_len + 1], NULL, 10);
break;
}
- fclose (status_file);
return retval;
}
return retval;
}
@@
-98,15
+96,18
@@
enum proc_state
static enum proc_state
parse_proc_status_state (const char *state)
{
static enum proc_state
parse_proc_status_state (const char *state)
{
- state = skip_spaces
_const
(state);
+ state = skip_spaces (state);
switch (state[0])
{
switch (state[0])
{
+ case 't':
+ return PROC_STATE_TRACING_STOP;
case 'T':
case 'T':
- if (strcmp (state, "T (tracing stop)") == 0)
- return PROC_STATE_TRACING_STOP;
- else
+ /* Before Linux 2.6.33, tracing stop used uppercase T. */
+ if (strcmp (state, "T (stopped)\n") == 0)
return PROC_STATE_STOPPED;
return PROC_STATE_STOPPED;
+ else /* "T (tracing stop)\n" */
+ return PROC_STATE_TRACING_STOP;
case 'X':
return PROC_STATE_DEAD;
case 'Z':
case 'X':
return PROC_STATE_DEAD;
case 'Z':
@@
-125,12
+126,11
@@
parse_proc_status_state (const char *state)
static int
linux_proc_pid_get_state (pid_t pid, int warn, enum proc_state *state)
{
static int
linux_proc_pid_get_state (pid_t pid, int warn, enum proc_state *state)
{
- FILE *procfile;
int have_state;
char buffer[100];
xsnprintf (buffer, sizeof (buffer), "/proc/%d/status", (int) pid);
int have_state;
char buffer[100];
xsnprintf (buffer, sizeof (buffer), "/proc/%d/status", (int) pid);
- procfile = gdb_fopen_cloexec (buffer, "r");
+
gdb_file_up
procfile = gdb_fopen_cloexec (buffer, "r");
if (procfile == NULL)
{
if (warn)
if (procfile == NULL)
{
if (warn)
@@
-139,14
+139,13
@@
linux_proc_pid_get_state (pid_t pid, int warn, enum proc_state *state)
}
have_state = 0;
}
have_state = 0;
- while (fgets (buffer, sizeof (buffer), procfile) != NULL)
+ while (fgets (buffer, sizeof (buffer), procfile
.get ()
) != NULL)
if (startswith (buffer, "State:"))
{
have_state = 1;
*state = parse_proc_status_state (buffer + sizeof ("State:") - 1);
break;
}
if (startswith (buffer, "State:"))
{
have_state = 1;
*state = parse_proc_status_state (buffer + sizeof ("State:") - 1);
break;
}
- fclose (procfile);
return have_state;
}
return have_state;
}
@@
-239,20
+238,18
@@
linux_proc_tid_get_name (ptid_t ptid)
static char comm_buf[TASK_COMM_LEN];
char comm_path[100];
static char comm_buf[TASK_COMM_LEN];
char comm_path[100];
- FILE *comm_file;
const char *comm_val;
const char *comm_val;
- pid_t pid = ptid
_get_pid (ptid
);
- pid_t tid = ptid
_lwp_p (ptid) ? ptid_get_lwp (ptid) : ptid_get_pid (ptid
);
+ pid_t pid = ptid
.pid (
);
+ pid_t tid = ptid
.lwp_p () ? ptid.lwp () : ptid.pid (
);
xsnprintf (comm_path, sizeof (comm_path),
"/proc/%ld/task/%ld/comm", (long) pid, (long) tid);
xsnprintf (comm_path, sizeof (comm_path),
"/proc/%ld/task/%ld/comm", (long) pid, (long) tid);
- comm_file = gdb_fopen_cloexec (comm_path, "r");
+
gdb_file_up
comm_file = gdb_fopen_cloexec (comm_path, "r");
if (comm_file == NULL)
return NULL;
if (comm_file == NULL)
return NULL;
- comm_val = fgets (comm_buf, sizeof (comm_buf), comm_file);
- fclose (comm_file);
+ comm_val = fgets (comm_buf, sizeof (comm_buf), comm_file.get ());
if (comm_val != NULL)
{
if (comm_val != NULL)
{
@@
-311,7
+308,7
@@
linux_proc_attach_tgid_threads (pid_t pid,
lwp = strtoul (dp->d_name, NULL, 10);
if (lwp != 0)
{
lwp = strtoul (dp->d_name, NULL, 10);
if (lwp != 0)
{
- ptid_t ptid = ptid_
build
(pid, lwp, 0);
+ ptid_t ptid = ptid_
t
(pid, lwp, 0);
if (attach_lwp (ptid))
new_threads_found = 1;
if (attach_lwp (ptid))
new_threads_found = 1;
@@
-360,3
+357,20
@@
linux_proc_pid_to_exec_file (int pid)
return buf;
}
return buf;
}
+
+/* See linux-procfs.h. */
+
+void
+linux_proc_init_warnings ()
+{
+ static bool warned = false;
+
+ if (warned)
+ return;
+ warned = true;
+
+ struct stat st;
+
+ if (stat ("/proc/self", &st) != 0)
+ warning (_("/proc is not accessible."));
+}
This page took
0.028495 seconds
and
4
git commands to generate.