GDB (xrefs)

Macros | Functions | Variables
filestuff.c File Reference
`#include "common-defs.h"`
`#include "filestuff.h"`
`#include "gdb_vecs.h"`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <algorithm>`
`#include <sys/socket.h>`
`#include <sys/resource.h>`
`#include <dirent.h>`

Go to the source code of this file.

## Macros
#define | HAVE_F_GETFD F_GETFD
#define | HAVE_SOCKETS 1
#define | O_CLOEXEC 0
#define | SOCK_CLOEXEC 0

## Functions
static int | fdwalk (int(*func)(void *, int), void *arg)
static int | do_mark_open_fd (void *ignore, int fd)
void | notice_open_fds (void)
void | mark_fd_no_cloexec (int fd)
void | unmark_fd_no_cloexec (int fd)
static int | do_close (void *ignore, int fd)
void | close_most_fds (void)
static void | mark_cloexec (int fd)
static void | maybe_mark_cloexec (int fd)
static void | socket_mark_cloexec (int fd)
int | gdb_open_cloexec (const char *filename, int flags, unsigned long mode)
gdb_file_up | gdb_fopen_cloexec (const char *filename, const char *opentype)
int | gdb_socketpair_cloexec (int domain, int style, int protocol, int filedes[2])
int | gdb_socket_cloexec (int domain, int style, int protocol)
int | gdb_pipe_cloexec (int filedes[2])
static void | do_close_cleanup (void *arg)
struct cleanup * | make_cleanup_close (int fd)

## Variables
static std::vector< int > | open_fds
static int | trust_o_cloexec

## Macro Definition Documentation

## ◆ HAVE_F_GETFD

#define HAVE_F_GETFD F_GETFD

Definition at line 35 of file filestuff.c.

## ◆ HAVE_SOCKETS

#define HAVE_SOCKETS 1

Definition at line 36 of file filestuff.c.

## ◆ O_CLOEXEC

#define O_CLOEXEC 0

Definition at line 44 of file filestuff.c.

Referenced by gdb_fopen_cloexec(), gdb_open_cloexec(), and gdb_pipe_cloexec().

## ◆ SOCK_CLOEXEC

#define SOCK_CLOEXEC 0

Definition at line 48 of file filestuff.c.

Referenced by gdb_socket_cloexec(), gdb_socketpair_cloexec(), and socket_mark_cloexec().

## Function Documentation

## ◆ close_most_fds()

void close_most_fds | ( | void |  | ) |

Definition at line 216 of file filestuff.c.

References do_close(), and fdwalk().

Referenced by fork_inferior(), pipe_open(), and shell_escape().

## ◆ do_close()

static int do_close | ( | void * | ignore,
|  | int | fd
| ) |  |
| static

Definition at line 198 of file filestuff.c.

References open_fds.

Referenced by close_most_fds().

## ◆ do_close_cleanup()

static void do_close_cleanup | ( | void * | arg | ) |
| static

Definition at line 403 of file filestuff.c.

Referenced by make_cleanup_close().

## ◆ do_mark_open_fd()

static int do_mark_open_fd | ( | void * | ignore,
|  | int | fd
| ) |  |
| static

Definition at line 159 of file filestuff.c.

References open_fds.

Referenced by mark_fd_no_cloexec(), and notice_open_fds().

## ◆ fdwalk()

static int fdwalk | ( | int(*)(void *, int) | func,
|  | void * | arg
| ) |  |
| static

Definition at line 65 of file filestuff.c.

References func.

Referenced by close_most_fds(), and notice_open_fds().

## ◆ gdb_fopen_cloexec()

gdb_file_up gdb_fopen_cloexec | ( | const char * | filename,
|  | const char * | opentype
| ) |  |

Definition at line 296 of file filestuff.c.

References maybe_mark_cloexec(), and O_CLOEXEC.

Referenced by auto_load_objfile_script_1(), command_from_pid(), commandline_from_pid(), compile_to_object(), dump_binary_file(), linux_common_core_of_thread(), linux_proc_get_int(), linux_proc_pending_signals(), linux_proc_pid_get_state(), linux_proc_tid_get_name(), linux_xfer_osdata_cpus(), linux_xfer_osdata_modules(), linux_xfer_osdata_msg(), linux_xfer_osdata_sem(), linux_xfer_osdata_shm(), stdio_file::open(), print_sockets(), remote_file_get(), remote_file_put(), restore_binary_file(), tfile_start(), write_psymtabs_to_index(), and xml_fetch_content_from_file().

## ◆ gdb_open_cloexec()

int gdb_open_cloexec | ( | const char * | filename,
|  | int | flags,
|  | unsigned long | mode
| ) |  |

Definition at line 283 of file filestuff.c.

References flags, maybe_mark_cloexec(), and O_CLOEXEC.

Referenced by core_open(), find_and_open_source(), gdb_bfd_open(), hardwire_open(), inf_child_fileio_open(), linux_mntns_access_fs(), linux_mntns_open_cloexec(), linux_proc_xfer_partial(), linux_proc_xfer_spu(), mnsh_handle_open(), open_terminal_stream(), openp(), procfs_xfer_auxv(), remote_fileio_func_open(), solib_find_1(), and tfile_open().

## ◆ gdb_pipe_cloexec()

int gdb_pipe_cloexec | ( | int | filedes[2] | ) |

Definition at line 373 of file filestuff.c.

References _, gdb_assert_not_reached, mark_cloexec(), maybe_mark_cloexec(), and O_CLOEXEC.

Referenced by linux_async_pipe(), serial_event_open(), and tui_initialize_io().

## ◆ gdb_socket_cloexec()

int gdb_socket_cloexec | ( | int | domain,
|  | int | style,
|  | int | protocol
| ) |  |

Definition at line 359 of file filestuff.c.

References SOCK_CLOEXEC, and socket_mark_cloexec().

Referenced by gdb_connect_sync_socket(), and net_open().

## ◆ gdb_socketpair_cloexec()

int gdb_socketpair_cloexec | ( | int | domain,
|  | int | style,
|  | int | protocol,
|  | int | filedes[2]
| ) |  |

Definition at line 338 of file filestuff.c.

References _, gdb_assert_not_reached, SOCK_CLOEXEC, and socket_mark_cloexec().

Referenced by gdb_pipe(), linux_mntns_get_helper(), and pipe_open().

## ◆ make_cleanup_close()

struct cleanup* make_cleanup_close | ( | int | fd | ) |

Definition at line 413 of file filestuff.c.

References do_close_cleanup(), make_cleanup_dtor(), xfree(), and XNEW.

Referenced by forward_search_command(), get_filename_and_charpos(), iterate_over_mappings(), linux_mntns_access_fs(), procfs_open_1(), procfs_pidlist(), and reverse_search_command().

## ◆ mark_cloexec()

static void mark_cloexec | ( | int | fd | ) |
| static

Definition at line 236 of file filestuff.c.

References trust_o_cloexec.

Referenced by gdb_pipe_cloexec(), maybe_mark_cloexec(), and socket_mark_cloexec().

## ◆ mark_fd_no_cloexec()

void mark_fd_no_cloexec | ( | int | fd | ) |

Definition at line 176 of file filestuff.c.

References do_mark_open_fd().

Referenced by darwin_pre_ptrace().

## ◆ maybe_mark_cloexec()

static void maybe_mark_cloexec | ( | int | fd | ) |
| static

Definition at line 259 of file filestuff.c.

References mark_cloexec(), and trust_o_cloexec.

Referenced by gdb_fopen_cloexec(), gdb_open_cloexec(), and gdb_pipe_cloexec().

## ◆ notice_open_fds()

void notice_open_fds | ( | void |  | ) |

Definition at line 168 of file filestuff.c.

References do_mark_open_fd(), and fdwalk().

Referenced by captured_main_1().

## ◆ socket_mark_cloexec()

static void socket_mark_cloexec | ( | int | fd | ) |
| static

Definition at line 270 of file filestuff.c.

References mark_cloexec(), SOCK_CLOEXEC, and trust_o_cloexec.

Referenced by gdb_socket_cloexec(), and gdb_socketpair_cloexec().

## ◆ unmark_fd_no_cloexec()

void unmark_fd_no_cloexec | ( | int | fd | ) |

Definition at line 184 of file filestuff.c.

References _, gdb_assert_not_reached, and open_fds.

Referenced by darwin_ptrace_him().

## Variable Documentation

## ◆ open_fds

std::vector<int> open_fds
| static

Definition at line 153 of file filestuff.c.

Referenced by do_close(), do_mark_open_fd(), and unmark_fd_no_cloexec().

## ◆ trust_o_cloexec

int trust_o_cloexec
| static

Definition at line 230 of file filestuff.c.

Referenced by mark_cloexec(), maybe_mark_cloexec(), and socket_mark_cloexec().