public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "xdje42 at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/18175] New: gdb.parse_and_eval should un-lazy results
Date: Sun, 29 Mar 2015 21:52:00 -0000	[thread overview]
Message-ID: <bug-18175-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=18175

            Bug ID: 18175
           Summary: gdb.parse_and_eval should un-lazy results
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: xdje42 at gmail dot com

gdb.parse_and_eval should un-lazy its results.

Otherwise the following can happen.

Try 1:

(gdb) py foo = gdb.parse_and_eval ("*(char*) $sp")
(gdb) x/b $sp
0x7fffffffe1c0: 0
(gdb) py print foo
0 '\000'
(gdb) set *(char*) $sp = 42
(gdb) x/b $sp
0x7fffffffe1c0: 42
(gdb) py print foo
0 '\000' <<<<< expected result

Try 2:

(gdb) py foo = gdb.parse_and_eval ("*(char*) $sp")
(gdb) set *(char*) $sp = 43
(gdb) py print foo
43 '+' <<<<< Ugh.
(gdb) 

Note that in the first example, the "py print foo" before modifying
memory is sufficient to un-lazy the value.
I point this out to show that if we don't make this change then
debugging such things can be nasty: a simple "print" can modify
program behaviour.

Guile's parse-and-eval has the same issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2015-03-28 22:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-29 21:52 xdje42 at gmail dot com [this message]
2022-06-06 23:30 ` [Bug python/18175] " tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-18175-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).