forked from Imagelibrary/binutils-gdb
Introduce and use gdb_file_up
This introduces gdb_file_up, a unique pointer holding a FILE*, and then changes some code in gdb to use it. In particular gdb_fopen_cloexec now returns a gdb_file_up. This allow removing some cleanups. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * xml-support.c (xml_fetch_content_from_file): Update. * ui-file.c (stdio_file::open): Update. * tracefile-tfile.c (tfile_start): Update. * remote.c (remote_file_put, remote_file_get): Update. * nat/linux-procfs.c (linux_proc_get_int) (linux_proc_pid_get_state, linux_proc_tid_get_name): Update. * nat/linux-osdata.c (linux_common_core_of_thread): Update. (command_from_pid, commandline_from_pid, linux_xfer_osdata_cpus) (print_sockets, linux_xfer_osdata_shm, linux_xfer_osdata_sem) (linux_xfer_osdata_msg, linux_xfer_osdata_modules): Update. * nat/linux-btrace.c (linux_determine_kernel_start): Update. * linux-nat.c (linux_proc_pending_signals): Update. * dwarf2read.c (write_psymtabs_to_index): Use gdb_file_up. (file_closer): Remove. * compile/compile.c (compile_to_object): Update. * common/filestuff.h (struct gdb_file_deleter): New. (gdb_file_up): New typedef. (gdb_fopen_cloexec): Change return type. * common/filestuff.c (gdb_fopen_cloexec): Return gdb_file_up. * cli/cli-dump.c (fopen_with_cleanup): Remove. (dump_binary_file, restore_binary_file): Update. * auto-load.c (auto_load_objfile_script_1): Update.
This commit is contained in:
@@ -4187,20 +4187,17 @@ void
|
||||
linux_proc_pending_signals (int pid, sigset_t *pending,
|
||||
sigset_t *blocked, sigset_t *ignored)
|
||||
{
|
||||
FILE *procfile;
|
||||
char buffer[PATH_MAX], fname[PATH_MAX];
|
||||
struct cleanup *cleanup;
|
||||
|
||||
sigemptyset (pending);
|
||||
sigemptyset (blocked);
|
||||
sigemptyset (ignored);
|
||||
xsnprintf (fname, sizeof fname, "/proc/%d/status", pid);
|
||||
procfile = gdb_fopen_cloexec (fname, "r");
|
||||
gdb_file_up procfile = gdb_fopen_cloexec (fname, "r");
|
||||
if (procfile == NULL)
|
||||
error (_("Could not open %s"), fname);
|
||||
cleanup = make_cleanup_fclose (procfile);
|
||||
|
||||
while (fgets (buffer, PATH_MAX, procfile) != NULL)
|
||||
while (fgets (buffer, PATH_MAX, procfile.get ()) != NULL)
|
||||
{
|
||||
/* Normal queued signals are on the SigPnd line in the status
|
||||
file. However, 2.6 kernels also have a "shared" pending
|
||||
@@ -4219,8 +4216,6 @@ linux_proc_pending_signals (int pid, sigset_t *pending,
|
||||
else if (startswith (buffer, "SigIgn:\t"))
|
||||
add_line_to_sigset (buffer + 8, ignored);
|
||||
}
|
||||
|
||||
do_cleanups (cleanup);
|
||||
}
|
||||
|
||||
static enum target_xfer_status
|
||||
|
||||
Reference in New Issue
Block a user