diff options
author | Keith Seitz <keiths@redhat.com> | 2017-08-17 13:58:01 -0700 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2017-08-17 13:58:01 -0700 |
commit | b5f28d7abc02ca509e389fa932d725cf111e4b40 (patch) | |
tree | 57a0dc0feaff890630a6ba2c9fab811d56b1f9cf /gdb/nat/linux-procfs.c | |
parent | 2a95a158fae932f758d75a1178a40d4cc4804ff0 (diff) | |
parent | 1a457753cfad05989574c671a221ffce2d5df703 (diff) | |
download | binutils-users/pmuldoon/c++compile.zip binutils-users/pmuldoon/c++compile.tar.gz binutils-users/pmuldoon/c++compile.tar.bz2 |
Update w/HEADusers/pmuldoon/c++compile
Problems:
gdb/compile/compile.c
gdb/cp-support.c
gdb/cp-support.h
gdb/gdbtypes.h
gdb/language.c
gdb/linespec.c
Diffstat (limited to 'gdb/nat/linux-procfs.c')
-rw-r--r-- | gdb/nat/linux-procfs.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c index 5290045..a12f622 100644 --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -29,12 +29,11 @@ static int 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); - status_file = gdb_fopen_cloexec (buf, "r"); + gdb_file_up status_file = gdb_fopen_cloexec (buf, "r"); if (status_file == NULL) { if (warn) @@ -42,14 +41,13 @@ linux_proc_get_int (pid_t lwpid, const char *field, int warn) 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; } - fclose (status_file); return retval; } @@ -128,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) { - FILE *procfile; 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) @@ -142,14 +139,13 @@ linux_proc_pid_get_state (pid_t pid, int warn, enum proc_state *state) } 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; } - fclose (procfile); return have_state; } @@ -242,7 +238,6 @@ linux_proc_tid_get_name (ptid_t ptid) static char comm_buf[TASK_COMM_LEN]; char comm_path[100]; - FILE *comm_file; 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); @@ -250,12 +245,11 @@ linux_proc_tid_get_name (ptid_t ptid) 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; - 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) { |