Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

DDD-like watches

<< < (10/10)

oBFusCATed:
This change:

--- Code: ---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;

--- End code ---

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...

m.29:
I tried this unittest with others and all tests passed:
--- Code: ---// 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);
}
--- End code ---
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: ---#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;
}
--- End code ---
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]

oBFusCATed:
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.

rickg22:
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!

oBFusCATed:
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.

Navigation

[0] Message Index

[*] Previous page

Go to full version