News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Attempt to take address of value not located in memory during debugging - solved

Started by rickkky, November 26, 2011, 12:16:05 AM

Previous topic - Next topic

rickkky

Hi,
Since I have upgrade my ubuntu (10.10 -> codeblocks 10.05), I can not watch any of the contents of variable in debug mode. However, my "cbp" files have not changed!...

Example:
QString tmp = "test";

Watches:
tmp.toStdString() = "Attempt to take address of value not located in memory..."
or:
tmp.toStdString().c_str() = "Attempt to take address of value not located in memory..."

This becomes totally impossible to debug anything (C++/Qt for me) in these conditions ... :-(
Please, does anyone have an idea (except: "boot 10.04") to help me resolve this issue?

Regard.
<http://homepage.gna.org/ldapcppei/Frontends/Howto.html>


MortenMacFly

Quote from: rickkky on November 26, 2011, 12:16:05 AM
tmp.toStdString() = "Attempt to take address of value not located in memory..."
[...]
tmp.toStdString().c_str() = "Attempt to take address of value not located in memory..."
Are you aware that a debugger cannot understand this C++ code which needs to be compiled? I guess you should understand what a debugger is able to do and what not. The debugger cannot simply evaluate "tmp.toStdString()" - that's why you see the error. (At least not without special instrumentation.)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

rickkky

#2
QuoteAre you aware that a debugger cannot understand this C++ code which needs to be compiled?
I confess that I do not know all that can do a debugger or not, but I am aware at least of what it was doing before and what it is no longer able to do. ;-)  And because I am an optimist guy, my motto is: "larger version, more features"...

Worse than the described issue, here is what I can do when I boot on my old partition of my mechanic hard drive designed in the last century (ubuntu 10.04):
Code:
...
entry *zone = ...;     // here (1) , "entry" is a ldapcppei::class based on a "std::set" (cf. <http://homepage.gna.org/ldapcppei/>)
<breakpoint>
...
Watches give:
(*zone)["zoneName"]->getStrValue() = (display the actual str content of the attribute "zoneName") !...
(where "operator[](char*)" is a search method -and "attribute" positionning- of the class "entry" in libldapcppei ...)

Here I have to admit, like you, I become quite contemplative ...  :shock: but: yes this works!... :shock: :shock:

(1): line 176 in <http://homepage.gna.org/ldapcppei/archives/ldapEasyAdminFrontends/sources/bind9domain.so/bind9domain.cpp>.

Complement: "tmp.toStdString()" (compiled) does not shock me. When "tmp" exists, its method "QString::toStdString()" simply points to the memory address of the "std::string" of the object. And, after all, the role of a debugger is to show the contents of memory addresses. (However, for the example above, I have no explanation for the fact that it works... I just see it works - with Lucid Lynx, not with my Oneric Ocelot and C::B 10.05...).

MortenMacFly

Quote from: rickkky on November 26, 2011, 11:01:44 PM
not with my Oneric Ocelot and C::B 10.05...).
What about if you try a recent debugger nightly? Debugging has improved a lot!

Note that changing the OS might also mean to change the compiler, the debugger and the framework (versions). So there can be many reasons.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

rickkky

#4
QuoteWhat about if you try a recent debugger nightly? Debugging has improved a lot!
This seems the same, but I live in GMT-10... ;-)

QuoteNote that changing the OS might also mean to change the compiler, the debugger and the framework...
This is not wrong, but my companion, Friday, suggests to me that I should not be the only one in the world to debug with older distributions and want to continue with the new one... So I wonder if I should return to the previous version.  :?

rickkky

New info : with kdbg, "tmp.toStdString()" works !... (ubuntu 11.10)
And in addition, (QString)ident shows its {value}!   8)

(line 36: <http://homepage.gna.org/ldapcppei/archives/ldapEasyAdminFrontends/sources/netfilter.so/main.cpp>)

Is there finaly a problem with C::B 10.05?...  :shock:

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!]

rickkky

?...
(Apparently, it seems that I did not understand the question... (?)
Sorry: I may control the debuggers as badly as the English language - and vice versa ...  :D )

my dbg version is the one of the current ubuntu distribution: gdb 7.3-0ubuntu2...


rickkky

Ok!... (I did not know the concept ...   :D ). Thanks.

It's the same ...
See: "ident.toStdString()" under the cursor (because I cannot add anything in the window "watches", which stays disable) on the screenshot below: the message is the same...

But, this works with "tmp.c_str()" ... (tmp is a std::string)

(this works with "ident" too, but doesn't show its value - only several values of pointers...)

oBFusCATed

Goto to Settings->Debugger... and find the option "Enable watch scripts" then disabled the option and try again.
(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!]

rickkky

Yes, now it's ok ...

(but the window "watches" stays disabled... ;-) - Would I have improperly installed? ...)

oBFusCATed

This is not the watches window:)
This is the new tooltip, which looks like the new watches, but unfortunately you cannot edit watches in there.
The real watches window can be shown with Debug->Debugging windows->Watches
(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!]

rickkky

Oh yes: this is no longer right-click ... but direct entry into the field ...
Very cool the option "Evaluate expression under cursor"...  :D
Thank you very much for your help...