Author Topic: Splitting debugger in two - specific debugger and common GUI  (Read 430874 times)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #585 on: January 15, 2012, 01:56:06 am »
This is caused by
1. cbEditor::SaveFoldState() calling cbEditor::OnEditorModified
2 which then calls debugger->EditorLinesAddedOrRemoved,
3. which shifts the breakpoints after the end of the file.

Can you please test the attached patch ?
It prevents the event-connection if the dummy editor for the fold-backup is created.
So no line-added-event is thrown for the backup editor and therefore the bp's get not shifted.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #586 on: January 17, 2012, 08:34:38 am »
Can you please test the attached patch ?
Works here. I think that's way better than before, please commit. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #587 on: January 17, 2012, 08:38:59 am »
Another one:
- Start C::B (do not have anything opened before)
- Create a console app using the wizard, select only debug target
- Once created, place a BP in the "cout << " line
- Hit The "Debug" button from the tool bar.
- For me, GDB does not run the debuggee and I cannot stop the debugger until I kill it from the task manager
--> Note: The "build before debug" is off, so there is no executable! But it should not fail like that.

The log:
[debug]Command-line: C:\Devel\GCC46TDM\bin\gdb.exe -nx -fullname  -quiet  -args 粔"冠ࠇ
[debug]Working dir : C:\DOKUME~1\Morten\Desktop\MYCon

Starting debugger: C:\Devel\GCC46TDM\bin\gdb.exe -nx -fullname  -quiet  -args 粔"冠ࠇ
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]????: No such file or directory.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.3
[debug]Copyright (C) 2011 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.3

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set debugevents on
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]No symbol table is loaded.  Use the "file" command.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Devel\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/DOKUME~1/Morten/Desktop/MYCon/
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Dokumente und Einstellungen/Morten/Desktop/MYCon/main.cpp:7"
[debug]No symbol table is loaded.  Use the "file" command.
[debug]Breakpoint 2 ("C:/Dokumente und Einstellungen/Morten/Desktop/MYCon/main.cpp:7) pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]No executable specified, use `target exec'.
[debug]>>>>>>cb_gdb:


Notice that the strange Chinese characters "-args 粔"冠ࠇ" are really there.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #588 on: January 17, 2012, 09:36:04 am »
Can you try this patch and then tell me if it works:
Code
Index: src/plugins/debuggergdb/gdb_commands.h
===================================================================
--- src/plugins/debuggergdb/gdb_commands.h      (revision 7700)
+++ src/plugins/debuggergdb/gdb_commands.h      (working copy)
@@ -681,9 +681,9 @@
             const wxArrayString &lines = GetArrayFromString(output, _T('\n'));
             for (size_t ii = 0; ii < lines.GetCount(); ++ii)
             {
-                if (lines[ii].StartsWith(wxT("No symbol table loaded."))
-                    || lines[ii].StartsWith(wxT("No executable file specified."))
-                    || lines[ii].StartsWith(wxT("No executable specified.")))
+                if (lines[ii].StartsWith(wxT("No symbol table loaded"))
+                    || lines[ii].StartsWith(wxT("No executable file specified"))
+                    || lines[ii].StartsWith(wxT("No executable specified")))
                 {
                     // log this and quit debugging
                     m_pDriver->Log(_("Starting the debuggee failed: ")+lines[ii]);

About the Chinese characters: I don't see any on linux, but I guess something is not initialized correctly, can you try to debug it?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #589 on: January 17, 2012, 09:51:57 am »
Can you please test the attached patch ?
Works here. I think that's way better than before, please commit. ;-)
To trunk or to debugger-branch ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #590 on: January 17, 2012, 10:14:22 am »
I've tried it on trunk, because the patch didn't apply on the branch.
I prefer the commit to happen in trunk, because the bug happens there, too.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #591 on: January 17, 2012, 11:24:59 am »
I've tried it on trunk, because the patch didn't apply on the branch.
I prefer the commit to happen in trunk, because the bug happens there, too.
Done in trunk svn r7702 .

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #592 on: January 17, 2012, 02:53:41 pm »
Can you try this patch and then tell me if it works:
It works, but the garbage with the Chinese characters is still there. It looks like a wrong/missing  .c_str() .wxstr() to me...
However, the hang is gone. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #593 on: January 17, 2012, 02:59:40 pm »
BTW, also notice this line:
[debug]????: No such file or directory.
It comes when trying to read the symbol table from the executable (debuggee) that is not there yet. Maybe you should check for that pattern too (not sure if you do so already).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #594 on: January 17, 2012, 03:15:20 pm »
I don't do it, but I'm not sure if it is possible.

Can you try to debug the Chinese symbols, I can't reproduce it on linux here and I don't know when I'll have time to switch to windows?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #595 on: January 17, 2012, 03:25:08 pm »
I don't do it, but I'm not sure if it is possible.

Can you try to debug the Chinese symbols, I can't reproduce it on linux here and I don't know when I'll have time to switch to windows?
I just tested, and if the project path has spaces, then it will show some "Unknown Chinese characters".
This is because gdb can not handle path with spaces.

If you do not have spaces in your path, but no exe built, then there is not such Chinese symbols.

The debugger freeze in both cases. I'm testing latest debugger branch nightly build.

PS, you can not set a breakpoint in a file with spaces under gdb(Windows).
« Last Edit: January 17, 2012, 03:28:22 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #596 on: January 17, 2012, 03:25:31 pm »
Can you try to debug the Chinese symbols, I can't reproduce it on linux here and I don't know when I'll have time to switch to windows?
Yes, I am already at it but face two times another freeze bug (the one reported earlier with "out of function scope")... :-(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #597 on: January 17, 2012, 03:26:44 pm »
PS, you can not set a breakpoint in a file with spaces under gdb(Windows).
This works very well for me if you have set the "GDB workaround in the advanced compiler options.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #598 on: January 17, 2012, 03:30:35 pm »
OK - when entering "GDB_driver::GetCommandLine(const wxString& debugger, const wxString& debuggee, const wxString &userArguments)" I see that "debuggee" is exactly "" " (quote, space). This looks pretty weird.

I see in the debug log:
[debug]> output debuggee
[debug](const wxString &) @0x22e200: {
[debug]  <wxStringBase> = {
[debug]    static npos = <optimized out>,
[debug]    m_pchData = 0x17f39544 L"\"\xe920\221\174"
[debug]  }, <No data fields>}>>>>>>cb_gdb:


(I'll update this post if I got news...)

EDIT: UPDATE:

A little earlier (in int DebuggerGDB::DoDebug(bool breakOnEntry)) I see that "path" is "C:\\Dokumente und Einstellungen\\Morten\\Desktop\\MyCon2\\." then after a call to "ConvertToGDBDirectory(path)" it is "C:/DOKUME~1/Morten/Desktop/MyCon2/.". That's OK.

The command line generated in in "GDB_driver::GetCommandLine" uses "-args " ", so the final command line is:
C:\\Devel\\GCC46TDM\\bin\\gdb.exe -nx -fullname  -quiet  -args "
Do you see the trailing single quotation mark? I think that's it. A bug. :-)

-> No closing quotation mark, so the debugger reads garbage!
« Last Edit: January 17, 2012, 03:45:46 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #599 on: January 17, 2012, 03:34:25 pm »
PS, you can not set a breakpoint in a file with spaces under gdb(Windows).
This works very well for me if you have set the "GDB workaround in the advanced compiler options.
I have already have this option checked.
See my log (with spaces)
Code
Debugger name and version: GNU gdb (GDB) 7.4.50.20120117-cvs
...
[debug]>>>>>>cb_gdb:
[debug]> directory E:/code/cb/TEST_C~1/SPACEF~1/hi/
[debug]>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:
[debug]> break "E:/code/cb/test_code/space folder/hi/main.cpp:8"
[debug]Breakpoint 2 at 0x401402: file E:\code\cb\test_code\space folder\hi\main.cpp, line 8.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]gdb: windows_init_thread_list

Child process PID: 4164

[debug][New Thread 4164.0x1cc]
[debug]Error in re-setting breakpoint 2: Function "E:/code/cb/test_code/space folder/hi/main.cpp:8" not defined.
[debug][Inferior 1 (process 4164) exited normally]
[debug]>>>>>>cb_gdb:

Error in re-setting breakpoint 2: Function "E:/code/cb/test_code/space folder/hi/main.cpp:8" not defined.
[Inferior 1 (process 4164) exited normally]

[debug]> set debugevents off
[debug]>>>>>>cb_gdb:
[debug]> quit

Debugger finished with status 0

Below is path with no space:
Code
Debugger name and version: GNU gdb (GDB) 7.4.50.20120117-cvs
...
[debug]>>>>>>cb_gdb:
[debug]> directory E:/code/cb/test_code/nospace/hi/
[debug]>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:
[debug]> break "E:/code/cb/test_code/space folder/hi/main.cpp:8"
[debug]No source file named E:/code/cb/test_code/space folder/hi/main.cpp.
[debug]Breakpoint 2 ("E:/code/cb/test_code/space folder/hi/main.cpp:8) pending.
[debug]>>>>>>cb_gdb:
[debug]> break "E:/code/cb/test_code/nospace/hi/main.cpp:7"
[debug]Breakpoint 3 at 0x4013de: file E:\code\cb\test_code\nospace\hi\main.cpp, line 7.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]gdb: windows_init_thread_list

Child process PID: 6040

[debug][New Thread 6040.0xa34]
[debug]Breakpoint 3, main () at E:\code\cb\test_code\nospace\hi\main.cpp:7
[debug]E:\code\cb\test_code\nospace\hi\main.cpp:7:62:beg:0x4013de
[debug]>>>>>>cb_gdb:

At E:\code\cb\test_code\nospace\hi\main.cpp:7

[debug]> set debugevents off
[debug]>>>>>>cb_gdb:
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.