aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-06-04 12:34:11 +0000
committerDaniel Jacobowitz <drow@false.org>2007-06-04 12:34:11 +0000
commite1024ff1ddc5fdc00175c3fa2bdfdea412d6687f (patch)
tree2925881313e29580ac614cb86abcf39825df9d57 /gdb/utils.c
parent9dfacfd20b2906ee57cfbca7ee11631c0d82c1d5 (diff)
downloadgdb-e1024ff1ddc5fdc00175c3fa2bdfdea412d6687f.zip
gdb-e1024ff1ddc5fdc00175c3fa2bdfdea412d6687f.tar.gz
gdb-e1024ff1ddc5fdc00175c3fa2bdfdea412d6687f.tar.bz2
* defs.h (ldirname): New prototype.
* dwarf2read.c (read_file_scope): Use DW_AT_name if DW_AT_comp_dir is missing. * utils.c (ldirname): New function. * xml-tdesc.c (file_read_description_xml): Use ldirname.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 4caa272..f5325f6 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3195,3 +3195,31 @@ strtoulst (const char *num, const char **trailer, int base)
else
return result;
}
+
+/* Simple, portable version of dirname that does not modify its
+ argument. */
+
+char *
+ldirname (const char *filename)
+{
+ const char *base = lbasename (filename);
+ char *dirname;
+
+ while (base > filename && IS_DIR_SEPARATOR (base[-1]))
+ --base;
+
+ if (base == filename)
+ return NULL;
+
+ dirname = xmalloc (base - filename + 2);
+ memcpy (dirname, filename, base - filename);
+
+ /* On DOS based file systems, convert "d:foo" to "d:.", so that we
+ create "d:./bar" later instead of the (different) "d:/bar". */
+ if (base - filename == 2 && IS_ABSOLUTE_PATH (base)
+ && !IS_DIR_SEPARATOR (filename[0]))
+ dirname[base++ - filename] = '.';
+
+ dirname[base - filename] = '\0';
+ return dirname;
+}