aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorHui Zhu <teawater@gmail.com>2010-02-05 02:22:39 +0000
committerHui Zhu <teawater@gmail.com>2010-02-05 02:22:39 +0000
commitd18b8b7a0759b26ebc14eab4e95f643e142a24de (patch)
tree3ed27c3dcec9f42a29c79f1da9b5eee881dc0508 /gdb/utils.c
parent6cfaf60bc2581b5ef9028a4157d203adbd2ae9c2 (diff)
downloadgdb-d18b8b7a0759b26ebc14eab4e95f643e142a24de.zip
gdb-d18b8b7a0759b26ebc14eab4e95f643e142a24de.tar.gz
gdb-d18b8b7a0759b26ebc14eab4e95f643e142a24de.tar.bz2
2010-02-05 Hui Zhu <teawater@gmail.com>
* defs.h (gdb_bfd_errmsg): New extern. * exec.c (exec_file_attach): Change bfd_errmsg to gdb_bfd_errmsg. * utils.c (AMBIGUOUS_MESS1): New macro. (AMBIGUOUS_MESS2): New macro. (gdb_bfd_errmsg): New function.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 82a66a1..33c195a 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3608,6 +3608,46 @@ compare_positive_ints (const void *ap, const void *bp)
return * (int *) ap - * (int *) bp;
}
+#define AMBIGUOUS_MESS1 ".\nMatching formats:"
+#define AMBIGUOUS_MESS2 ".\nUse \"set gnutarget format-name\" to specify the format."
+
+const char *
+gdb_bfd_errmsg (bfd_error_type error_tag, char **matching)
+{
+ char *ret, *retp;
+ int ret_len;
+ char **p;
+
+ /* Check if errmsg just need simple return. */
+ if (error_tag != bfd_error_file_ambiguously_recognized || matching == NULL)
+ return bfd_errmsg (error_tag);
+
+ ret_len = strlen (bfd_errmsg (error_tag)) + strlen (AMBIGUOUS_MESS1)
+ + strlen (AMBIGUOUS_MESS2);
+ for (p = matching; *p; p++)
+ ret_len += strlen (*p) + 1;
+ ret = xmalloc (ret_len + 1);
+ retp = ret;
+ make_cleanup (xfree, ret);
+
+ strcpy (retp, bfd_errmsg (error_tag));
+ retp += strlen (retp);
+
+ strcpy (retp, AMBIGUOUS_MESS1);
+ retp += strlen (retp);
+
+ for (p = matching; *p; p++)
+ {
+ sprintf (retp, " %s", *p);
+ retp += strlen (retp);
+ }
+ xfree (matching);
+
+ strcpy (retp, AMBIGUOUS_MESS2);
+
+ return ret;
+}
+
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_utils;