diff options
author | Tom Tromey <tom@tromey.com> | 2021-12-21 16:24:16 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-12-24 10:24:48 -0700 |
commit | 34b965f7c006e64dbd5546575744daa642d4856f (patch) | |
tree | 395f80417b26c931dfaaa66b1ceff1230cdef1dd | |
parent | b6a08665ffb4a4b41e3761666c7c54655279f2ad (diff) | |
download | binutils-34b965f7c006e64dbd5546575744daa642d4856f.zip binutils-34b965f7c006e64dbd5546575744daa642d4856f.tar.gz binutils-34b965f7c006e64dbd5546575744daa642d4856f.tar.bz2 |
Move gdb_bfd_errmsg to gdb_bfd.c
gdb_bfd.c contains most of gdb's BFD-related utility functions.
However, gdb_bfd_errmsg is in utils.c. It seemed better to me to move
this out of util.[ch] and into the BFD-related file instead.
Tested by rebuilding.
-rw-r--r-- | gdb/gdb_bfd.c | 30 | ||||
-rw-r--r-- | gdb/gdb_bfd.h | 7 | ||||
-rw-r--r-- | gdb/utils.c | 28 | ||||
-rw-r--r-- | gdb/utils.h | 7 |
4 files changed, 37 insertions, 35 deletions
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index c6ff409..3771e59 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -1059,6 +1059,36 @@ gdb_bfd_get_full_section_contents (bfd *abfd, asection *section, section_size); } +#define AMBIGUOUS_MESS1 ".\nMatching formats:" +#define AMBIGUOUS_MESS2 \ + ".\nUse \"set gnutarget format-name\" to specify the format." + +/* See gdb_bfd.h. */ + +std::string +gdb_bfd_errmsg (bfd_error_type error_tag, char **matching) +{ + char **p; + + /* Check if errmsg just need simple return. */ + if (error_tag != bfd_error_file_ambiguously_recognized || matching == NULL) + return bfd_errmsg (error_tag); + + std::string ret (bfd_errmsg (error_tag)); + ret += AMBIGUOUS_MESS1; + + for (p = matching; *p; p++) + { + ret += " "; + ret += *p; + } + ret += AMBIGUOUS_MESS2; + + xfree (matching); + + return ret; +} + /* A callback for htab_traverse that prints a single BFD. */ static int diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index 156c276..62a03e1 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -223,4 +223,11 @@ gdb_bfd_sections (const gdb_bfd_ref_ptr &abfd) return gdb_bfd_section_range (abfd->sections); }; +/* A wrapper for bfd_errmsg to produce a more helpful error message + in the case of bfd_error_file_ambiguously recognized. + MATCHING, if non-NULL, is the corresponding argument to + bfd_check_format_matches, and will be freed. */ + +extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching); + #endif /* GDB_BFD_H */ diff --git a/gdb/utils.c b/gdb/utils.c index 138bd3b..41944f8 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3026,34 +3026,6 @@ gdb_argv::reset (const char *s) m_argv = argv; } -#define AMBIGUOUS_MESS1 ".\nMatching formats:" -#define AMBIGUOUS_MESS2 \ - ".\nUse \"set gnutarget format-name\" to specify the format." - -std::string -gdb_bfd_errmsg (bfd_error_type error_tag, char **matching) -{ - char **p; - - /* Check if errmsg just need simple return. */ - if (error_tag != bfd_error_file_ambiguously_recognized || matching == NULL) - return bfd_errmsg (error_tag); - - std::string ret (bfd_errmsg (error_tag)); - ret += AMBIGUOUS_MESS1; - - for (p = matching; *p; p++) - { - ret += " "; - ret += *p; - } - ret += AMBIGUOUS_MESS2; - - xfree (matching); - - return ret; -} - /* Return ARGS parsed as a valid pid, or throw an error. */ int diff --git a/gdb/utils.h b/gdb/utils.h index 03424e6..fe72078 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -109,13 +109,6 @@ compare_cstrings (const char *str1, const char *str2) return strcmp (str1, str2) < 0; } -/* A wrapper for bfd_errmsg to produce a more helpful error message - in the case of bfd_error_file_ambiguously recognized. - MATCHING, if non-NULL, is the corresponding argument to - bfd_check_format_matches, and will be freed. */ - -extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching); - /* Reset the prompt_for_continue clock. */ void reset_prompt_for_continue_wait_time (void); /* Return the time spent in prompt_for_continue. */ |