diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/corefile.c | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | gdb-users/simark/clang-format.zip gdb-users/simark/clang-format.tar.gz gdb-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/corefile.c')
-rw-r--r-- | gdb/corefile.c | 107 |
1 files changed, 48 insertions, 59 deletions
diff --git a/gdb/corefile.c b/gdb/corefile.c index 5cb5590..6ab46b3 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -45,12 +45,10 @@ typedef void (*hook_type) (const char *); -hook_type deprecated_exec_file_display_hook; /* The original hook. */ -static hook_type *exec_file_extra_hooks; /* Array of additional +hook_type deprecated_exec_file_display_hook; /* The original hook. */ +static hook_type *exec_file_extra_hooks; /* Array of additional hooks. */ -static int exec_file_hook_count = 0; /* Size of array. */ - - +static int exec_file_hook_count = 0; /* Size of array. */ /* If there are two or more functions that wish to hook into exec_file_command, this function will call all of the hook @@ -91,9 +89,9 @@ specify_exec_file_hook (void (*hook) (const char *)) Yes, it's inefficient to grow it by one each time but since this is hardly ever called it's not a big deal. */ exec_file_hook_count++; - new_array = (hook_type *) - xrealloc (exec_file_extra_hooks, - exec_file_hook_count * sizeof (hook_type)); + new_array + = (hook_type *) xrealloc (exec_file_extra_hooks, + exec_file_hook_count * sizeof (hook_type)); exec_file_extra_hooks = new_array; exec_file_extra_hooks[exec_file_hook_count - 1] = hook; } @@ -115,8 +113,7 @@ reopen_exec_file (void) std::string filename = bfd_get_filename (current_program_space->exec_bfd ()); res = stat (filename.c_str (), &st); - if (res == 0 - && current_program_space->ebfd_mtime + if (res == 0 && current_program_space->ebfd_mtime && current_program_space->ebfd_mtime != st.st_mtime) exec_file_attach (filename.c_str (), 0); else @@ -125,7 +122,7 @@ reopen_exec_file (void) exits. */ bfd_cache_close_all (); } - + /* If we have both a core file and an exec file, print a warning if they don't go together. */ @@ -136,10 +133,10 @@ validate_files (void) { if (!core_file_matches_executable_p (core_bfd, current_program_space->exec_bfd ())) - warning (_("core file may not match specified executable file.")); + warning (_ ("core file may not match specified executable file.")); else if (bfd_get_mtime (current_program_space->exec_bfd ()) > bfd_get_mtime (core_bfd)) - warning (_("exec file is newer than core file.")); + warning (_ ("exec file is newer than core file.")); } } @@ -153,29 +150,27 @@ get_exec_file (int err) if (!err) return NULL; - error (_("No executable file specified.\n\ + error (_ ("No executable file specified.\n\ Use the \"file\" or \"exec-file\" command.")); } - std::string -memory_error_message (enum target_xfer_status err, - struct gdbarch *gdbarch, CORE_ADDR memaddr) +memory_error_message (enum target_xfer_status err, struct gdbarch *gdbarch, + CORE_ADDR memaddr) { switch (err) { case TARGET_XFER_E_IO: /* Actually, address between memaddr and memaddr + len was out of bounds. */ - return string_printf (_("Cannot access memory at address %s"), + return string_printf (_ ("Cannot access memory at address %s"), paddress (gdbarch, memaddr)); case TARGET_XFER_UNAVAILABLE: - return string_printf (_("Memory at address %s unavailable."), + return string_printf (_ ("Memory at address %s unavailable."), paddress (gdbarch, memaddr)); default: internal_error ("unhandled target_xfer_status: %s (%s)", - target_xfer_status_to_string (err), - plongest (err)); + target_xfer_status_to_string (err), plongest (err)); } } @@ -217,10 +212,10 @@ read_memory_object (enum target_object object, CORE_ADDR memaddr, enum target_xfer_status status; ULONGEST xfered_len; - status = target_xfer_partial (current_inferior ()->top_target (), object, - NULL, myaddr + xfered, NULL, - memaddr + xfered, len - xfered, - &xfered_len); + status + = target_xfer_partial (current_inferior ()->top_target (), object, + NULL, myaddr + xfered, NULL, memaddr + xfered, + len - xfered, &xfered_len); if (status != TARGET_XFER_OK) memory_error (status == TARGET_XFER_EOF ? TARGET_XFER_E_IO : status, @@ -260,9 +255,8 @@ read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) if successful. */ int -safe_read_memory_integer (CORE_ADDR memaddr, int len, - enum bfd_endian byte_order, - LONGEST *return_value) +safe_read_memory_integer (CORE_ADDR memaddr, int len, + enum bfd_endian byte_order, LONGEST *return_value) { gdb_byte buf[sizeof (LONGEST)]; @@ -292,8 +286,7 @@ safe_read_memory_unsigned_integer (CORE_ADDR memaddr, int len, } LONGEST -read_memory_integer (CORE_ADDR memaddr, int len, - enum bfd_endian byte_order) +read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order) { gdb_byte buf[sizeof (LONGEST)]; @@ -312,8 +305,7 @@ read_memory_unsigned_integer (CORE_ADDR memaddr, int len, } LONGEST -read_code_integer (CORE_ADDR memaddr, int len, - enum bfd_endian byte_order) +read_code_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order) { gdb_byte buf[sizeof (LONGEST)]; @@ -343,8 +335,7 @@ read_memory_typed_address (CORE_ADDR addr, struct type *type) /* See gdbcore.h. */ void -write_memory (CORE_ADDR memaddr, - const bfd_byte *myaddr, ssize_t len) +write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len) { int status; @@ -360,15 +351,15 @@ write_memory_with_notification (CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len) { write_memory (memaddr, myaddr, len); - gdb::observers::memory_changed.notify (current_inferior (), memaddr, len, myaddr); + gdb::observers::memory_changed.notify (current_inferior (), memaddr, len, + myaddr); } /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */ void -write_memory_unsigned_integer (CORE_ADDR addr, int len, - enum bfd_endian byte_order, - ULONGEST value) +write_memory_unsigned_integer (CORE_ADDR addr, int len, + enum bfd_endian byte_order, ULONGEST value) { gdb_byte *buf = (gdb_byte *) alloca (len); @@ -379,29 +370,27 @@ write_memory_unsigned_integer (CORE_ADDR addr, int len, /* Store VALUE at ADDR in the inferior as a LEN-byte signed integer. */ void -write_memory_signed_integer (CORE_ADDR addr, int len, - enum bfd_endian byte_order, - LONGEST value) +write_memory_signed_integer (CORE_ADDR addr, int len, + enum bfd_endian byte_order, LONGEST value) { gdb_byte *buf = (gdb_byte *) alloca (len); store_signed_integer (buf, len, byte_order, value); write_memory (addr, buf, len); } - + /* The current default bfd target. Points to storage allocated for gnutarget_string. */ const char *gnutarget; /* Same thing, except it is "auto" not NULL for the default case. */ static std::string gnutarget_string; + static void show_gnutarget_string (struct ui_file *file, int from_tty, - struct cmd_list_element *c, - const char *value) + struct cmd_list_element *c, const char *value) { - gdb_printf (file, - _("The current BFD target is \"%s\".\n"), value); + gdb_printf (file, _ ("The current BFD target is \"%s\".\n"), value); } static void @@ -423,8 +412,8 @@ set_gnutarget_command (const char *ignore, int from_tty, static void complete_set_gnutarget (struct cmd_list_element *cmd, - completion_tracker &tracker, - const char *text, const char *word) + completion_tracker &tracker, const char *text, + const char *word) { static const char **bfd_targets; @@ -453,27 +442,27 @@ set_gnutarget (const char *newtarget) } void _initialize_core (); + void _initialize_core () { cmd_list_element *core_file_cmd - = add_cmd ("core-file", class_files, core_file_command, _("\ + = add_cmd ("core-file", class_files, core_file_command, _ ("\ Use FILE as core dump for examining memory and registers.\n\ Usage: core-file FILE\n\ No arg means have no core file. This command has been superseded by the\n\ -`target core' and `detach' commands."), &cmdlist); +`target core' and `detach' commands."), + &cmdlist); set_cmd_completer (core_file_cmd, filename_completer); - - set_show_commands set_show_gnutarget - = add_setshow_string_noescape_cmd ("gnutarget", class_files, - &gnutarget_string, _("\ -Set the current BFD target."), _("\ -Show the current BFD target."), _("\ + set_show_commands set_show_gnutarget = add_setshow_string_noescape_cmd ( + "gnutarget", class_files, &gnutarget_string, _ ("\ +Set the current BFD target."), + _ ("\ +Show the current BFD target."), + _ ("\ Use `set gnutarget auto' to specify automatic detection."), - set_gnutarget_command, - show_gnutarget_string, - &setlist, &showlist); + set_gnutarget_command, show_gnutarget_string, &setlist, &showlist); set_cmd_completer (set_show_gnutarget.set, complete_set_gnutarget); add_alias_cmd ("g", set_show_gnutarget.set, class_files, 1, &setlist); |