public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/18280] New: pointer values returned from pretty-printers are not printed
@ 2015-04-18 20:08 xdje42 at gmail dot com
  2015-04-19 16:53 ` [Bug python/18280] " xdje42 at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: xdje42 at gmail dot com @ 2015-04-18 20:08 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 18280
           Summary: pointer values returned from pretty-printers are not
                    printed
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: xdje42 at gmail dot com

>From #gdb:
https://gist.github.com/TheWug/16b47181a7907b7a7539

The pretty-printer is returning an int * value but gdb isn't printing it.

The problem seems to be in c_val_print, case TYPE_CODE_PTR
and print_address_demangle.

If we end up here:

int
print_address_demangle (const struct value_print_options *opts,
                        struct gdbarch *gdbarch, CORE_ADDR addr,
                        struct ui_file *stream, int do_demangle)
{
  if (opts->addressprint)
    {
      fputs_filtered (paddress (gdbarch, addr), stream);
      print_address_symbolic (gdbarch, addr, stream, do_demangle, " ");
    }
  else
    {
=>    return print_address_symbolic (gdbarch, addr, stream, do_demangle, "");
    }
  return 1;
}

nothing gets printed.

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


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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
@ 2015-04-19 16:53 ` xdje42 at gmail dot com
  2021-01-21 10:12 ` malcolm.parsons at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: xdje42 at gmail dot com @ 2015-04-19 16:53 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Doug Evans <xdje42 at gmail dot com> ---
For reference sake, here's the testcase:

struct Test
{
  Test() { j = 10; i = &j; }
  int *i;
  int j;
};

int main()
{
  Test x;
  ++*x.i;
  return 0;
}

Here's the pretty-printer:

class TestPrinter(object):
 def __init__(self, val):
  self.val = val
 def to_string(self):
  return self.val['i']
def test_printer_hook(val):
 return TestPrinter(val) if val.type.tag == 'Test' else None
for obj in gdb.objfiles():
 obj.pretty_printers.append(test_printer_hook)

# (registration of the pretty-printer is overkill, but no matter)

And here's a sample session:

bash$ gdb a.out # Put pretty-printer in a.out-gdb.py
(gdb) start
(gdb) n
(gdb) n
(gdb) p x
$1 = 
(gdb) p x.i
$2 = (int *) 0x7fffffffe198

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


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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
  2015-04-19 16:53 ` [Bug python/18280] " xdje42 at gmail dot com
@ 2021-01-21 10:12 ` malcolm.parsons at gmail dot com
  2021-01-21 14:12 ` malcolm.parsons at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: malcolm.parsons at gmail dot com @ 2021-01-21 10:12 UTC (permalink / raw)
  To: gdb-prs

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

Malcolm Parsons <malcolm.parsons at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |malcolm.parsons at gmail dot com

--- Comment #5 from Malcolm Parsons <malcolm.parsons at gmail dot com> ---
I can understand not wanting the address of a char* pointer as it will also be
printed as a string, but for every other pointer type, the address is needed.

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

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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
  2015-04-19 16:53 ` [Bug python/18280] " xdje42 at gmail dot com
  2021-01-21 10:12 ` malcolm.parsons at gmail dot com
@ 2021-01-21 14:12 ` malcolm.parsons at gmail dot com
  2021-01-21 14:16 ` malcolm.parsons at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: malcolm.parsons at gmail dot com @ 2021-01-21 14:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Malcolm Parsons <malcolm.parsons at gmail dot com> ---
(In reply to Tom Tromey from comment #2)
> Regression from this thread:
> https://sourceware.org/ml/gdb/2009-11/msg00105.html

Instead of breaking gdb, Paul should have been told to change the pretty
printer to this:

class string_print:
    def __init__(self, val):
        self.val = val

    def display_hint(self):
        return 'string'

    def to_string(self):
        return self.val['whybother']['contents'].string()

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

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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
                   ` (2 preceding siblings ...)
  2021-01-21 14:12 ` malcolm.parsons at gmail dot com
@ 2021-01-21 14:16 ` malcolm.parsons at gmail dot com
  2021-01-21 16:17 ` ppluzhnikov at google dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: malcolm.parsons at gmail dot com @ 2021-01-21 14:16 UTC (permalink / raw)
  To: gdb-prs

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

Malcolm Parsons <malcolm.parsons at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppluzhnikov at google dot com

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

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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
                   ` (3 preceding siblings ...)
  2021-01-21 14:16 ` malcolm.parsons at gmail dot com
@ 2021-01-21 16:17 ` ppluzhnikov at google dot com
  2021-01-21 18:40 ` ssbssa at sourceware dot org
  2021-01-21 18:57 ` malcolm.parsons at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: ppluzhnikov at google dot com @ 2021-01-21 16:17 UTC (permalink / raw)
  To: gdb-prs

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

Paul Pluzhnikov <ppluzhnikov at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |ppluzhnikov at google dot com

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

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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
                   ` (4 preceding siblings ...)
  2021-01-21 16:17 ` ppluzhnikov at google dot com
@ 2021-01-21 18:40 ` ssbssa at sourceware dot org
  2021-01-21 18:57 ` malcolm.parsons at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: ssbssa at sourceware dot org @ 2021-01-21 18:40 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org

--- Comment #7 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to Malcolm Parsons from comment #6)
> (In reply to Tom Tromey from comment #2)
> > Regression from this thread:
> > https://sourceware.org/ml/gdb/2009-11/msg00105.html
> 
> Instead of breaking gdb, Paul should have been told to change the pretty
> printer to this:
> 
> class string_print:
>     def __init__(self, val):
>         self.val = val
> 
>     def display_hint(self):
>         return 'string'
> 
>     def to_string(self):
>         return self.val['whybother']['contents'].string()

Someone did suggest something similar [1], but .string() failed for non-ASCII
characters [2].


[1] https://sourceware.org/legacy-ml/gdb/2009-11/msg00106.html
[2] https://sourceware.org/legacy-ml/gdb/2009-11/msg00107.html

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

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

* [Bug python/18280] pointer values returned from pretty-printers are not printed
  2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
                   ` (5 preceding siblings ...)
  2021-01-21 18:40 ` ssbssa at sourceware dot org
@ 2021-01-21 18:57 ` malcolm.parsons at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: malcolm.parsons at gmail dot com @ 2021-01-21 18:57 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #8 from Malcolm Parsons <malcolm.parsons at gmail dot com> ---
(In reply to Hannes Domani from comment #7)
> Someone did suggest something similar [1],

Without the display_hint, the returned string isn't quoted.

> but .string() failed for non-ASCII characters [2].

PR10705 was fixed by adding .lazy_string().

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

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

end of thread, other threads:[~2021-01-21 18:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-18 20:08 [Bug python/18280] New: pointer values returned from pretty-printers are not printed xdje42 at gmail dot com
2015-04-19 16:53 ` [Bug python/18280] " xdje42 at gmail dot com
2021-01-21 10:12 ` malcolm.parsons at gmail dot com
2021-01-21 14:12 ` malcolm.parsons at gmail dot com
2021-01-21 14:16 ` malcolm.parsons at gmail dot com
2021-01-21 16:17 ` ppluzhnikov at google dot com
2021-01-21 18:40 ` ssbssa at sourceware dot org
2021-01-21 18:57 ` malcolm.parsons at gmail 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).