This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/18938] source -s foo.py with foo.py a symlink to foo.notpy fails


https://sourceware.org/bugzilla/show_bug.cgi?id=18938

--- Comment #2 from dje at google dot com ---
Comment on attachment 8592
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8592
patch + testcase

>==== gdb/gdb-7.9.x/gdb/cli/cli-cmds.c#2 - gdb/gdb-7.9.x/gdb/cli/cli-cmds.c ====
>--- gdb/cli/cli-cmds.c	2015-02-23 13:07:25.000000000 -0800
>+++ gdb/gdb-7.9.x/gdb/cli/cli-cmds.c	2015-09-08 13:55:50.187471783 -0700
>@@ -537,10 +537,16 @@
>   return 1;
> }
> 
>-/* Load script FILE, which has already been opened as STREAM.  */
>+/* Load script FILE, which has already been opened as STREAM.
>+   FILE_TO_OPEN is the form of FILE to use if one needs to open the file.
>+   This is provided as FILE may have been found via the source search path.
>+   An important thing to note here is that FILE may be a symlink to a file
>+   with a different or non-existing suffix, and thus one cannot infer the
>+   extension language from FILE_TO_OPEN.  */
> 
> static void
>-source_script_from_stream (FILE *stream, const char *file)
>+source_script_from_stream (FILE *stream, const char *file,
>+			   const char *file_to_open)
> {
>   if (script_ext_mode != script_ext_off)
>     {
>@@ -555,7 +561,7 @@
> 		= ext_lang_script_sourcer (extlang);
> 
> 	      gdb_assert (sourcer != NULL);
>-	      sourcer (extlang, stream, file);
>+	      sourcer (extlang, stream, file_to_open);
> 	      return;
> 	    }
> 	  else if (script_ext_mode == script_ext_soft)
>@@ -608,7 +614,7 @@
>      anyway so that error messages show the actual file used.  But only do
>      this if we (may have) used search_path, as printing the full path in
>      errors for the non-search case can be more noise than signal.  */
>-  source_script_from_stream (stream, search_path ? full_path : file);
>+  source_script_from_stream (stream, file, search_path ? full_path : file);
>   do_cleanups (old_cleanups);
> }
> 
>==== gdb/testsuite/gdb.python/python.exp#1 - gdb/gdb-7.9.x/gdb/testsuite/gdb.python/python.exp ====
>--- gdb/gdb-7.9.x/gdb/testsuite/gdb.python/python.exp	2015-01-14 16:43:56.000000000 -0800
>+++ gdb/gdb-7.9.x/gdb/testsuite/gdb.python/python.exp	2015-09-08 14:19:04.246904083 -0700
>@@ -96,6 +96,19 @@
> 
> gdb_test "source -s source2.py" "yes" "source -s source2.py"
> 
>+set remote_source2_symlink_notpy \
>+    [gdb_remote_download host ${srcdir}/${subdir}/source2.py \
>+	 [standard_output_file "source2-symlink.notpy"]]
>+set remote_source2_symlink_py [standard_output_file "source2-symlink.py"]
>+remote_file host delete $remote_source2_symlink_py
>+set status [remote_exec host "ln -sf $remote_source2_symlink_notpy $remote_source2_symlink_py"]
>+set test "source -s source2-symlink.py"
>+if {[lindex $status 0] == 0} {
>+    gdb_test "source -s $remote_source2_symlink_py" "yes" $test
>+} else {
>+    unsupported "$test (host does not support symbolic links)"
>+}
>+
> gdb_test "python print (gdb.current_objfile())" "None"
> gdb_test "python print (gdb.objfiles())" "\\\[\\\]"
>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]