I tried this unittest with others and all tests passed:
// 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:
#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]