Discussion:
[Bug cli/22573] New: "finish" doesn't respect "set print pretty"
tromey at sourceware dot org
2017-12-08 16:25:14 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

Bug ID: 22573
Summary: "finish" doesn't respect "set print pretty"
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: cli
Assignee: unassigned at sourceware dot org
Reporter: tromey at sourceware dot org
Target Milestone: ---

I "finished" from a function that returned a structure and got:

Value returned is $10 = (0x7fffe45a98c8,
rustc_trans::debuginfo::metadata::MemberDescriptionFactory::VariantMDF(rustc_trans::debuginfo::metadata::VariantMemberDescriptionFactory
{offsets: alloc::vec::Vec<rustc::ty::layout::Size> {buf:
alloc::raw_vec::RawVec<rustc::ty::layout::Size, alloc::heap::Heap> {ptr:
core::ptr::Unique<rustc::ty::layout::Size> {pointer:
core::nonzero::NonZero<*const rustc::ty::layout::Size> (0x7fffe43b2b10),
_marker: core::marker::PhantomData<rustc::ty::layout::Size>}, cap: 2, a:
alloc::heap::Heap}, len: 2}, args: alloc::vec::Vec<(alloc::string::String,
&rustc::ty::TyS)> {buf: alloc::raw_vec::RawVec<(alloc::string::String,
&rustc::ty::TyS), alloc::heap::Heap> {ptr:
core::ptr::Unique<(alloc::string::String, &rustc::ty::TyS)> {pointer:
core::nonzero::NonZero<*const (alloc::string::String, &rustc::ty::TyS)>
(0x7fffe4bbaa90), _marker: core::marker::PhantomData<(alloc::string::String,
&rustc::ty::TyS)>}, cap: 2, a: alloc::heap::Heap}, len: 2}, span:
syntax_pos::span_encoding::Span (71170)}))

That's all on one line.
I expected it to respect "set print pretty", but it did not.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-04-12 20:08:28 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Keywords| |good-first-bug
--
You are receiving this mail because:
You are on the CC list for the bug.
vries at gcc dot gnu.org
2018-06-08 10:23:33 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

Tom de Vries <vries at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |vries at gcc dot gnu.org

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 11062
--> https://sourceware.org/bugzilla/attachment.cgi?id=11062&action=edit
Tentative patch
--
You are receiving this mail because:
You are on the CC list for the bug.
vries at gcc dot gnu.org
2018-06-08 11:52:44 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

Tom de Vries <vries at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Attachment #11062|0 |1
is obsolete| |

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 11063
--> https://sourceware.org/bugzilla/attachment.cgi?id=11063&action=edit
Updated tentative patch, with test-case
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-06-08 15:43:37 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Thanks for the patch. It looks basically good to me.
I wonder why the timeout stuff was needed in the .exp.
Also instead of "runto main" it seems like it could just
run directly to the desired stopping point.
Also it needs a ChangeLog entry.

To submit the patch for real, see the contribution checklist:

https://sourceware.org/gdb/wiki/ContributionChecklist

Patch review & discussion normally occurs on the gdb-patches list.
--
You are receiving this mail because:
You are on the CC list for the bug.
vries at gcc dot gnu.org
2018-06-10 13:42:32 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #3)
Post by tromey at sourceware dot org
Thanks for the patch. It looks basically good to me.
I wonder why the timeout stuff was needed in the .exp.
That was just a copy-paste from finish.exp. Removed.
Post by tromey at sourceware dot org
Also instead of "runto main" it seems like it could just
run directly to the desired stopping point.
Also a copy-paste from finish.exp. Removed.
Post by tromey at sourceware dot org
Also it needs a ChangeLog entry.
https://sourceware.org/gdb/wiki/ContributionChecklist
Patch review & discussion normally occurs on the gdb-patches list.
Patch with ChangeLog entry posted:
https://sourceware.org/ml/gdb-patches/2018-06/msg00248.html
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-06-14 13:32:53 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5d9a06087942ddf4f9ab724b5b4c1a45507d8321

commit 5d9a06087942ddf4f9ab724b5b4c1a45507d8321
Author: Tom de Vries <***@suse.de>
Date: Fri Jun 8 12:37:53 2018 +0200

[gdb/cli] Honour 'print pretty' when printing result of finish command

Consider this testcase:
...
struct s {
int a;
int b;
};

struct s foo ()
{
struct s r;
r.a = 1;
r.b = 2;
return r;
}

int
main (void)
{
struct s v;
v = foo ();
return v.a + v.b;
}
...

When we compile it with -g, load the exec with gdb, and run till the end of
foo,
we can print r:
...
(gdb) p r
$1 = {a = 1, b = 2}
...

and by setting pretty printing to on, we can get the fields of r printed
each
on its own line:
...
(gdb) set print pretty
(gdb) p r
$2 = {
a = 1,
b = 2
}
...

However, when we finish foo, the printed function result value is not using
the pretty printing setting:
...
(gdb) finish
Run till exit from #0 foo () at test.c:11
0x00000000004004c1 in main () at test.c:18
18 v = foo ();
Value returned is $3 = {a = 1, b = 2}
...

This patch fixes that by using get_user_print_options instead of
get_no_prettyformat_print_options in print_return_value_1, which gives us:
...
(gdb) finish
Run till exit from #0 foo () at test.c:11
0x00000000004004c1 in main () at test.c:18
18 v = foo ();
Value returned is $2 = {
a = 1,
b = 2
}
...

Build & reg-tested on x86_64.

2018-06-14 Tom de Vries <***@suse.de>

PR cli/22573
* infcmd.c (print_return_value_1): Use get_user_print_options instead
of
get_no_prettyformat_print_options.

* gdb.base/finish-pretty.c: New test.
* gdb.base/finish-pretty.exp: New file.
--
You are receiving this mail because:
You are on the CC list for the bug.
vries at gcc dot gnu.org
2018-06-14 13:34:10 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

Tom de Vries <vries at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch with test-case committed, marking resolved-fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-06-14 14:05:51 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22573

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |palves at redhat dot com
Target Milestone|--- |8.2
--
You are receiving this mail because:
You are on the CC list for the bug.
Continue reading on narkive:
Loading...