* [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
[not found] <1422994793-9861-1-git-send-email-antoine.tremblay@ericsson.com>
@ 2015-02-03 20:21 ` Antoine Tremblay
2015-02-03 20:29 ` Antoine Tremblay
2015-03-24 15:11 ` Antoine Tremblay
0 siblings, 2 replies; 9+ messages in thread
From: Antoine Tremblay @ 2015-02-03 20:21 UTC (permalink / raw)
To: gdb-patches; +Cc: Antoine Tremblay
For example if you have an executable with debug symbols with a path that
looks like /build-server/program/build/../file.c and try to insert a
breakpoint by using the CLI "b /build-server/program/file.c" gdb would fail
to find that file.
This patch makes gdb try to open a source file with its canonical path
even if parts of that path do not exist.
In this example when trying to open /build-server/program/build/../file.c
we search for /build-server/program/file.c. even if the "build" directory
is not present on the system.
Also, since in general we do not need the full uncanonicalised path
to be present on the system and that we validate that the file exist
after a call to gdb_realpath with a subsequent call to open,
gdb_realpath was changed to accept that parts of the path or the whole
path be missing from the system.
This is done using canonicalize_filename_mode (filename, CAN_MISSING);
To make this behavior easy to adapt to multiple situations inside gdb
in the future, a new option to openp was added :
OPF_TRY_REALPATH = 0x08
This will try the canonicalized path when using the openp function.
As used in find_and_open_source to allow this feature.
Also added a small test case to verify the issue.
gdb/ChangeLog:
PR breakpoints/17497
* defs.h: Add OPF_TRY_REALPATH.
* source.c (openp): Add OPF_TRY_REALPATH option.
(find_and_open_source): Use OPF_TRY_REALPATH option to find a file.
* utils.c (gdb_realpath): Change canonicalize_file_name
to canonicalize_filename_mode with CAN_MISSING flag.
gdb/testsuite/ChangeLog:
PR breakpoints/17497
* gdb.base/Makefile.in: Add tryrealpath test.
* gdb.base/break-canonical-path.c: New test.
* gdb.base/break-canonical-path.exp: New file.
---
gdb/defs.h | 7 +-
gdb/source.c | 37 ++++++++--
gdb/testsuite/gdb.base/Makefile.in | 4 +-
gdb/testsuite/gdb.base/break-canonical-path.c | 22 ++++++
gdb/testsuite/gdb.base/break-canonical-path.exp | 83 +++++++++++++++++++++++
gdb/utils.c | 3 +-
6 files changed, 146 insertions(+), 10 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.c
create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.exp
diff --git a/gdb/defs.h b/gdb/defs.h
index a1cd45f..fac9b2c 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -310,9 +310,10 @@ extern const char *pc_prefix (CORE_ADDR);
/* From source.c */
/* See openp function definition for their description. */
-#define OPF_TRY_CWD_FIRST 0x01
-#define OPF_SEARCH_IN_PATH 0x02
-#define OPF_RETURN_REALPATH 0x04
+#define OPF_TRY_CWD_FIRST 0x01
+#define OPF_SEARCH_IN_PATH 0x02
+#define OPF_RETURN_REALPATH 0x04
+#define OPF_TRY_REALPATH 0x08
extern int openp (const char *, int, const char *, int, char **);
diff --git a/gdb/source.c b/gdb/source.c
index 574d9fa..1a3fbf9 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -769,8 +769,18 @@ openp (const char *path, int opts, const char *string,
if (is_regular_file (string))
{
- filename = alloca (strlen (string) + 1);
- strcpy (filename, string);
+ if (opts & OPF_TRY_REALPATH)
+ {
+ char *real_path = gdb_realpath (string);
+ filename = alloca (strlen (real_path) + 1);
+ strcpy (filename, real_path);
+ xfree (real_path);
+ }
+ else
+ {
+ filename = alloca (strlen (string) + 1);
+ strcpy (filename, string);
+ }
fd = gdb_open_cloexec (filename, mode, 0);
if (fd >= 0)
goto done;
@@ -867,6 +877,25 @@ openp (const char *path, int opts, const char *string,
strcat (filename + len, SLASH_STRING);
strcat (filename, string);
+ /* Try the canonical path. */
+ if (opts & OPF_TRY_REALPATH)
+ {
+ char *real_path;
+ int newlen;
+
+ real_path = gdb_realpath (filename);
+
+ /* First, realloc the filename buffer if too short. */
+ newlen = len + strlen (real_path) + 1;
+ if (newlen > alloclen)
+ {
+ alloclen = newlen;
+ filename = alloca (alloclen);
+ }
+ strcpy (filename, real_path);
+ xfree (real_path);
+ }
+
if (is_regular_file (filename))
{
fd = gdb_open_cloexec (filename, mode, 0);
@@ -1083,8 +1112,8 @@ find_and_open_source (const char *filename,
}
}
- result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
- OPEN_MODE, fullname);
+ result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH |
+ OPF_TRY_REALPATH, filename, OPEN_MODE, fullname);
if (result < 0)
{
/* Didn't work. Try using just the basename. */
diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
index dda3169..1c23bbd 100644
--- a/gdb/testsuite/gdb.base/Makefile.in
+++ b/gdb/testsuite/gdb.base/Makefile.in
@@ -4,8 +4,8 @@ srcdir = @srcdir@
EXECUTABLES = a2-run advance all-types annota1 annota1-watch_thread_num \
annota3 anon args arrayidx async attach attach-pie-misread \
attach2 auxv bang\! bfp-test bigcore bitfields bitfields2 \
- break break-always break-entry break-interp-test breako2 \
- breakpoint-shadow break-on-linker-gcd-function \
+ break break-always break-canonical-path break-entry break-interp-test \
+ breako2 breakpoint-shadow break-on-linker-gcd-function \
call-ar-st call-rt-st call-sc-t* call-signals \
call-strs callexit callfuncs callfwmall charset checkpoint \
chng-syms code_elim1 code_elim2 commands compiler completion complex \
diff --git a/gdb/testsuite/gdb.base/break-canonical-path.c b/gdb/testsuite/gdb.base/break-canonical-path.c
new file mode 100644
index 0000000..7e362b2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/break-canonical-path.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2015 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/break-canonical-path.exp b/gdb/testsuite/gdb.base/break-canonical-path.exp
new file mode 100644
index 0000000..511acaa
--- /dev/null
+++ b/gdb/testsuite/gdb.base/break-canonical-path.exp
@@ -0,0 +1,83 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file tests if we can set a breakpoint provided our path is the
+# canonicalized path of a longer path with some parts that are not
+# present on the fs.
+# See breakpoints/17497 for more information
+
+# main directory for compilation
+set canonical_tmp_dir "break-canonical-path-tmp"
+# this directory will be deleted before putting the breakpoint
+set canonical_relative_dir "tmp"
+set canonical_srcfile_basename "break-canonical-path.c"
+
+standard_testfile $canonical_tmp_dir/$canonical_relative_dir/../$canonical_srcfile_basename
+
+proc canonical_cleanup {rmsrcfile rmreldir rmtmpdir} {
+ global subdir
+ global canonical_tmp_dir
+ global canonical_relative_dir
+ global canonical_srcfile_basename
+
+ if { $rmsrcfile && [catch { file delete $subdir/$canonical_tmp_dir/$canonical_srcfile_basename }] } {
+ print "file delete $subdir/$canonical_tmp_dir/$canonical_srcfile_basename failed"
+ }
+ if { $rmreldir && [catch { file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir }] } {
+ print "file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
+ }
+ if { $rmtmpdir && [catch { file delete $subdir/$canonical_tmp_dir }] } {
+ print "file delete $subdir/$canonical_tmp_di failed"
+ }
+}
+
+if [is_remote host] {
+ unsupported "Compiling on a remote host does not support a filename with directory."
+ return 0
+}
+
+if [catch { file mkdir "$subdir/$canonical_tmp_dir/$canonical_relative_dir" }] {
+ untested "file mkdir $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
+ canonical_cleanup false true true
+ return 0
+}
+
+if [catch { file copy $srcdir/$subdir/$canonical_srcfile_basename $subdir/$canonical_tmp_dir }] {
+ untested "file copy $srcdir/$subdir/$srcfile_basename $subdir/$canonical_tmp_dir failed"
+ canonical_cleanup false true true
+ return 0
+}
+
+#compile with the to be deleted directory so that it is in the debug info
+set err [gdb_compile "$subdir/$srcfile" $binfile executable {debug}]
+if { $err != "" } {
+ untested "${srcfile} compilation failed"
+ canonical_cleanup true true true
+ return -1
+}
+
+#remove the directory so that we can test after that we can break even if it's not there
+#using the canonicalized version of the path
+if [catch { file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir }] {
+ untested "rmdir $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
+ canonical_cleanup true true true
+ return 0
+}
+
+clean_restart ${testfile}
+
+gdb_breakpoint $subdir/$canonical_tmp_dir/$canonical_srcfile_basename:[gdb_get_line_number "main" $srcdir/$subdir/$canonical_srcfile_basename] {message}
+
+canonical_cleanup true true true
diff --git a/gdb/utils.c b/gdb/utils.c
index 909476b..c97ead3 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -68,6 +68,7 @@
#include "gdb_usleep.h"
#include "interps.h"
#include "gdb_regex.h"
+#include "canonicalize.h"
#if !HAVE_DECL_MALLOC
extern PTR malloc (); /* ARI: PTR */
@@ -2889,7 +2890,7 @@ gdb_realpath (const char *filename)
}
#else
{
- char *rp = canonicalize_file_name (filename);
+ char *rp = canonicalize_filename_mode (filename, CAN_MISSING);
if (rp != NULL)
return rp;
--
1.7.9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-02-03 20:21 ` [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists Antoine Tremblay
@ 2015-02-03 20:29 ` Antoine Tremblay
2015-02-11 13:27 ` Antoine Tremblay
2015-03-27 12:24 ` Pedro Alves
2015-03-24 15:11 ` Antoine Tremblay
1 sibling, 2 replies; 9+ messages in thread
From: Antoine Tremblay @ 2015-02-03 20:29 UTC (permalink / raw)
To: gdb-patches
Hi,
Unfortunately the 1/2 patch of this patchset failed because it's
about 1M , and mailman is only accepting < 400k emails...
The patch is large since I'm replacing canonicalize-lgpl from
binutils with canonicalize and that triggers a few dependencies..
Any ideas on how I should proceed ?
I could send a patch with only the change to the update-gnulib.sh maybe ?
Regards,
Antoine Tremblay
On 02/03/2015 03:19 PM, Antoine Tremblay wrote:
> For example if you have an executable with debug symbols with a path that
> looks like /build-server/program/build/../file.c and try to insert a
> breakpoint by using the CLI "b /build-server/program/file.c" gdb would fail
> to find that file.
>
> This patch makes gdb try to open a source file with its canonical path
> even if parts of that path do not exist.
>
> In this example when trying to open /build-server/program/build/../file.c
> we search for /build-server/program/file.c. even if the "build" directory
> is not present on the system.
>
> Also, since in general we do not need the full uncanonicalised path
> to be present on the system and that we validate that the file exist
> after a call to gdb_realpath with a subsequent call to open,
> gdb_realpath was changed to accept that parts of the path or the whole
> path be missing from the system.
>
> This is done using canonicalize_filename_mode (filename, CAN_MISSING);
>
> To make this behavior easy to adapt to multiple situations inside gdb
> in the future, a new option to openp was added :
>
> OPF_TRY_REALPATH = 0x08
>
> This will try the canonicalized path when using the openp function.
> As used in find_and_open_source to allow this feature.
>
> Also added a small test case to verify the issue.
>
> gdb/ChangeLog:
>
> PR breakpoints/17497
> * defs.h: Add OPF_TRY_REALPATH.
> * source.c (openp): Add OPF_TRY_REALPATH option.
> (find_and_open_source): Use OPF_TRY_REALPATH option to find a file.
> * utils.c (gdb_realpath): Change canonicalize_file_name
> to canonicalize_filename_mode with CAN_MISSING flag.
>
> gdb/testsuite/ChangeLog:
>
> PR breakpoints/17497
> * gdb.base/Makefile.in: Add tryrealpath test.
> * gdb.base/break-canonical-path.c: New test.
> * gdb.base/break-canonical-path.exp: New file.
> ---
> gdb/defs.h | 7 +-
> gdb/source.c | 37 ++++++++--
> gdb/testsuite/gdb.base/Makefile.in | 4 +-
> gdb/testsuite/gdb.base/break-canonical-path.c | 22 ++++++
> gdb/testsuite/gdb.base/break-canonical-path.exp | 83 +++++++++++++++++++++++
> gdb/utils.c | 3 +-
> 6 files changed, 146 insertions(+), 10 deletions(-)
> create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.c
> create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.exp
>
> diff --git a/gdb/defs.h b/gdb/defs.h
> index a1cd45f..fac9b2c 100644
> --- a/gdb/defs.h
> +++ b/gdb/defs.h
> @@ -310,9 +310,10 @@ extern const char *pc_prefix (CORE_ADDR);
> /* From source.c */
>
> /* See openp function definition for their description. */
> -#define OPF_TRY_CWD_FIRST 0x01
> -#define OPF_SEARCH_IN_PATH 0x02
> -#define OPF_RETURN_REALPATH 0x04
> +#define OPF_TRY_CWD_FIRST 0x01
> +#define OPF_SEARCH_IN_PATH 0x02
> +#define OPF_RETURN_REALPATH 0x04
> +#define OPF_TRY_REALPATH 0x08
>
> extern int openp (const char *, int, const char *, int, char **);
>
> diff --git a/gdb/source.c b/gdb/source.c
> index 574d9fa..1a3fbf9 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -769,8 +769,18 @@ openp (const char *path, int opts, const char *string,
>
> if (is_regular_file (string))
> {
> - filename = alloca (strlen (string) + 1);
> - strcpy (filename, string);
> + if (opts & OPF_TRY_REALPATH)
> + {
> + char *real_path = gdb_realpath (string);
> + filename = alloca (strlen (real_path) + 1);
> + strcpy (filename, real_path);
> + xfree (real_path);
> + }
> + else
> + {
> + filename = alloca (strlen (string) + 1);
> + strcpy (filename, string);
> + }
> fd = gdb_open_cloexec (filename, mode, 0);
> if (fd >= 0)
> goto done;
> @@ -867,6 +877,25 @@ openp (const char *path, int opts, const char *string,
> strcat (filename + len, SLASH_STRING);
> strcat (filename, string);
>
> + /* Try the canonical path. */
> + if (opts & OPF_TRY_REALPATH)
> + {
> + char *real_path;
> + int newlen;
> +
> + real_path = gdb_realpath (filename);
> +
> + /* First, realloc the filename buffer if too short. */
> + newlen = len + strlen (real_path) + 1;
> + if (newlen > alloclen)
> + {
> + alloclen = newlen;
> + filename = alloca (alloclen);
> + }
> + strcpy (filename, real_path);
> + xfree (real_path);
> + }
> +
> if (is_regular_file (filename))
> {
> fd = gdb_open_cloexec (filename, mode, 0);
> @@ -1083,8 +1112,8 @@ find_and_open_source (const char *filename,
> }
> }
>
> - result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
> - OPEN_MODE, fullname);
> + result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH |
> + OPF_TRY_REALPATH, filename, OPEN_MODE, fullname);
> if (result < 0)
> {
> /* Didn't work. Try using just the basename. */
> diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
> index dda3169..1c23bbd 100644
> --- a/gdb/testsuite/gdb.base/Makefile.in
> +++ b/gdb/testsuite/gdb.base/Makefile.in
> @@ -4,8 +4,8 @@ srcdir = @srcdir@
> EXECUTABLES = a2-run advance all-types annota1 annota1-watch_thread_num \
> annota3 anon args arrayidx async attach attach-pie-misread \
> attach2 auxv bang\! bfp-test bigcore bitfields bitfields2 \
> - break break-always break-entry break-interp-test breako2 \
> - breakpoint-shadow break-on-linker-gcd-function \
> + break break-always break-canonical-path break-entry break-interp-test \
> + breako2 breakpoint-shadow break-on-linker-gcd-function \
> call-ar-st call-rt-st call-sc-t* call-signals \
> call-strs callexit callfuncs callfwmall charset checkpoint \
> chng-syms code_elim1 code_elim2 commands compiler completion complex \
> diff --git a/gdb/testsuite/gdb.base/break-canonical-path.c b/gdb/testsuite/gdb.base/break-canonical-path.c
> new file mode 100644
> index 0000000..7e362b2
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/break-canonical-path.c
> @@ -0,0 +1,22 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2015 Free Software Foundation, Inc.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +int
> +main (void)
> +{
> + return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/break-canonical-path.exp b/gdb/testsuite/gdb.base/break-canonical-path.exp
> new file mode 100644
> index 0000000..511acaa
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/break-canonical-path.exp
> @@ -0,0 +1,83 @@
> +# Copyright (C) 2015 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +# This file tests if we can set a breakpoint provided our path is the
> +# canonicalized path of a longer path with some parts that are not
> +# present on the fs.
> +# See breakpoints/17497 for more information
> +
> +# main directory for compilation
> +set canonical_tmp_dir "break-canonical-path-tmp"
> +# this directory will be deleted before putting the breakpoint
> +set canonical_relative_dir "tmp"
> +set canonical_srcfile_basename "break-canonical-path.c"
> +
> +standard_testfile $canonical_tmp_dir/$canonical_relative_dir/../$canonical_srcfile_basename
> +
> +proc canonical_cleanup {rmsrcfile rmreldir rmtmpdir} {
> + global subdir
> + global canonical_tmp_dir
> + global canonical_relative_dir
> + global canonical_srcfile_basename
> +
> + if { $rmsrcfile && [catch { file delete $subdir/$canonical_tmp_dir/$canonical_srcfile_basename }] } {
> + print "file delete $subdir/$canonical_tmp_dir/$canonical_srcfile_basename failed"
> + }
> + if { $rmreldir && [catch { file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir }] } {
> + print "file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
> + }
> + if { $rmtmpdir && [catch { file delete $subdir/$canonical_tmp_dir }] } {
> + print "file delete $subdir/$canonical_tmp_di failed"
> + }
> +}
> +
> +if [is_remote host] {
> + unsupported "Compiling on a remote host does not support a filename with directory."
> + return 0
> +}
> +
> +if [catch { file mkdir "$subdir/$canonical_tmp_dir/$canonical_relative_dir" }] {
> + untested "file mkdir $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
> + canonical_cleanup false true true
> + return 0
> +}
> +
> +if [catch { file copy $srcdir/$subdir/$canonical_srcfile_basename $subdir/$canonical_tmp_dir }] {
> + untested "file copy $srcdir/$subdir/$srcfile_basename $subdir/$canonical_tmp_dir failed"
> + canonical_cleanup false true true
> + return 0
> +}
> +
> +#compile with the to be deleted directory so that it is in the debug info
> +set err [gdb_compile "$subdir/$srcfile" $binfile executable {debug}]
> +if { $err != "" } {
> + untested "${srcfile} compilation failed"
> + canonical_cleanup true true true
> + return -1
> +}
> +
> +#remove the directory so that we can test after that we can break even if it's not there
> +#using the canonicalized version of the path
> +if [catch { file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir }] {
> + untested "rmdir $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
> + canonical_cleanup true true true
> + return 0
> +}
> +
> +clean_restart ${testfile}
> +
> +gdb_breakpoint $subdir/$canonical_tmp_dir/$canonical_srcfile_basename:[gdb_get_line_number "main" $srcdir/$subdir/$canonical_srcfile_basename] {message}
> +
> +canonical_cleanup true true true
> diff --git a/gdb/utils.c b/gdb/utils.c
> index 909476b..c97ead3 100644
> --- a/gdb/utils.c
> +++ b/gdb/utils.c
> @@ -68,6 +68,7 @@
> #include "gdb_usleep.h"
> #include "interps.h"
> #include "gdb_regex.h"
> +#include "canonicalize.h"
>
> #if !HAVE_DECL_MALLOC
> extern PTR malloc (); /* ARI: PTR */
> @@ -2889,7 +2890,7 @@ gdb_realpath (const char *filename)
> }
> #else
> {
> - char *rp = canonicalize_file_name (filename);
> + char *rp = canonicalize_filename_mode (filename, CAN_MISSING);
>
> if (rp != NULL)
> return rp;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-02-03 20:29 ` Antoine Tremblay
@ 2015-02-11 13:27 ` Antoine Tremblay
2015-03-27 12:24 ` Pedro Alves
1 sibling, 0 replies; 9+ messages in thread
From: Antoine Tremblay @ 2015-02-11 13:27 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 12607 bytes --]
Hi,
I have attached the 1/2 patch of this patchset as a bzip2 compressed
patch so can it can be posted for review, hope it's ok...
Regards,
Antoine Tremblay
On 02/03/2015 03:28 PM, Antoine Tremblay wrote:
> Hi,
> Unfortunately the 1/2 patch of this patchset failed because it's
> about 1M , and mailman is only accepting < 400k emails...
>
> The patch is large since I'm replacing canonicalize-lgpl from
> binutils with canonicalize and that triggers a few dependencies..
>
> Any ideas on how I should proceed ?
>
> I could send a patch with only the change to the update-gnulib.sh
> maybe ?
>
> Regards,
>
> Antoine Tremblay
>
>
> On 02/03/2015 03:19 PM, Antoine Tremblay wrote:
>> For example if you have an executable with debug symbols with a path
>> that
>> looks like /build-server/program/build/../file.c and try to insert a
>> breakpoint by using the CLI "b /build-server/program/file.c" gdb
>> would fail
>> to find that file.
>>
>> This patch makes gdb try to open a source file with its canonical path
>> even if parts of that path do not exist.
>>
>> In this example when trying to open
>> /build-server/program/build/../file.c
>> we search for /build-server/program/file.c. even if the "build"
>> directory
>> is not present on the system.
>>
>> Also, since in general we do not need the full uncanonicalised path
>> to be present on the system and that we validate that the file exist
>> after a call to gdb_realpath with a subsequent call to open,
>> gdb_realpath was changed to accept that parts of the path or the whole
>> path be missing from the system.
>>
>> This is done using canonicalize_filename_mode (filename, CAN_MISSING);
>>
>> To make this behavior easy to adapt to multiple situations inside gdb
>> in the future, a new option to openp was added :
>>
>> OPF_TRY_REALPATH = 0x08
>>
>> This will try the canonicalized path when using the openp function.
>> As used in find_and_open_source to allow this feature.
>>
>> Also added a small test case to verify the issue.
>>
>> gdb/ChangeLog:
>>
>> PR breakpoints/17497
>> * defs.h: Add OPF_TRY_REALPATH.
>> * source.c (openp): Add OPF_TRY_REALPATH option.
>> (find_and_open_source): Use OPF_TRY_REALPATH option to find a file.
>> * utils.c (gdb_realpath): Change canonicalize_file_name
>> to canonicalize_filename_mode with CAN_MISSING flag.
>>
>> gdb/testsuite/ChangeLog:
>>
>> PR breakpoints/17497
>> * gdb.base/Makefile.in: Add tryrealpath test.
>> * gdb.base/break-canonical-path.c: New test.
>> * gdb.base/break-canonical-path.exp: New file.
>> ---
>> gdb/defs.h | 7 +-
>> gdb/source.c | 37 ++++++++--
>> gdb/testsuite/gdb.base/Makefile.in | 4 +-
>> gdb/testsuite/gdb.base/break-canonical-path.c | 22 ++++++
>> gdb/testsuite/gdb.base/break-canonical-path.exp | 83
>> +++++++++++++++++++++++
>> gdb/utils.c | 3 +-
>> 6 files changed, 146 insertions(+), 10 deletions(-)
>> create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.c
>> create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.exp
>>
>> diff --git a/gdb/defs.h b/gdb/defs.h
>> index a1cd45f..fac9b2c 100644
>> --- a/gdb/defs.h
>> +++ b/gdb/defs.h
>> @@ -310,9 +310,10 @@ extern const char *pc_prefix (CORE_ADDR);
>> /* From source.c */
>> /* See openp function definition for their description. */
>> -#define OPF_TRY_CWD_FIRST 0x01
>> -#define OPF_SEARCH_IN_PATH 0x02
>> -#define OPF_RETURN_REALPATH 0x04
>> +#define OPF_TRY_CWD_FIRST 0x01
>> +#define OPF_SEARCH_IN_PATH 0x02
>> +#define OPF_RETURN_REALPATH 0x04
>> +#define OPF_TRY_REALPATH 0x08
>> extern int openp (const char *, int, const char *, int, char **);
>> diff --git a/gdb/source.c b/gdb/source.c
>> index 574d9fa..1a3fbf9 100644
>> --- a/gdb/source.c
>> +++ b/gdb/source.c
>> @@ -769,8 +769,18 @@ openp (const char *path, int opts, const char
>> *string,
>> if (is_regular_file (string))
>> {
>> - filename = alloca (strlen (string) + 1);
>> - strcpy (filename, string);
>> + if (opts & OPF_TRY_REALPATH)
>> + {
>> + char *real_path = gdb_realpath (string);
>> + filename = alloca (strlen (real_path) + 1);
>> + strcpy (filename, real_path);
>> + xfree (real_path);
>> + }
>> + else
>> + {
>> + filename = alloca (strlen (string) + 1);
>> + strcpy (filename, string);
>> + }
>> fd = gdb_open_cloexec (filename, mode, 0);
>> if (fd >= 0)
>> goto done;
>> @@ -867,6 +877,25 @@ openp (const char *path, int opts, const char
>> *string,
>> strcat (filename + len, SLASH_STRING);
>> strcat (filename, string);
>> + /* Try the canonical path. */
>> + if (opts & OPF_TRY_REALPATH)
>> + {
>> + char *real_path;
>> + int newlen;
>> +
>> + real_path = gdb_realpath (filename);
>> +
>> + /* First, realloc the filename buffer if too short. */
>> + newlen = len + strlen (real_path) + 1;
>> + if (newlen > alloclen)
>> + {
>> + alloclen = newlen;
>> + filename = alloca (alloclen);
>> + }
>> + strcpy (filename, real_path);
>> + xfree (real_path);
>> + }
>> +
>> if (is_regular_file (filename))
>> {
>> fd = gdb_open_cloexec (filename, mode, 0);
>> @@ -1083,8 +1112,8 @@ find_and_open_source (const char *filename,
>> }
>> }
>> - result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
>> filename,
>> - OPEN_MODE, fullname);
>> + result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH |
>> + OPF_TRY_REALPATH, filename, OPEN_MODE, fullname);
>> if (result < 0)
>> {
>> /* Didn't work. Try using just the basename. */
>> diff --git a/gdb/testsuite/gdb.base/Makefile.in
>> b/gdb/testsuite/gdb.base/Makefile.in
>> index dda3169..1c23bbd 100644
>> --- a/gdb/testsuite/gdb.base/Makefile.in
>> +++ b/gdb/testsuite/gdb.base/Makefile.in
>> @@ -4,8 +4,8 @@ srcdir = @srcdir@
>> EXECUTABLES = a2-run advance all-types annota1
>> annota1-watch_thread_num \
>> annota3 anon args arrayidx async attach attach-pie-misread \
>> attach2 auxv bang\! bfp-test bigcore bitfields bitfields2 \
>> - break break-always break-entry break-interp-test breako2 \
>> - breakpoint-shadow break-on-linker-gcd-function \
>> + break break-always break-canonical-path break-entry
>> break-interp-test \
>> + breako2 breakpoint-shadow break-on-linker-gcd-function \
>> call-ar-st call-rt-st call-sc-t* call-signals \
>> call-strs callexit callfuncs callfwmall charset checkpoint \
>> chng-syms code_elim1 code_elim2 commands compiler completion
>> complex \
>> diff --git a/gdb/testsuite/gdb.base/break-canonical-path.c
>> b/gdb/testsuite/gdb.base/break-canonical-path.c
>> new file mode 100644
>> index 0000000..7e362b2
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.base/break-canonical-path.c
>> @@ -0,0 +1,22 @@
>> +/* This testcase is part of GDB, the GNU debugger.
>> +
>> + Copyright 2015 Free Software Foundation, Inc.
>> +
>> + This program is free software; you can redistribute it and/or modify
>> + it under the terms of the GNU General Public License as published by
>> + the Free Software Foundation; either version 3 of the License, or
>> + (at your option) any later version.
>> +
>> + This program is distributed in the hope that it will be useful,
>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + GNU General Public License for more details.
>> +
>> + You should have received a copy of the GNU General Public License
>> + along with this program. If not, see
>> <http://www.gnu.org/licenses/>. */
>> +
>> +int
>> +main (void)
>> +{
>> + return 0;
>> +}
>> diff --git a/gdb/testsuite/gdb.base/break-canonical-path.exp
>> b/gdb/testsuite/gdb.base/break-canonical-path.exp
>> new file mode 100644
>> index 0000000..511acaa
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.base/break-canonical-path.exp
>> @@ -0,0 +1,83 @@
>> +# Copyright (C) 2015 Free Software Foundation, Inc.
>> +
>> +# This program is free software; you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation; either version 3 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> +# GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
>> +
>> +# This file tests if we can set a breakpoint provided our path is the
>> +# canonicalized path of a longer path with some parts that are not
>> +# present on the fs.
>> +# See breakpoints/17497 for more information
>> +
>> +# main directory for compilation
>> +set canonical_tmp_dir "break-canonical-path-tmp"
>> +# this directory will be deleted before putting the breakpoint
>> +set canonical_relative_dir "tmp"
>> +set canonical_srcfile_basename "break-canonical-path.c"
>> +
>> +standard_testfile
>> $canonical_tmp_dir/$canonical_relative_dir/../$canonical_srcfile_basename
>> +
>> +proc canonical_cleanup {rmsrcfile rmreldir rmtmpdir} {
>> + global subdir
>> + global canonical_tmp_dir
>> + global canonical_relative_dir
>> + global canonical_srcfile_basename
>> +
>> + if { $rmsrcfile && [catch { file delete
>> $subdir/$canonical_tmp_dir/$canonical_srcfile_basename }] } {
>> + print "file delete
>> $subdir/$canonical_tmp_dir/$canonical_srcfile_basename failed"
>> + }
>> + if { $rmreldir && [catch { file delete
>> $subdir/$canonical_tmp_dir/$canonical_relative_dir }] } {
>> + print "file delete
>> $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
>> + }
>> + if { $rmtmpdir && [catch { file delete
>> $subdir/$canonical_tmp_dir }] } {
>> + print "file delete $subdir/$canonical_tmp_di failed"
>> + }
>> +}
>> +
>> +if [is_remote host] {
>> + unsupported "Compiling on a remote host does not support a
>> filename with directory."
>> + return 0
>> +}
>> +
>> +if [catch { file mkdir
>> "$subdir/$canonical_tmp_dir/$canonical_relative_dir" }] {
>> + untested "file mkdir
>> $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
>> + canonical_cleanup false true true
>> + return 0
>> +}
>> +
>> +if [catch { file copy $srcdir/$subdir/$canonical_srcfile_basename
>> $subdir/$canonical_tmp_dir }] {
>> + untested "file copy $srcdir/$subdir/$srcfile_basename
>> $subdir/$canonical_tmp_dir failed"
>> + canonical_cleanup false true true
>> + return 0
>> +}
>> +
>> +#compile with the to be deleted directory so that it is in the debug
>> info
>> +set err [gdb_compile "$subdir/$srcfile" $binfile executable {debug}]
>> +if { $err != "" } {
>> + untested "${srcfile} compilation failed"
>> + canonical_cleanup true true true
>> + return -1
>> +}
>> +
>> +#remove the directory so that we can test after that we can break
>> even if it's not there
>> +#using the canonicalized version of the path
>> +if [catch { file delete
>> $subdir/$canonical_tmp_dir/$canonical_relative_dir }] {
>> + untested "rmdir
>> $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
>> + canonical_cleanup true true true
>> + return 0
>> +}
>> +
>> +clean_restart ${testfile}
>> +
>> +gdb_breakpoint
>> $subdir/$canonical_tmp_dir/$canonical_srcfile_basename:[gdb_get_line_number
>> "main" $srcdir/$subdir/$canonical_srcfile_basename] {message}
>> +
>> +canonical_cleanup true true true
>> diff --git a/gdb/utils.c b/gdb/utils.c
>> index 909476b..c97ead3 100644
>> --- a/gdb/utils.c
>> +++ b/gdb/utils.c
>> @@ -68,6 +68,7 @@
>> #include "gdb_usleep.h"
>> #include "interps.h"
>> #include "gdb_regex.h"
>> +#include "canonicalize.h"
>> #if !HAVE_DECL_MALLOC
>> extern PTR malloc (); /* ARI: PTR */
>> @@ -2889,7 +2890,7 @@ gdb_realpath (const char *filename)
>> }
>> #else
>> {
>> - char *rp = canonicalize_file_name (filename);
>> + char *rp = canonicalize_filename_mode (filename, CAN_MISSING);
>> if (rp != NULL)
>> return rp;
>
[-- Attachment #2: 0001-Replaced-binutils-module-canonicalize-lgpl-with-cano.patch.bz2 --]
[-- Type: application/x-bzip, Size: 139229 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-02-03 20:21 ` [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists Antoine Tremblay
2015-02-03 20:29 ` Antoine Tremblay
@ 2015-03-24 15:11 ` Antoine Tremblay
1 sibling, 0 replies; 9+ messages in thread
From: Antoine Tremblay @ 2015-03-24 15:11 UTC (permalink / raw)
To: gdb-patches
ping..
On 02/03/2015 03:19 PM, Antoine Tremblay wrote:
> For example if you have an executable with debug symbols with a path that
> looks like /build-server/program/build/../file.c and try to insert a
> breakpoint by using the CLI "b /build-server/program/file.c" gdb would fail
> to find that file.
>
> This patch makes gdb try to open a source file with its canonical path
> even if parts of that path do not exist.
>
> In this example when trying to open /build-server/program/build/../file.c
> we search for /build-server/program/file.c. even if the "build" directory
> is not present on the system.
>
> Also, since in general we do not need the full uncanonicalised path
> to be present on the system and that we validate that the file exist
> after a call to gdb_realpath with a subsequent call to open,
> gdb_realpath was changed to accept that parts of the path or the whole
> path be missing from the system.
>
> This is done using canonicalize_filename_mode (filename, CAN_MISSING);
>
> To make this behavior easy to adapt to multiple situations inside gdb
> in the future, a new option to openp was added :
>
> OPF_TRY_REALPATH = 0x08
>
> This will try the canonicalized path when using the openp function.
> As used in find_and_open_source to allow this feature.
>
> Also added a small test case to verify the issue.
>
> gdb/ChangeLog:
>
> PR breakpoints/17497
> * defs.h: Add OPF_TRY_REALPATH.
> * source.c (openp): Add OPF_TRY_REALPATH option.
> (find_and_open_source): Use OPF_TRY_REALPATH option to find a file.
> * utils.c (gdb_realpath): Change canonicalize_file_name
> to canonicalize_filename_mode with CAN_MISSING flag.
>
> gdb/testsuite/ChangeLog:
>
> PR breakpoints/17497
> * gdb.base/Makefile.in: Add tryrealpath test.
> * gdb.base/break-canonical-path.c: New test.
> * gdb.base/break-canonical-path.exp: New file.
> ---
> gdb/defs.h | 7 +-
> gdb/source.c | 37 ++++++++--
> gdb/testsuite/gdb.base/Makefile.in | 4 +-
> gdb/testsuite/gdb.base/break-canonical-path.c | 22 ++++++
> gdb/testsuite/gdb.base/break-canonical-path.exp | 83 +++++++++++++++++++++++
> gdb/utils.c | 3 +-
> 6 files changed, 146 insertions(+), 10 deletions(-)
> create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.c
> create mode 100644 gdb/testsuite/gdb.base/break-canonical-path.exp
>
> diff --git a/gdb/defs.h b/gdb/defs.h
> index a1cd45f..fac9b2c 100644
> --- a/gdb/defs.h
> +++ b/gdb/defs.h
> @@ -310,9 +310,10 @@ extern const char *pc_prefix (CORE_ADDR);
> /* From source.c */
>
> /* See openp function definition for their description. */
> -#define OPF_TRY_CWD_FIRST 0x01
> -#define OPF_SEARCH_IN_PATH 0x02
> -#define OPF_RETURN_REALPATH 0x04
> +#define OPF_TRY_CWD_FIRST 0x01
> +#define OPF_SEARCH_IN_PATH 0x02
> +#define OPF_RETURN_REALPATH 0x04
> +#define OPF_TRY_REALPATH 0x08
>
> extern int openp (const char *, int, const char *, int, char **);
>
> diff --git a/gdb/source.c b/gdb/source.c
> index 574d9fa..1a3fbf9 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -769,8 +769,18 @@ openp (const char *path, int opts, const char *string,
>
> if (is_regular_file (string))
> {
> - filename = alloca (strlen (string) + 1);
> - strcpy (filename, string);
> + if (opts & OPF_TRY_REALPATH)
> + {
> + char *real_path = gdb_realpath (string);
> + filename = alloca (strlen (real_path) + 1);
> + strcpy (filename, real_path);
> + xfree (real_path);
> + }
> + else
> + {
> + filename = alloca (strlen (string) + 1);
> + strcpy (filename, string);
> + }
> fd = gdb_open_cloexec (filename, mode, 0);
> if (fd >= 0)
> goto done;
> @@ -867,6 +877,25 @@ openp (const char *path, int opts, const char *string,
> strcat (filename + len, SLASH_STRING);
> strcat (filename, string);
>
> + /* Try the canonical path. */
> + if (opts & OPF_TRY_REALPATH)
> + {
> + char *real_path;
> + int newlen;
> +
> + real_path = gdb_realpath (filename);
> +
> + /* First, realloc the filename buffer if too short. */
> + newlen = len + strlen (real_path) + 1;
> + if (newlen > alloclen)
> + {
> + alloclen = newlen;
> + filename = alloca (alloclen);
> + }
> + strcpy (filename, real_path);
> + xfree (real_path);
> + }
> +
> if (is_regular_file (filename))
> {
> fd = gdb_open_cloexec (filename, mode, 0);
> @@ -1083,8 +1112,8 @@ find_and_open_source (const char *filename,
> }
> }
>
> - result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
> - OPEN_MODE, fullname);
> + result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH |
> + OPF_TRY_REALPATH, filename, OPEN_MODE, fullname);
> if (result < 0)
> {
> /* Didn't work. Try using just the basename. */
> diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
> index dda3169..1c23bbd 100644
> --- a/gdb/testsuite/gdb.base/Makefile.in
> +++ b/gdb/testsuite/gdb.base/Makefile.in
> @@ -4,8 +4,8 @@ srcdir = @srcdir@
> EXECUTABLES = a2-run advance all-types annota1 annota1-watch_thread_num \
> annota3 anon args arrayidx async attach attach-pie-misread \
> attach2 auxv bang\! bfp-test bigcore bitfields bitfields2 \
> - break break-always break-entry break-interp-test breako2 \
> - breakpoint-shadow break-on-linker-gcd-function \
> + break break-always break-canonical-path break-entry break-interp-test \
> + breako2 breakpoint-shadow break-on-linker-gcd-function \
> call-ar-st call-rt-st call-sc-t* call-signals \
> call-strs callexit callfuncs callfwmall charset checkpoint \
> chng-syms code_elim1 code_elim2 commands compiler completion complex \
> diff --git a/gdb/testsuite/gdb.base/break-canonical-path.c b/gdb/testsuite/gdb.base/break-canonical-path.c
> new file mode 100644
> index 0000000..7e362b2
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/break-canonical-path.c
> @@ -0,0 +1,22 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2015 Free Software Foundation, Inc.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +int
> +main (void)
> +{
> + return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/break-canonical-path.exp b/gdb/testsuite/gdb.base/break-canonical-path.exp
> new file mode 100644
> index 0000000..511acaa
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/break-canonical-path.exp
> @@ -0,0 +1,83 @@
> +# Copyright (C) 2015 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +# This file tests if we can set a breakpoint provided our path is the
> +# canonicalized path of a longer path with some parts that are not
> +# present on the fs.
> +# See breakpoints/17497 for more information
> +
> +# main directory for compilation
> +set canonical_tmp_dir "break-canonical-path-tmp"
> +# this directory will be deleted before putting the breakpoint
> +set canonical_relative_dir "tmp"
> +set canonical_srcfile_basename "break-canonical-path.c"
> +
> +standard_testfile $canonical_tmp_dir/$canonical_relative_dir/../$canonical_srcfile_basename
> +
> +proc canonical_cleanup {rmsrcfile rmreldir rmtmpdir} {
> + global subdir
> + global canonical_tmp_dir
> + global canonical_relative_dir
> + global canonical_srcfile_basename
> +
> + if { $rmsrcfile && [catch { file delete $subdir/$canonical_tmp_dir/$canonical_srcfile_basename }] } {
> + print "file delete $subdir/$canonical_tmp_dir/$canonical_srcfile_basename failed"
> + }
> + if { $rmreldir && [catch { file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir }] } {
> + print "file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
> + }
> + if { $rmtmpdir && [catch { file delete $subdir/$canonical_tmp_dir }] } {
> + print "file delete $subdir/$canonical_tmp_di failed"
> + }
> +}
> +
> +if [is_remote host] {
> + unsupported "Compiling on a remote host does not support a filename with directory."
> + return 0
> +}
> +
> +if [catch { file mkdir "$subdir/$canonical_tmp_dir/$canonical_relative_dir" }] {
> + untested "file mkdir $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
> + canonical_cleanup false true true
> + return 0
> +}
> +
> +if [catch { file copy $srcdir/$subdir/$canonical_srcfile_basename $subdir/$canonical_tmp_dir }] {
> + untested "file copy $srcdir/$subdir/$srcfile_basename $subdir/$canonical_tmp_dir failed"
> + canonical_cleanup false true true
> + return 0
> +}
> +
> +#compile with the to be deleted directory so that it is in the debug info
> +set err [gdb_compile "$subdir/$srcfile" $binfile executable {debug}]
> +if { $err != "" } {
> + untested "${srcfile} compilation failed"
> + canonical_cleanup true true true
> + return -1
> +}
> +
> +#remove the directory so that we can test after that we can break even if it's not there
> +#using the canonicalized version of the path
> +if [catch { file delete $subdir/$canonical_tmp_dir/$canonical_relative_dir }] {
> + untested "rmdir $subdir/$canonical_tmp_dir/$canonical_relative_dir failed"
> + canonical_cleanup true true true
> + return 0
> +}
> +
> +clean_restart ${testfile}
> +
> +gdb_breakpoint $subdir/$canonical_tmp_dir/$canonical_srcfile_basename:[gdb_get_line_number "main" $srcdir/$subdir/$canonical_srcfile_basename] {message}
> +
> +canonical_cleanup true true true
> diff --git a/gdb/utils.c b/gdb/utils.c
> index 909476b..c97ead3 100644
> --- a/gdb/utils.c
> +++ b/gdb/utils.c
> @@ -68,6 +68,7 @@
> #include "gdb_usleep.h"
> #include "interps.h"
> #include "gdb_regex.h"
> +#include "canonicalize.h"
>
> #if !HAVE_DECL_MALLOC
> extern PTR malloc (); /* ARI: PTR */
> @@ -2889,7 +2890,7 @@ gdb_realpath (const char *filename)
> }
> #else
> {
> - char *rp = canonicalize_file_name (filename);
> + char *rp = canonicalize_filename_mode (filename, CAN_MISSING);
>
> if (rp != NULL)
> return rp;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-02-03 20:29 ` Antoine Tremblay
2015-02-11 13:27 ` Antoine Tremblay
@ 2015-03-27 12:24 ` Pedro Alves
2015-03-27 18:48 ` Antoine Tremblay
1 sibling, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2015-03-27 12:24 UTC (permalink / raw)
To: Antoine Tremblay, gdb-patches
On 02/03/2015 08:28 PM, Antoine Tremblay wrote:
> Hi,
> Unfortunately the 1/2 patch of this patchset failed because it's
> about 1M , and mailman is only accepting < 400k emails...
>
> The patch is large since I'm replacing canonicalize-lgpl from
> binutils with canonicalize and that triggers a few dependencies..
Eh, so large... What is it exactly pulling?
>
> Any ideas on how I should proceed ?
>
> I could send a patch with only the change to the update-gnulib.sh maybe ?
Yes, please, along with any other changes outside import/.
I assume you'll need to change gdb/gnulib/Makefile.in too.
And be sure to explain why canonicalize-lgpl doesn't work
for what we need.
Could you push the patches as a branch somewhere? That'd
make it trivial to pull/try them.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-03-27 12:24 ` Pedro Alves
@ 2015-03-27 18:48 ` Antoine Tremblay
2015-03-27 18:52 ` Antoine Tremblay
0 siblings, 1 reply; 9+ messages in thread
From: Antoine Tremblay @ 2015-03-27 18:48 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 03/27/2015 08:24 AM, Pedro Alves wrote:
> On 02/03/2015 08:28 PM, Antoine Tremblay wrote:
>> Hi,
>> Unfortunately the 1/2 patch of this patchset failed because it's
>> about 1M , and mailman is only accepting < 400k emails...
>>
>> The patch is large since I'm replacing canonicalize-lgpl from
>> binutils with canonicalize and that triggers a few dependencies..
>
> Eh, so large... What is it exactly pulling?
It is pulling the following modules as dependencies to canonicalize :
areadlink-with-size,bitrotate,chdir-long,cloexec,close,closedir,d-ino,dirname,dup,dup2,error,exitfail,fchdir,fcntl,fcntl-h,fd-hook,fdopendir,file-set,filename,filenamecat-lgpl,fstat,fstatat,getcwd,getcwd-lgpl,getdtablesize,gettext-h,hash,hash-pjw,hash-triple,intprops,mempcpy,memrchr,msvc-inval,msvc-nothrow,open,openat,openat-die,openat-h,opendir,readdir,realloc-posix,rewinddir,same,save-cwd,strdup-posix,strerror,strerror-override,strndup,strnlen,unistd-safer,xalloc,xalloc-die,xalloc-oversized,xgetcwd,xstrndup
>
>>
>> Any ideas on how I should proceed ?
>>
>> I could send a patch with only the change to the update-gnulib.sh maybe ?
>
> Yes, please, along with any other changes outside import/.
> I assume you'll need to change gdb/gnulib/Makefile.in too.
> And be sure to explain why canonicalize-lgpl doesn't work
> for what we need.
I will add the changes outside of import at the end of this mail,
however I think I should commit the whole thing otherwise someone else
will have to do it... Maybe exceptionally you can review the patch on
github ? (I've included the link later in the email)
As to why canonizlize-gpl doesn't work :
Since canonicalize-lgpl uses the system's realpath implementation, we
can't canonicalize a path that does not exist on the current file system
in it's uncanonicalized form.
However this path may exist on the system in it's canonicalized form,
this is actually common with some IDEs that use outside of tree builds
and relative paths as documented in PR breakpoints/17497.
I can add this to the patch comments....
>
> Could you push the patches as a branch somewhere? That'd
> make it trivial to pull/try them.
Yes I've uploaded my patchset at : https://github.com/hexa00/binutils-gdb
Regards,
Antoine
Patch outside of import (Note that Makefile.in is generated
automatically so the only manual change is gdb/gnulib/update-gnulib.sh
diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
index 5c7238f..5845f09 100644
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -31,7 +31,7 @@
# The list of gnulib modules we are importing in GDB.
IMPORTED_GNULIB_MODULES="\
alloca \
- canonicalize-lgpl \
+ canonicalize \
dirent \
dirfd \
errno \
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-03-27 18:48 ` Antoine Tremblay
@ 2015-03-27 18:52 ` Antoine Tremblay
2015-03-27 19:05 ` Pedro Alves
0 siblings, 1 reply; 9+ messages in thread
From: Antoine Tremblay @ 2015-03-27 18:52 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 03/27/2015 02:48 PM, Antoine Tremblay wrote:
> On 03/27/2015 08:24 AM, Pedro Alves wrote:
>> On 02/03/2015 08:28 PM, Antoine Tremblay wrote:
>>> Hi,
>>> Unfortunately the 1/2 patch of this patchset failed because it's
>>> about 1M , and mailman is only accepting < 400k emails...
>>>
>>> The patch is large since I'm replacing canonicalize-lgpl from
>>> binutils with canonicalize and that triggers a few dependencies..
>>
>> Eh, so large... What is it exactly pulling?
>
> It is pulling the following modules as dependencies to canonicalize :
>
> areadlink-with-size,bitrotate,chdir-long,cloexec,close,closedir,d-ino,dirname,dup,dup2,error,exitfail,fchdir,fcntl,fcntl-h,fd-hook,fdopendir,file-set,filename,filenamecat-lgpl,fstat,fstatat,getcwd,getcwd-lgpl,getdtablesize,gettext-h,hash,hash-pjw,hash-triple,intprops,mempcpy,memrchr,msvc-inval,msvc-nothrow,open,openat,openat-die,openat-h,opendir,readdir,realloc-posix,rewinddir,same,save-cwd,strdup-posix,strerror,strerror-override,strndup,strnlen,unistd-safer,xalloc,xalloc-die,xalloc-oversized,xgetcwd,xstrndup
>
>
>>
>>>
>>> Any ideas on how I should proceed ?
>>>
>>> I could send a patch with only the change to the update-gnulib.sh
>>> maybe ?
>>
>> Yes, please, along with any other changes outside import/.
>> I assume you'll need to change gdb/gnulib/Makefile.in too.
>> And be sure to explain why canonicalize-lgpl doesn't work
>> for what we need.
>
> I will add the changes outside of import at the end of this mail,
> however I think I should commit the whole thing otherwise someone else
> will have to do it... Maybe exceptionally you can review the patch on
> github ? (I've included the link later in the email)
>
> As to why canonizlize-gpl doesn't work :
>
> Since canonicalize-lgpl uses the system's realpath implementation, we
> can't canonicalize a path that does not exist on the current file system
> in it's uncanonicalized form.
>
> However this path may exist on the system in it's canonicalized form,
> this is actually common with some IDEs that use outside of tree builds
> and relative paths as documented in PR breakpoints/17497.
>
> I can add this to the patch comments....
>
>>
>> Could you push the patches as a branch somewhere? That'd
>> make it trivial to pull/try them.
>
> Yes I've uploaded my patchset at : https://github.com/hexa00/binutils-gdb
>
> Regards,
>
> Antoine
>
> Patch outside of import (Note that Makefile.in is generated
> automatically so the only manual change is gdb/gnulib/update-gnulib.sh
>
> diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
> index 5c7238f..5845f09 100644
> --- a/gdb/gnulib/update-gnulib.sh
> +++ b/gdb/gnulib/update-gnulib.sh
> @@ -31,7 +31,7 @@
> # The list of gnulib modules we are importing in GDB.
> IMPORTED_GNULIB_MODULES="\
> alloca \
> - canonicalize-lgpl \
> + canonicalize \
> dirent \
> dirfd \
> errno \
I forgot to mention if you have a recent debian or ubuntu with perl >
5.6 you will have problems running update-gnulib.sh you need to patch
your automake 1.11.1 with the patch at :
https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
Actually this patch contains a quilt patchset you need to apply the
patch inside this patchset...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-03-27 18:52 ` Antoine Tremblay
@ 2015-03-27 19:05 ` Pedro Alves
2015-03-27 19:14 ` Antoine Tremblay
0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2015-03-27 19:05 UTC (permalink / raw)
To: Antoine Tremblay, gdb-patches
On 03/27/2015 06:52 PM, Antoine Tremblay wrote:
> I forgot to mention if you have a recent debian or ubuntu with perl >
> 5.6 you will have problems running update-gnulib.sh you need to patch
> your automake 1.11.1 with the patch at :
> https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
>
> Actually this patch contains a quilt patchset you need to apply the
> patch inside this patchset...
>
in the users/palves/gnulib-update branch I just worked around
it in the update-gnulib.sh script itself:
commit e24f90b0469990f97d0f4ff433bdb8c5567736fe
Author: Pedro Alves <palves@redhat.com>
AuthorDate: Mon Mar 23 11:56:05 2015 +0000
Commit: Pedro Alves <palves@redhat.com>
CommitDate: Mon Mar 23 11:56:05 2015 +0000
Set up to update gnulib d164bf67cc2d471facdd5d3b09f80f3688b3a21b
diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
old mode 100644
new mode 100755
index 5c7238f..91acea4
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -53,7 +53,7 @@ IMPORTED_GNULIB_MODULES="\
"
# The gnulib commit ID to use for the update.
-GNULIB_COMMIT_SHA1="8d5bd1402003bd0153984b138735adf537d960b0"
+GNULIB_COMMIT_SHA1="d164bf67cc2d471facdd5d3b09f80f3688b3a21b"
# The expected version number for the various auto tools we will
# use after the import.
@@ -110,7 +110,7 @@ if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
fi
# Verify that we have the correct version of aclocal.
-ver=`aclocal --version 2>&1 | head -1 | sed 's/.*) //'`
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
if [ "$ver" != "$ACLOCAL_VERSION" ]; then
echo "Error: Wrong aclocal version: $ver. Aborting."
exit 1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists.
2015-03-27 19:05 ` Pedro Alves
@ 2015-03-27 19:14 ` Antoine Tremblay
0 siblings, 0 replies; 9+ messages in thread
From: Antoine Tremblay @ 2015-03-27 19:14 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
> in the users/palves/gnulib-update branch I just worked around
> it in the update-gnulib.sh script itself:
Even better :)
Antoine
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-03-27 19:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1422994793-9861-1-git-send-email-antoine.tremblay@ericsson.com>
2015-02-03 20:21 ` [PATCH 2/2] Fix source file not found when part of the path does not exist but that a canonicalized path exists Antoine Tremblay
2015-02-03 20:29 ` Antoine Tremblay
2015-02-11 13:27 ` Antoine Tremblay
2015-03-27 12:24 ` Pedro Alves
2015-03-27 18:48 ` Antoine Tremblay
2015-03-27 18:52 ` Antoine Tremblay
2015-03-27 19:05 ` Pedro Alves
2015-03-27 19:14 ` Antoine Tremblay
2015-03-24 15:11 ` Antoine Tremblay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox