Author Topic: DDD-like watches  (Read 25847 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11939
    • Travis build status
Re: DDD-like watches
« Reply #45 on: April 17, 2011, 02:26:14 am »
This change:
Code: [Select]
Index: src/plugins/debuggergdb/parsewatchvalue.cpp
===================================================================
--- src/plugins/debuggergdb/parsewatchvalue.cpp (revision 7112)
+++ src/plugins/debuggergdb/parsewatchvalue.cpp (working copy)
@@ -258,6 +258,8 @@
 bool ParseGDBWatchValue(GDBWatch &watch, wxString const &value, int &start, int length)
 {
     watch.SetDebugValue(value);
+    // erase possible "Cannot access memory at address" at structural types
+    watch.SetValue(wxEmptyString);
     watch.MarkChildsAsRemoved();
 
     int position = start;

requires a unittest, explanation and steps to reproduce.

Also you're using C++, not C# or any other "modern" language, so "this->" is not required (99.99% of the time), when accessing members of the class.
Please don't do it.
I've not tried the patch yet, will do so tomorrow...
(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 m.29

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: DDD-like watches
« Reply #46 on: April 17, 2011, 11:29:27 pm »
I tried this unittest with others and all tests passed:
Code: [Select]
// dereferenced pointer from invalid to valid address
TEST(DereferencedStructPointer)
{
    GDBWatch w(wxT("*s"));
    CHECK(ParseGDBWatchValue(w, wxT("Cannot access memory at address 0x0")));
    CHECK(ParseGDBWatchValue(w, wxT("{\n  number = 29,\n  real = 36\n}")));
    CHECK_EQUAL(wxT("*s= {number=29,real=36}"), w);
}
Without my patch I get *s=Cannot access memory at address 0x0 {number=29,real=36}. You can reproduce this with this C code:
Code: [Select]
#include <stdlib.h>

struct structure {
    int number;
    float real;
};

int main(void) {
    struct structure *s = NULL;

    struct structure S = {
        .number = 29,
        .real = 36,
    };
    s = &S;

    return EXIT_SUCCESS;
}
You set breakpoint at line struct structure *s = NULL; and then stop at line return EXIT_SUCCESS; As you can see at picture, old value is displayed.

In my code I hide edges of graph which are invalid. I find out this case (watch is invalid) by parsing watch value, but in some cases value of watch was invalid even if watch was was valid. Typically if dereferenced pointer was NULL and then not NULL.

Sorry for the "this->" issue. I'll remove it.

[attachment deleted by admin]
Windows XP SP3, wxWidgets 2.8.11, C::B DEBUGGER BRANCH nightly builds

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11939
    • Travis build status
Re: DDD-like watches
« Reply #47 on: April 17, 2011, 11:59:04 pm »
Applied with little modifications, thanks :)

p.s. Please don't attach images directly, because the forum space is limited. Use a picture paste type of service instead.
(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 rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: DDD-like watches
« Reply #48 on: May 05, 2011, 06:08:33 pm »
Wow, it really looks nice so far! I can't wait to see it working on my video editing project. Hey... can it be modified to display RGB pixels (if you specify a format) now that we're at it?  :twisted: mwahahahahaha!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11939
    • Travis build status
Re: DDD-like watches
« Reply #49 on: May 05, 2011, 06:49:57 pm »
rickg22: probably you should get a copy of python enabled gdb and try to see what you can do with python scripting of gdb.

Hardcoding a bitmap viewer in the code doesn't sound good.
(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!]