From 04affae3ef7aa124b6ac0ce4f3a54063b7b4784f Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 2 Dec 2013 22:24:32 +0100 Subject: Record objfile->original_name as an absolute path gdb/ 2013-12-02 Doug Evans Jan Kratochvil * objfiles.c (allocate_objfile): Save original_name as an absolute path. * objfiles.h (struct objfile): Expand comment on original_name. * source.c (openp): Call gdb_abspath. * utils.c (gdb_abspath): New function. * utils.h (gdb_abspath): Declare. gdb/testsuite/ 2013-12-02 Doug Evans * gdb.dwarf/dwp-symlink.c: Fake out gdb to not load debug info at start. * gdb.dwarf/dwp-symlink.exp: Test trying to load dwp when the binary has been specified with a relative path and we have chdir'd before accessing the debug info. --- gdb/utils.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'gdb/utils.c') diff --git a/gdb/utils.c b/gdb/utils.c index 10c73d3..975c432 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3274,6 +3274,32 @@ gdb_realpath_keepfile (const char *filename) return result; } +/* Return PATH in absolute form, performing tilde-expansion if necessary. + PATH cannot be NULL or the empty string. + This does not resolve symlinks however, use gdb_realpath for that. + Space for the result is allocated with malloc. + If the path is already absolute, it is strdup'd. + If there is a problem computing the absolute path, the path is returned + unchanged (still strdup'd). */ + +char * +gdb_abspath (const char *path) +{ + gdb_assert (path != NULL && path[0] != '\0'); + + if (path[0] == '~') + return tilde_expand (path); + + if (IS_ABSOLUTE_PATH (path)) + return xstrdup (path); + + /* Beware the // my son, the Emacs barfs, the botch that catch... */ + return concat (current_directory, + IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]) + ? "" : SLASH_STRING, + path, (char *) NULL); +} + ULONGEST align_up (ULONGEST v, int n) { -- cgit v1.1