From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29679 invoked by alias); 11 Mar 2010 15:44:20 -0000 Received: (qmail 29638 invoked by uid 22791); 11 Mar 2010 15:44:19 -0000 X-SWARE-Spam-Status: No, hits=-7.9 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Mar 2010 15:44:14 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2BFhhnm022246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Mar 2010 10:43:44 -0500 Received: from qcore.mollernet.net (vpn-234-88.phx2.redhat.com [10.3.234.88]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2BFhg3i017784; Thu, 11 Mar 2010 10:43:42 -0500 Message-ID: <4B990FAE.2090600@redhat.com> Date: Thu, 11 Mar 2010 15:44:00 -0000 From: Chris Moller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: tromey@redhat.com CC: Jan Kratochvil , Vladimir Prus , Joel Brobecker , gdb-patches@sourceware.org Subject: Re: pr 11067 patch resurrected from the dead References: <20100212041137.GE2907@adacore.com> <4B75783D.6050103@redhat.com> <20100213114933.GA595@host0.dyn.jankratochvil.net> <4B76F5CE.30704@redhat.com> <20100219142846.GC2779@adacore.com> <20100219143609.GA1210@host0.dyn.jankratochvil.net> <4B7EA5F9.6030001@redhat.com> <20100219185004.GA23504@host0.dyn.jankratochvil.net> <4B7EEBC8.7060206@redhat.com> <20100219201105.GA30692@host0.dyn.jankratochvil.net> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070705030307040401080200" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00413.txt.bz2 This is a multi-part message in MIME format. --------------070705030307040401080200 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1520 On 02/23/10 18:54, Tom Tromey wrote: >>>>>> "Jan" == Jan Kratochvil writes: >>>>>> > > Finally catching up on this thread... > > Jan> I would prefer the value_print_options way but rather: > Okay, folks, I dusted this off and spun another simple patch using value_print_options. Given an enum: enum tt { T0, T1, T2 }; enum tt tf = T1; If you do p /f tf you'll get $1 = T1 = (enum tt)1 of instead of the $2 = T1 you'd get without the /f flag. (It's "/f" because 'f' isn't otherwise used for enums--'f' for "fancy" or something like that.) It also doesn't differentiate between printing single enums and enums in more complex things like arrays. Given enum tt ta[] = { T1, T0, T2 }; The result would be: p /f ta $3 = {T1 = (enum tt)1, T0 = (enum tt)0, T2 = (enum tt)2} As an alternative, maybe it could print something like $2 = (enum tt)1 which kind looks like the result of printing a character. As you can see in the attached check summary diff, this patch doesn't do a thing to MI or anything else. If people like this, great. Otherwise, I'll leave it dead and buried. > Yes, I think value_print_options is preferable to checking > ui_out_is_mi_like_p. My reason is that getting the ui-out object > involves looking at some global state, whereas value_print_options is > local to the call hierarchy. This means that it is simpler to reason > about and modify. > > Tom > --------------070705030307040401080200 Content-Type: text/x-patch; name="pr11067.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr11067.patch" Content-length: 3815 Index: printcmd.c =================================================================== RCS file: /cvs/src/src/gdb/printcmd.c,v retrieving revision 1.173 diff -u -r1.173 printcmd.c --- printcmd.c 5 Mar 2010 20:18:14 -0000 1.173 +++ printcmd.c 11 Mar 2010 15:20:44 -0000 @@ -373,6 +373,46 @@ current_language); return; } + + if (TYPE_CODE (type) == TYPE_CODE_ENUM + && options->format == 'f') + { + unsigned flen, i; + LONGEST val; + + flen = TYPE_NFIELDS (type); + val = unpack_long (type, valaddr); + + for (i = 0; i < flen; i++) + { + if (val == TYPE_FIELD_BITPOS (type, i)) + { + break; + } + } + if (i < flen) + { + char *enum_name; + + if (TYPE_NAME (type)) + enum_name = TYPE_NAME (type); + else if (TYPE_TAG_NAME(type)) + enum_name = TYPE_TAG_NAME(type); + else + enum_name = ""; + + fprintf_filtered (stream, "%s = (enum %s)%s", + TYPE_FIELD_NAME (type, i), + enum_name, + plongest (val)); + } + else + { + warning (_("Enum fancy formatting failed, using simple format.")); + print_longest (stream, 'd', 0, val); + } + return; + } if (len > sizeof(LONGEST) && (TYPE_CODE (type) == TYPE_CODE_INT Index: testsuite/gdb.base/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/Makefile.in,v retrieving revision 1.5 diff -u -r1.5 Makefile.in --- testsuite/gdb.base/Makefile.in 15 Sep 2009 03:30:08 -0000 1.5 +++ testsuite/gdb.base/Makefile.in 11 Mar 2010 15:20:45 -0000 @@ -12,7 +12,8 @@ scope section_command setshow setvar shmain sigall signals \ solib solib_sl so-impl-ld so-indr-cl \ step-line step-test structs structs2 \ - twice-tmp varargs vforked-prog watchpoint whatis catch-syscall + twice-tmp varargs vforked-prog watchpoint whatis catch-syscall \ + pr11067 MISCELLANEOUS = coremmap.data ../foobar.baz \ shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl Index: testsuite/gdb.base/pr11067.c =================================================================== RCS file: testsuite/gdb.base/pr11067.c diff -N testsuite/gdb.base/pr11067.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr11067.c 11 Mar 2010 15:20:45 -0000 @@ -0,0 +1,18 @@ +#include + +typedef enum { E0, E1, E2 } ex_e; +ex_e ef = E2; + +enum tt { + T0, + T1, + T2 +}; + +enum tt tf = T1; + +int +main() +{ + return 0; +} Index: testsuite/gdb.base/pr11067.exp =================================================================== RCS file: testsuite/gdb.base/pr11067.exp diff -N testsuite/gdb.base/pr11067.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr11067.exp 11 Mar 2010 15:20:45 -0000 @@ -0,0 +1,28 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile pr11067 +set srcfile ${testfile}.c +if [prepare_for_testing $testfile.exp $testfile $srcfile {debug}] { + return -1 +} + +if ![runto_main] then { + fail "Can't run to main" + return +} + +gdb_test "p /f tf" "T1 = \\(enum tt\\)1.*" +gdb_test "p /f ef" "E2 = \\(enum \\)2.*" --------------070705030307040401080200 Content-Type: text/x-patch; name="pr11067-check.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr11067-check.diff" Content-length: 1475 --- ../../../gdb-virgin.sum 2010-03-09 21:36:05.994326240 -0500 +++ gdb.sum 2010-03-11 10:26:51.188200869 -0500 @@ -1,4 +1,4 @@ -Test Run By moller on Tue Mar 9 19:14:09 2010 +Test Run By moller on Thu Mar 11 10:18:45 2010 Native configuration is i686-pc-linux-gnu === gdb tests === @@ -5703,6 +5703,9 @@ PASS: gdb.base/pr11022.exp: breakpoint hit 2 PASS: gdb.base/pr11022.exp: set var x = 1 PASS: gdb.base/pr11022.exp: watchpoint hit 2 +Running ../../../src/gdb/testsuite/gdb.base/pr11067.exp ... +PASS: gdb.base/pr11067.exp: p /f tf +PASS: gdb.base/pr11067.exp: p /f ef Running ../../../src/gdb/testsuite/gdb.base/prelink.exp ... PASS: gdb.base/prelink.exp: set verbose on PASS: gdb.base/prelink.exp: prelink @@ -16058,7 +16061,7 @@ PASS: gdb.threads/watchthreads2.exp: all threads started PASS: gdb.threads/watchthreads2.exp: watch x PASS: gdb.threads/watchthreads2.exp: set var test_ready = 1 -PASS: gdb.threads/watchthreads2.exp: all threads incremented x +KFAIL: gdb.threads/watchthreads2.exp: gdb can drop watchpoints in multithreaded app (PRMS: gdb/10116) Running ../../../src/gdb/testsuite/gdb.trace/actions.exp ... PASS: gdb.trace/actions.exp: 5.1a: set three tracepoints, no actions PASS: gdb.trace/actions.exp: 5.1b: set actions for first tracepoint @@ -16259,7 +16262,7 @@ === gdb Summary === -# of expected passes 15452 +# of expected passes 15453 # of unexpected failures 16 # of expected failures 43 # of untested testcases 3 --------------070705030307040401080200--