Patch #1658 2006-11-24 22:10

ramazank

Corrects the "No source file named" behavior when debugging
Download
1658-Corrects_the_N.patch (2.1 KB)
Category
Plugin::Bugfix
Status
Rejected
Close date
2007-01-04 14:47
Assigned to
 
Index: plugins/debuggergdb/gdb_driver.cpp
===================================================================
--- plugins/debuggergdb/gdb_driver.cpp    (revision 3258)
+++ plugins/debuggergdb/gdb_driver.cpp    (working copy)
@@ -22,7 +22,7 @@
 static wxRegEx reThreadSwitch(_T("^\\[Switching to thread .*\\]#0[ \t]+(0x[A-z0-9]+) in (.*) from (.*)"));
 static wxRegEx reThreadSwitch2(_T("^\\[Switching to thread .*\\]#0[ \t]+(0x[A-z0-9]+) in (.*) from (.*):([0-9]+)"));
 #ifdef __WXMSW__
-    static wxRegEx reBreak(_T("([A-z]:)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-z]+)"));
+    static wxRegEx reBreak(_T("..([A-z]:)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-z]+)"));
 #else
     static wxRegEx reBreak(_T("\032\032([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-z]+)"));
 #endif
@@ -130,6 +130,7 @@
     wxString cmd;
     cmd << debugger;
     cmd << _T(" -nx");          // don't run .gdbinit
+    cmd << _T(" -readnow ");    // read symbol table immediately
     cmd << _T(" -fullname ");   // report full-path filenames when breaking
     cmd << _T(" -quiet");       // don't display version on startup
     cmd << _T(" -args ") << debuggee;
@@ -141,6 +142,7 @@
     wxString cmd;
     cmd << debugger;
     cmd << _T(" -nx");          // don't run .gdbinit
+    cmd << _T(" -readnow ");    // read symbol table immediately
     cmd << _T(" -fullname ");   // report full-path filenames when breaking
     cmd << _T(" -quiet");       // don't display version on startup
     cmd << _T(" -pid=") << wxString::Format(_T("%d"), pid);
Index: plugins/debuggergdb/debuggerstate.cpp
===================================================================
--- plugins/debuggergdb/debuggerstate.cpp    (revision 3258)
+++ plugins/debuggergdb/debuggerstate.cpp    (working copy)
@@ -104,10 +104,11 @@
         }
         else
         {
-            // for foreign files, we still should use a relative path
+            // for foreign files, we should use an absolute path
             wxFileName f(filename);
-            f.MakeRelativeTo(prj->GetBasePath());
+            f.MakeAbsolute();
             fname = f.GetFullPath();
+            fname.Replace(_T("\\"), _T("/"));
         }
     }
     return fname;
ramazank 2006-11-24 22:51

If you set a breakpoint in a foreign file, then you may get a "No source file named" error for this file when debugging. For example, you have two projects, one for main executable, one for a static library which is used by main executable project. If you set a breakpoint in a library source file gdb probably will give a "No source file named" error. To correct this:

1. You should start the gdb with "-readnow" parameter.

2. You should set the breakpoints for foreign files with absolute file names and with forward slashes.

This patch provides that.

mandrav 2007-01-04 14:47

1) Using the -readnow gdb arg becomes impossible to debug C::B (app crashes while loading inside gdb). Keep in mind that C::B dynamically loads plugins so that might very well be the reason. But -readnow is not needed anyway for the other part of the patch to function.

2) The other part of the patch, fixes your specific test-case (project you posted in this thread: http://forums.codeblocks.org/index.php?topic=4368.0), but breaks my other test cases.

Thanks for the effort though :).