Author Topic: Attempt to take address of value not located in memory during debugging - solved  (Read 19572 times)

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
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>

« Last Edit: December 02, 2011, 10:00:04 pm by rickkky »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Attempt to take address of value not located in memory
« Reply #1 on: November 26, 2011, 06:49:48 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory
« Reply #2 on: November 26, 2011, 11:01:44 pm »
Quote
Are 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...).
« Last Edit: November 29, 2011, 12:59:44 am by rickkky »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Attempt to take address of value not located in memory
« Reply #3 on: November 27, 2011, 10:17:00 am »
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory
« Reply #4 on: November 28, 2011, 02:44:06 am »
Quote
What about if you try a recent debugger nightly? Debugging has improved a lot!
This seems the same, but I live in GMT-10... ;-)

Quote
Note 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.  :?
« Last Edit: November 29, 2011, 12:55:21 am by rickkky »

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory during debugging
« Reply #5 on: November 28, 2011, 08:46:34 pm »
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:
« Last Edit: November 28, 2011, 09:13:46 pm by rickkky »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Attempt to take address of value not located in memory
« Reply #6 on: November 29, 2011, 01:39:41 am »
What about if you try a recent debugger nightly? Debugging has improved a lot!
(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 rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory during debugging
« Reply #7 on: November 29, 2011, 02:53:44 am »
?...
(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...
« Last Edit: November 29, 2011, 03:19:31 am by rickkky »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory during debugging
« Reply #9 on: November 29, 2011, 10:27:32 am »
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...)
« Last Edit: November 29, 2011, 10:59:23 am by rickkky »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Attempt to take address of value not located in memory during debugging
« Reply #10 on: November 29, 2011, 10:31:52 am »
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!]

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory during debugging
« Reply #11 on: November 29, 2011, 10:40:40 am »
Yes, now it's ok ...

(but the window "watches" stays disabled... ;-) - Would I have improperly installed? ...)
« Last Edit: November 29, 2011, 10:44:53 am by rickkky »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Attempt to take address of value not located in memory during debugging
« Reply #12 on: November 29, 2011, 10:46:13 am »
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!]

Offline rickkky

  • Single posting newcomer
  • *
  • Posts: 9
Re: Attempt to take address of value not located in memory during debugging
« Reply #13 on: November 29, 2011, 10:55:43 am »
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...
« Last Edit: November 29, 2011, 11:10:43 am by rickkky »