public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11606] New: multiple inferior calls with struct return values behave not well.
@ 2010-05-17  8:32 andre dot poenitz at nokia dot com
  2010-05-17 11:06 ` [Bug c++/11606] " pedro at codesourcery dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-05-17  8:32 UTC (permalink / raw)
  To: gdb-prs

Evaluating expressions involving sequences of calls with non-trivial
intermediate values produce errors like "Attempt to take address of value not
located in memory." or, in other cases, gdb reporting SIGSEGV in the inferior.

To reproduce:

  echo 'struct S {}; S f() { return S(); } S g(const S &s) { return s; } int
main() { S s = g(f()); }' | g++ -xc++ -o x -g -
  gdb -ex 'b main' -ex run -ex 'p g(f())' ./x

My guess is that the result of the call is transfered from the inferior into
gdb, but not "moved back" for further processing.

The problem can be partially worked around by manually disentangling the calls
and "poking" the intermediate results back into the inferior using something like

def makeValue(type, init):
    gdb.execute("set $d = (%s*)malloc(sizeof(%s))" % (type, type))
    gdb.execute("set *$d = {%s}" % init)
    return gdb.parse_and_eval("$d").dereference()

-- 
           Summary: multiple inferior calls with struct return values behave
                    not well.
           Product: gdb
           Version: 7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: andre dot poenitz at nokia dot com
                CC: gdb-prs at sourceware dot org
 GCC build triplet: i486-linux-gnu, applies to any
  GCC host triplet: i486-linux-gnu, applies to any
GCC target triplet: i486-linux-gnu, applies to any


http://sourceware.org/bugzilla/show_bug.cgi?id=11606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/11606] multiple inferior calls with struct return values behave not well.
  2010-05-17  8:32 [Bug c++/11606] New: multiple inferior calls with struct return values behave not well andre dot poenitz at nokia dot com
@ 2010-05-17 11:06 ` pedro at codesourcery dot com
  2010-05-17 13:32 ` andre dot poenitz at nokia dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pedro at codesourcery dot com @ 2010-05-17 11:06 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pedro at codesourcery dot com  2010-05-17 11:06 -------
Are you saying that the same example sometimes crashes the inferior, while
sometimes results in the "Attempt to take address of value not located in
memory." error, or do you need a different reproducer to cause
SIGSEGV crash in the inferior?  If the latter, do you have such a
reproducer?


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/11606] multiple inferior calls with struct return values behave not well.
  2010-05-17  8:32 [Bug c++/11606] New: multiple inferior calls with struct return values behave not well andre dot poenitz at nokia dot com
  2010-05-17 11:06 ` [Bug c++/11606] " pedro at codesourcery dot com
@ 2010-05-17 13:32 ` andre dot poenitz at nokia dot com
  2010-08-05 15:12 ` swagiaal at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-05-17 13:32 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From andre dot poenitz at nokia dot com  2010-05-17 13:32 -------
The example given always produces "Attempt to take address of value not
located in memory." as far as I can tell.

The SIGSEGV reports have been showing up in a somewhat more complex setup
involving Qt Creator's pretty-printers for QObject and QModelIndex that also
uses cascaded inferior calls.

I believe the problem is the same, though and would like to save me the trouble
to cut this down to something that's reproducible without a lot of external
dependencies.

Sorry for the confusion.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/11606] multiple inferior calls with struct return values behave not well.
  2010-05-17  8:32 [Bug c++/11606] New: multiple inferior calls with struct return values behave not well andre dot poenitz at nokia dot com
  2010-05-17 11:06 ` [Bug c++/11606] " pedro at codesourcery dot com
  2010-05-17 13:32 ` andre dot poenitz at nokia dot com
@ 2010-08-05 15:12 ` swagiaal at redhat dot com
  2010-08-05 15:13 ` [Bug c++/11606] GDB does not properly implement the default copy constructor swagiaal at redhat dot com
  2010-08-06 21:34 ` swagiaal at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: swagiaal at redhat dot com @ 2010-08-05 15:12 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From swagiaal at redhat dot com  2010-08-05 15:12 -------
Created an attachment (id=4913)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4913&action=view)
test case


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/11606] GDB does not properly implement the default copy constructor
  2010-05-17  8:32 [Bug c++/11606] New: multiple inferior calls with struct return values behave not well andre dot poenitz at nokia dot com
                   ` (2 preceding siblings ...)
  2010-08-05 15:12 ` swagiaal at redhat dot com
@ 2010-08-05 15:13 ` swagiaal at redhat dot com
  2010-08-06 21:34 ` swagiaal at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: swagiaal at redhat dot com @ 2010-08-05 15:13 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From swagiaal at redhat dot com  2010-08-05 15:13 -------
While the example mentioned can be fixed by setting the lval of the value
returned by call_function_by_hand() lval_memory further nesting does not work.
example attached.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
            Summary|multiple inferior calls with|GDB does not properly
                   |struct return values behave |implement the default copy
                   |not well.                   |constructor


http://sourceware.org/bugzilla/show_bug.cgi?id=11606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/11606] GDB does not properly implement the default copy constructor
  2010-05-17  8:32 [Bug c++/11606] New: multiple inferior calls with struct return values behave not well andre dot poenitz at nokia dot com
                   ` (3 preceding siblings ...)
  2010-08-05 15:13 ` [Bug c++/11606] GDB does not properly implement the default copy constructor swagiaal at redhat dot com
@ 2010-08-06 21:34 ` swagiaal at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: swagiaal at redhat dot com @ 2010-08-06 21:34 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From swagiaal at redhat dot com  2010-08-06 21:34 -------
This issue was also discussed here:
http://www.cygwin.com/ml/gdb-patches/2010-08/msg00053.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |swagiaal at redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=11606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-06 21:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17  8:32 [Bug c++/11606] New: multiple inferior calls with struct return values behave not well andre dot poenitz at nokia dot com
2010-05-17 11:06 ` [Bug c++/11606] " pedro at codesourcery dot com
2010-05-17 13:32 ` andre dot poenitz at nokia dot com
2010-08-05 15:12 ` swagiaal at redhat dot com
2010-08-05 15:13 ` [Bug c++/11606] GDB does not properly implement the default copy constructor swagiaal at redhat dot com
2010-08-06 21:34 ` swagiaal at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).