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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #270 on: September 20, 2010, 06:28:50 pm »
No time, it is on the TODO...
(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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #271 on: September 20, 2010, 11:43:56 pm »
Next patch: http://smrt.is-a-geek.org/codeblocks/patches/dbg/dbg_refactor0016.9.patch

Two disassembly problems:
1. No disassembly was displayed if gdb emits some warnings before the real result from the "info frame" command
2. There was no yellow marker on windows. It seems that %p doesn't generate 0x in front of the printed address in wxString::Format.

There many more problems with the disassembly window, but at least it is a bit more usable now.
(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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #272 on: September 24, 2010, 06:39:03 pm »
no pch patch:

Code
Index: src/sdk/cbplugin.cpp
===================================================================
--- src/sdk/cbplugin.cpp        (revision 6634)
+++ src/sdk/cbplugin.cpp        (working copy)
@@ -22,6 +22,9 @@
     #include "editormanager.h"
     #include "cbeditor.h"
     #include "projectmanager.h"
+    #include "infowindow.h"
+    #include "macrosmanager.h"
+    #include "configmanager.h"
 #endif
 
 #include <wx/toolbar.h>
Index: src/sdk/watchesdlg.cpp
===================================================================
--- src/sdk/watchesdlg.cpp      (revision 6634)
+++ src/sdk/watchesdlg.cpp      (working copy)
@@ -9,9 +9,11 @@
 
 #include "sdk_precomp.h"
 #ifndef CB_PRECOMP
+    #include <wx/dnd.h>
     #include <wx/menu.h>
     #include <wx/sizer.h>
 
+    #include "cbexception.h"
     #include "cbplugin.h"
     #include "logmanager.h"
     #include "scrollingdialog.h"
Index: src/plugins/debuggergdb/cdb_driver.cpp
===================================================================
--- src/plugins/debuggergdb/cdb_driver.cpp      (revision 6634)
+++ src/plugins/debuggergdb/cdb_driver.cpp      (working copy)
@@ -8,6 +8,11 @@
  */
 
 #include <sdk.h>
+
+#ifndef CB_PRECOMP
+    #include "logmanager.h"
+#endif
+
 #include "cdb_driver.h"
 #include "cdb_commands.h"
 

(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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #273 on: September 24, 2010, 10:55:29 pm »
Next patch: http://smrt.is-a-geek.org/codeblocks/patches/dbg/dbg_refactor0016.10.patch

1. Added tooltips to the watches window
2. Enabled the tooltips in the wxPG, please fix the windows project to enable them, too

Morten do you plan to add the svn tree, the test project for the debugger plugin?
(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 cbexaminr

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #274 on: September 27, 2010, 11:24:12 pm »
There many more problems with the disassembly window, but at least it is a bit more usable now.

Here's a patch to hopefully improve the disassembly stepping display (some fixes, some enhancements.)
1)Avoid unnecessary re-disassembling
2)change (correct?) check for "current" line address
3)correct code that checked for UpdateBackTrace() and then updated disassembly window
4)Changes to window "current" line position handling
5)support for mixed mode disassembly (currently only available as compilation option)
6)Add calls to NotifyCursorChanged() for cmd_step_instr and cmd_step_into_instr

Anybody interested in trying this?  (so far I've only tried winxp sp2, wxwidgets 2.8.10)

patch against wxpropgrid_debugger branch svn R6634
« Last Edit: September 28, 2010, 01:03:13 am by cbexaminr »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #275 on: September 28, 2010, 07:31:54 am »
Anybody interested in trying this?  (so far I've only tried winxp sp2, wxwidgets 2.8.10)
@oBFusCATed: Will you look into this?
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 #276 on: September 28, 2010, 08:27:58 am »
Yes, I'll tonight (but I don't use disassembly much(at all in fact))... If I don't answer soon please remind me.

Btw this one looks bad
Code
@@ -117,33 +120,83 @@
     wxString fmt;
     fmt.Printf(_T("%p\t%s\n"), (void*)addr, line.c_str());
     if (!fmt.StartsWith(wxT("0x")))
-        fmt = wxT("0x") + fmt;
+        fmt.insert(size_t(0), &wxT("0x")[0], wxString::npos) ; //n == npos, insert all of sz
Why it is needed? what it does?
(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 cbexaminr

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #277 on: September 28, 2010, 09:49:47 am »
Yes, I'll tonight (but I don't use disassembly much(at all in fact))... If I don't answer soon please remind me.

Btw this one looks bad
Code
@@ -117,33 +120,83 @@
     wxString fmt;
     fmt.Printf(_T("%p\t%s\n"), (void*)addr, line.c_str());
     if (!fmt.StartsWith(wxT("0x")))
-        fmt = wxT("0x") + fmt;
+        fmt.insert(size_t(0), &wxT("0x")[0], wxString::npos) ; //n == npos, insert all of sz
Why it is needed? what it does?

[edit]
"what it does?" - it inserts the passed string into position zero of the existing string, without requiring a new buffer/object allocation, when the existing buffer is already large enough to hold the .insert()d string. [/edit]

Not required, but was trying to avoid the extra object construction (in original code) of extra wxString (and its buffer allocation) on every added line, when the existing allocated buffer might be enough for the extra two characters.  In wxWidgets 3.0 (well, 2.9.x), the internals of .insert have changed, its started doing an ('...substring') local object allocation, so any improvement from this might be negated by environment code changes in next major wxWidgets release**.  The ugly casts were trying to get the correctly overloaded .insert from among the compiler ambiguities (there might be a cleaner way to achieve that, I didn't go beyond getting the one I wanted.)

... (but I don't use disassembly much(at all in fact))...
What!!!???!! Oh, you surely miss much... :)

**I probably should take a closer look at that change, and see if its avoidable and if I could convince the wxWidgets devs to eliminate it if reasonably possible, but I only have so much time, and its not a lot.  (I do use disassembly a lot, in other products, hence the time spent here.)
« Last Edit: September 28, 2010, 09:57:31 am by cbexaminr »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #278 on: September 28, 2010, 10:24:18 am »
Have you profiled the code?
What improvement in performance do we get by this change?
If it is less than 15% (I'm sure it is less), please leave it as it is.

Also in c++0x this won't be an issue (I think).

p.s. There is one general rule: premature optimization is the root of all evil.
p.p.s. memory allocations are not problem on the PC for most GUI applications
p.p.p.s. I don't need to look into the assembly to fix most of the problems I encounter and I don't do much hardcore optimization work.
(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 cbexaminr

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #279 on: September 28, 2010, 10:29:50 am »
Anybody interested in trying this?  (so far I've only tried winxp sp2, wxwidgets 2.8.10)

patch against wxpropgrid_debugger branch svn R6634

Meant to also note - GDB (7.1, maybe 7.2 also), or GDB/c::b, seem to have issues (at least in the 'mixed' mode) when attempts are made to step into code where GDB cannot find the source.  I've seen GDB seemingly fail to actually perform the step (looking at debugger(Debug) log window), I've seen it do the step but c::b can't update display because GDB returns 'internal error' warnings about psymtab vs symtab inconsistency (from a 'bt' request), and I've seen it seem to work.  I've particularly seen  that occur with a routine _Unwind_SjLj_register (something like  that), but I think also when it looked for other library modules (which I don't have source for locally) that contained two separate relative path segments (don't currently recall module name) in the debug info filename.

So if you see something strange, check debug log window for gdb output to be sure problem not related to something its doing, or not doing.

Offline cbexaminr

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #280 on: September 28, 2010, 11:40:45 am »
disclaimer:  This is NOT intended to be inflammatory, nor particularly defensive, just informative.  Please read it with that mindset.

Have you profiled the code?
No, not in this context.
What improvement in performance do we get by this change?
Probably less than 15% yes, but it is combined unnecessary actions like this that add up throughOUT a program to make it slower, and profiling can't really reveal the effect of those, because they're so spread out.  Add'l heap fragmentation also tends to slow down everybodies allocations over time.  (I've worked on this on a machine that can see c::b/GDB take approx. 20-30 minutes to load c::b for debugging - when I reboot the machine it takes <= 30 seconds.  As best I can tell, its probably because of OS virtual memory address space fragmentation, that is eliminated by a reboot.)

While the total disassembly time improvement is likely less than 15%, I'd estimate the local operation percentage gain (of orig. string concat vs .insert) to be possibly 50% gain, but if you like I'll consider* trying to cobble together something to demonstrate this - although it'll be a little harder to prove in a single-threaded context, whereas the effect can be more pronounced in multi-threaded contexts where multiple threads may be thrashing the heap with allocations.  (c::b does seem to have multiple threads doing something.)  (*Not that I really want to spend my time proving this, for something I know is a wise practice, when the product itself could benefit from further changes.)

I might also note that the original addition of the check for the leading '0x' might have been avoided, with the code and formats being modified for all environments.  Of course the trade-off is consistency in all environments (windows vs linux vs ?), vs faster performance vs code maintainability vs risk of changes made to solve original problem.  (The current code is probaby 'faster' in linux, because it doesn't have to perform the extra object allocation, both environments have overhead of checking to see if '0x' there to begin with, slower in windows where the object construction and concat are performed, and those lines are less 'maintainable' as there is an 'exception' path ["Is there a leading 0x? No, add one"] that nothing in the code currently indicates the reason for.  (Its also dependent on output that is obviously currently different in different environments, and thus probably subject to future change, since it might reasonably be expected to be the same.)  (Modification might have been to eliminate use of %p, just use %x and add leading literal '0x' as in '0x%08x', but that could be a problem for 64-bit environs, if that's an issue.)  I saw what I thought was an opportunity for 'low-hanging fruit', albeit small in larger context, and took it.
If it is less than 15% (I'm sure it is less), please leave it as it is.
OK if you like, but see previous note in this response.
Also in c++0x this won't be an issue (I think).
Why not, what does c++0x provide to help this? 
When will c::b be distributed in c++0x (in all environs it serves)?


p.s. There is one general rule: premature optimization is the root of all evil.
Scattered failures to avoid unnecessary actions can result in 'fat' that cannot be easily detected or optimized away, short of a rewrite that avoids the unnecessary actions.

p.p.s. memory allocations are not problem on the PC for most GUI applications
The disassembly process itself is really a 'batch' operation within a GUI.  Try stepping into a very 'large' routine, and the pause waiting for disassembly is noticeable, and a bit long for pleasant GUI responsiveness.
p.p.p.s. I don't need to look into the assembly to fix most of the problems I encounter and I don't do much hardcore optimization work.
likewise, but I do at times find it indispensable, particularly when trying to debug optimized code that has failed.  I tend to prefer mostly working with code as it will be shipped, because I've chased too many problems (multi-threaded, timing-related problems) that simply would not show up in the non-optimized ('debug') code versions.  (And no, I've not generally been responsible for creating most of those problems, merely the one stuck with correcting them.)  Figuring out what's happening without looking at the disassembly of the optimized code has not been something I could accomplish.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #281 on: September 28, 2010, 12:11:38 pm »
Also in c++0x this won't be an issue (I think).
Why not, what does c++0x provide to help this? 
Rvalue references. The temporary should be reused if the classes are written right, but I'm not sure if this is true, have to check it.

The disassembly process itself is really a 'batch' operation within a GUI.  Try stepping into a very 'large' routine, and the pause waiting for disassembly is noticeable, and a bit long for pleasant GUI responsiveness.
Haha, this is another problem an has nothing to do with filling the Disassembly window - http://forums.codeblocks.org/index.php/topic,11298.0.html

p.p.p.s. I don't need to look into the assembly to fix most of the problems I encounter and I don't do much hardcore optimization work.
I've said that I don't use it much, so I can test the improvement in that area. I've not said that the disassebly windows is useless.
(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 cbexaminr

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #282 on: September 28, 2010, 02:38:49 pm »
Rvalue references. The temporary should be reused if the classes are written right, but I'm not sure if this is true, have to check it.
FWIW,

The original expression invokes a global operator+() function which declares a local wxString variable, and then calls a method operator+= to concatenate the items, before returning the result.

No temporary involved in that part of the process.

I think even if it were a temporary, it would be hard for a compiler to optimize away the internal buffer allocation involved in holding the string's actual data, and don't know how or if the class w/could be "written right" to avoid that.

(Unfortunately, as mentioned earlier/elsewhere, it appears that wxWidgets 2.9.x has changed the .insert to also involve the definition of a local class object, although I don't think that object involves a buffer allocation.)

You know, I thought about not trying to make that change, wondering if it would "raise a stink."  But I wasn't able to let it pass... :(

Offline cbexaminr

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #283 on: September 28, 2010, 02:57:14 pm »
Haha, this is another problem an has nothing to do with filling the Disassembly window - http://forums.codeblocks.org/index.php/topic,11298.0.html
deleted - posted in the patch thread referenced in quote.
« Last Edit: September 28, 2010, 03:32:26 pm by cbexaminr »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Splitting debugger in two - specific debugger and common GUI
« Reply #284 on: September 28, 2010, 03:05:15 pm »
It is not committed because it was not safe

The patch is here http://smrt.is-a-geek.org/codeblocks/patches/dbg/dbg_speedup_test.patch
« Last Edit: September 28, 2010, 03:09:28 pm by oBFusCATed »
(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!]