Patch #3121 2011-01-19 15:04
marcus_b
Including search directories to find relative source files- Download
- 3121-Including_sear.patch (1.2 KB)
- Category
- Plugin::Bugfix
- Status
- Open
- Close date
- Assigned to
- tpetrov
--- src/plugins/debuggergdb/debuggergdb.cpp.original 2011-01-19 14:53:56.877095951 +0100
+++ src/plugins/debuggergdb/debuggergdb.cpp 2011-01-19 15:37:55.227135231 +0100
@@ -2189,8 +2189,25 @@
cbProject* project = Manager::Get()->GetProjectManager()->GetActiveProject();
ProjectFile* f = project ? project->GetFileByFilename(filename, false, true) : 0;
wxFileName fname(filename);
- if (project && fname.IsRelative())
- fname.MakeAbsolute(project->GetBasePath());
+ if (project && fname.IsRelative())
+ {
+ wxArrayString& pdirs = GetSearchDirs(project);
+ wxFileName tmp = fname;
+ for (size_t i = 0; i < pdirs.GetCount(); ++i)
+ {
+ tmp = fname;
+ tmp.MakeAbsolute(pdirs[i]);
+ if (tmp.FileExists())
+ {
+ fname = tmp;
+ break;
+ }
+ }
+ if (fname.IsRelative())
+ {
+ fname.MakeAbsolute(project->GetBasePath());
+ }
+ }
// gdb can't work with spaces in filenames, so we have passed it the shorthand form (C:\MYDOCU~1 etc)
// revert this change now so the file can be located and opened...
// we do this by calling GetLongPath()
History
Is this patch against trunk or against debugger's branch?
If it is against trunk, can you provide a patch against debugger's branch?
Also a test case could be helpful...
My patch supported that clicking on entries in the callstack brings showed the corresponding source file in the editor. This did not work with files from outside the current codeblocks project. Before my changes it was assumed that the relative filenames are inside the current project, which is not always correct because the gdb displays also filenames that are relative to the gdb search directories (e.g. of a dynamically linked thirdparty library).
The patch is against the sources from the downloadable codeblocks-10.05-src.tar.bz2 archive (2010-06-08), so I assume it is the tags/10.05 branch.
I had a look at the sources in branches/wxpropgrid_debugger, which I think is the debugger's branch. The DebuggerGDB class was refactored since the release, and the function in which I made the changes was moved to the cbDebuggerPlugin class: DebuggerGBD::SyncEditor() -> cpDebuggerPlugin::SyncEditor().
Unfortunately cbDebuggerPlugin does not provide the GetSearchDirs() function, so my original patch cannot be applied anymore. Some further refactoring would be required (either pass the search directories as an argument to cpDebuggerPlugin::SyncEditor(), or move the search directories completely to cpDebuggerPlugin).
Can you proved a simple project, which demonstrates the bug?
If you do, so I can refactor your patch for the debuggers branch.