public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/16236] New: add $_memoize function
@ 2013-11-25 16:32 tromey at redhat dot com
  2014-02-26 20:55 ` [Bug python/16236] " tromey at redhat dot com
  2014-04-29 13:55 ` palves at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: tromey at redhat dot com @ 2013-11-25 16:32 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 16236
           Summary: add $_memoize function
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: tromey at redhat dot com

Right now gdb will create a new object in the inferior
on each use.  However, many times this isn't needed.
It would be handy sometimes to have a $_memoize convenience
function that forces its argument to memory just once,
and then for subsequent calls simply returns the same object.

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


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

* [Bug python/16236] add $_memoize function
  2013-11-25 16:32 [Bug python/16236] New: add $_memoize function tromey at redhat dot com
@ 2014-02-26 20:55 ` tromey at redhat dot com
  2014-04-29 13:55 ` palves at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at redhat dot com @ 2014-02-26 20:55 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom Tromey <tromey at redhat dot com> ---
Phil pointed out that this isn't clear.

If you use a string or a structure in an expression, gdb may allocate
memory in the inferior for it.  IIUC, it will do this each time the
expression is evaluated, and the memory is never freed.

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


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

* [Bug python/16236] add $_memoize function
  2013-11-25 16:32 [Bug python/16236] New: add $_memoize function tromey at redhat dot com
  2014-02-26 20:55 ` [Bug python/16236] " tromey at redhat dot com
@ 2014-04-29 13:55 ` palves at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: palves at redhat dot com @ 2014-04-29 13:55 UTC (permalink / raw)
  To: gdb-prs

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

Pedro Alves <palves at redhat dot com> changed:

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

--- Comment #2 from Pedro Alves <palves at redhat dot com> ---
For string, one can currently do:

 (gdb) set $foo = (char *) "asdf"
 (gdb) p $foo
 $1 = 0xd051e0 "asdf"

For arrays, one can do:

 (gdb) p $bar = (int *) {1, 2}
 $2 = (int *) 0xd05250

For scalars, I've seem people do two-step malloc+set:

 (gdb) p (int *) malloc (sizeof (argc))
 $3 = (int *) 0xd055e0
 (gdb) p *$3 = argc
 $4 = 1

Though one can just use the array syntax there too, simply allocating a
one-element array:

 (gdb) p (int*) { argc }
 $5 = (int *) 0xd05650
 (gdb) p *$29
 $6 = 1

typeof doesn't seem to work here, unfortunately:

 (gdb) p (typeof (argc) *) { argc }
 A syntax error in expression, near `*) { argc }'.

I'm not immediately seeing what's the symtax to lay a structure/object in a
expression, but if possible, I imagine that adding a cast to a struct pointer
might be a way to force coercing the object to memory too.

Not saying $_memoize wouldn't be useful at all -- just pointing at current
syntax/workarounds.  Even if not strictly necessary, it might be a convenient
shortcut.

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


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

end of thread, other threads:[~2014-04-29 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-25 16:32 [Bug python/16236] New: add $_memoize function tromey at redhat dot com
2014-02-26 20:55 ` [Bug python/16236] " tromey at redhat dot com
2014-04-29 13:55 ` palves 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).