Message ID | 1505995878-10687-1-git-send-email-simon.marchi@ericsson.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 43675 invoked by alias); 21 Sep 2017 12:11:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 43586 invoked by uid 89); 21 Sep 2017 12:11:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=Hx-languages-length:1484 X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Sep 2017 12:11:34 +0000 Received: from ESESSHC003.ericsson.se (Unknown_Domain [153.88.183.27]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id B1.92.20899.37CA3C95; Thu, 21 Sep 2017 14:11:32 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.27) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 21 Sep 2017 14:11:31 +0200 Received: from elxacz23q12.ki.sw.ericsson.se (192.176.1.80) by AM3PR07MB305.eurprd07.prod.outlook.com (2a01:111:e400:881b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.5; Thu, 21 Sep 2017 12:11:29 +0000 From: Simon Marchi <simon.marchi@ericsson.com> To: <gdb-patches@sourceware.org> CC: Simon Marchi <simon.marchi@ericsson.com> Subject: [pushed] microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug Date: Thu, 21 Sep 2017 14:11:18 +0200 Message-ID: <1505995878-10687-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: HE1PR0501CA0016.eurprd05.prod.outlook.com (2603:10a6:3:1a::26) To AM3PR07MB305.eurprd07.prod.outlook.com (2a01:111:e400:881b::13) X-MS-Office365-Filtering-Correlation-Id: 8021ca33-4b70-4c3f-42a6-08d500e9e3e6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM3PR07MB305; X-Microsoft-Exchange-Diagnostics: 1; AM3PR07MB305; 3:n6KA2IGKGtV2PMKiY2Rh32VbZfaMvM3yJnN5lTele8TvDbPeEYmzwpscqEKac0fhsyBjAY5WjPFw9+X2m1zbrQvxc0KYpk8W5KZL05FSMx1VYgkr+dtDxj6agXeb1rGcwNBzm/eE+UBa8PfbcaD9greFaWUBIMn/2+442CsELWBEexnJU0ni+0+aCA9eU0yC8TpOt2ECvziVrrQlDhQwi3/u08+ez9SZEkx0t1Vo/9G8QTGVabgpw68USGNy75Xg; 25:M3+Kjr8MH/V5i2zQNfhXdWKAQD9XQDH7vKLnBMvwGKsfwcO0kbQERg/OgOFgIElsqlmfLVsv4ejqMYSP37BHjB0g6ZGEv1YtcDt1J+ihelWi41uevtFcAnWchmbOrXCKaCU8MUIX1T+0WX3NxH2ogfyo1SoXSaVvhLD3GZbY1JYeXUaXBP8/AxNm2HoLRoujzfqqXQ6eAK02kFsd1s1Ymz5m3a4c13OWp7yelnGCK+IF4WS/YKfy4+dpFMHu7TGPwsRFNnX7mDKQXjSzMrSWcLNhLdWO2J/EE0Zt7f5rMVjwfHZHI+uX9QjsxeluqnlKKqDJ/M7mhuHGxV4o9WP9r9CH81thY+Szv/jESH3vuX0=; 31:YvKWgRNJrkpSVR5VxeUPfyERy4dRncLJ8k4xGi5cHQ1IFRO+2iqmNNZ+EZuffuife2LOaAgH9bPQwpsNd4MgCvujeQJiqt4AnbFV6iPTgoFbuqAFH9gVEpDn2MZpRtNPzsCfh1R1gjFrHQ8Y/0/gELxiuy+/4w+qA0zwsrgJBu7ljV9RfGvdk87gzBbJC9iRXJGCXvaSonH4E5NNLEB25jXJh5Cg6/iuDvJ/Y2T52L0= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PR07MB305: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; AM3PR07MB305; 20:DwBcy06+BSRYKFcFHHJMfWOiWXE4CTJk6hR1u2hZHSxG3KJdfymqObD9w+oHcgi6TYpWudhYJxrnp7WO+1s6CyGpasXgwPwWQMRmHmYtgfCeM3uMBTRsBAEqcQjVhfy1w4h4T/W9FuVAzj9mX++Hf9PnMbD+u1Dfbr9NX7VvCg8oUf/CJiJ8Ze8+w26iMTWEiAbfuxSHptRdwV4CIt77qmitxeTzk/kOOF/ZGvv0AvrNq5CtMBQVlMKIrlt5HTT247IAyXLzS1lWKrk59OHVlKxV3SOAj0f37fuRWbl9bbiHHQBem2pqMdnyvPaOJftvbCerwsmbATVduWuuXvvZYBerdbikwKzxjJ/UA0lTc94lMXrgGPnnEOmJaG1GmbGyRTl/NrZejSqpTk27r6OLh7C4P6r3x6Wf2xMa+M3wUzM4LDPJamcZqlB0sJQCH3ZfU0tVN3F1obmpb8M86Y1qY4uCnQ8S5XbaHLVmVYUqIBDYpyySWSSWkHoI+jkWx44/; 4:AXCBmq3VsFFOEGv3D8zsO7WJxsFTyJYyEbn8EXlVMbJNfoosXB0qmQa2TPASyUwJiXKnHnMvTvC74M7yzjmtEMwhyAhAbQ/O0uLtQp4FTnRqoq0BbC0Bos9U526QLqecnnLp3E5dQ3GnPynBgLAxp+oU/ccJEl5EHG0ETvaMYcah3soYT2tGs2DeG5KQj4IPRVPFVv51+df41Fcb/dleFcq9E03WfAG66q5DnNmbZZr3SId8CXJedg20q9HsEJem6Jbdxlm0ruj/S/S5VnqPPT1EKQe0B7BHN+buhe15e66YV3XoJPi/eQg7zN11os2NayJnFy1IpTPB1ySYJozEnU9m8FsSfszT6jkCPbcG5PyOc2Q6jVtkkP098R3Lbohg X-Exchange-Antispam-Report-Test: UriScan:(37575265505322)(22074186197030)(183786458502308); X-Microsoft-Antispam-PRVS: <AM3PR07MB305D6D44C1DDFB92E7EF18AED660@AM3PR07MB305.eurprd07.prod.outlook.com> X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123558100)(20161123562025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM3PR07MB305; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM3PR07MB305; X-Forefront-PRVS: 04371797A5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(377424004)(199003)(189002)(54534003)(97736004)(33646002)(86362001)(2361001)(53936002)(6116002)(2351001)(3846002)(68736007)(105586002)(106356001)(16586007)(16526017)(316002)(5003940100001)(6506006)(107886003)(6512007)(6306002)(4326008)(47776003)(305945005)(5660300001)(8936002)(966005)(66066001)(6916009)(50986999)(6486002)(189998001)(2906002)(48376002)(6666003)(50466002)(25786009)(36756003)(101416001)(7736002)(50226002)(81166006)(81156014)(478600001)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR07MB305; H:elxacz23q12.ki.sw.ericsson.se; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:3; LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR07MB305; 23:PadYaPYeCM8Odl77nZxEDf497lTwHGUHLXxBAPiotB?= =?us-ascii?Q?wU59uGEvk/sjof1Z/hDxWGzxW1iJb9Tq3pcJ1Zcj1/kiluZWTSd/ygFfEt/P?= =?us-ascii?Q?SzbnrGQRfDXDQmDgAQPMDjGF84NVW629RFtY2aTQ8JnoJ0sFyZS90XPRIh8+?= =?us-ascii?Q?O2mSYBcGBNeBrvdgV67hTUsxTshKdqm06QDlAwWFmo3l8bG6BGdewxw/adsr?= =?us-ascii?Q?BOrqAhWl0x9/yReC7Mgy+ZVhX0PtVhvyxK+ybu5EH+C8ccbZFwJW2UiEqGey?= =?us-ascii?Q?XY2HK2W/iPFbgoRYrUKhvGp5Uxl9nSECZElF2XdWKjWXEhqqZNWm1sMBq3V7?= =?us-ascii?Q?MaxJwG4X7k3boimx3/dnNZcU5BX/lKri1H+bG0LR4AgZ5eb70sdZAju3zCPY?= =?us-ascii?Q?V7v9/8/xOBZ9r+cKVJSqG6euQJCkxBaGCf0QIwHcbm9Onthx1e2o7otbJKuO?= =?us-ascii?Q?rR+r+PnOXviSqJWcMVmP3oef4k+HPFxwUjxHZlhVUpU/OCg354A7+otUj7/W?= =?us-ascii?Q?Y1zVKg1FGjF2JBd4qHx1GHnxx0OCcAhn7wfhd8GSInspG6yl2SeDW8de02gp?= =?us-ascii?Q?v0I5kbQaWVsGb+7M2uZxFYK4KomtWOww7DyXyad5f2C/L+H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1EFhFA7dkPjkvw==; 5:rgjai6f4uPGLpdnC43fil4+NEQfAA3c/uhPp1HvLoY5JiHSUfMhDbArupcs2ATHZOYO/RWaq99+FN89j3egB8mRlziJzAuee9R9NDddS625zO2MZOIMB/z7gDtiQIxq+x2xSuj6nrHXAE3Bffex4BQ==; 24:TfUOn3R4zhf6OPTJujYQkhM1I/LWfZ0btDUURHoTJppjuo/PN9uiibxZO0hsq8CCFJ6KhBKPigG/RwSs2G8dgd65naLh0mJXFyLP0Sfx0Eo=; 7:E/0YPF9VpdLmA4qtgaCS2ECiI+OL2tAc3RPUi7pJPQSuAVW+LUy9c0VisL3gYycZupaWd6yYH6/cL6oT7xpOTTxqPgdG/aFRELWf9a/3G1teUsPdZhCS5Xxn1GNd8SDUIkTLnd1gE1ScQU1/dfFieib22fd6ANLNensVUJUv4YVD60Frfbt76JEcifuNio9tegoLOdaT8hhaz/lEXeaaVWH5yDWogbv28rbhZnZQmUQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2017 12:11:29.1658 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR07MB305 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes |
Commit Message
Simon Marchi
Sept. 21, 2017, 12:11 p.m. UTC
I am getting this warning with clang: /home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error: format string is not a string literal [-Werror,-Wformat-nonliteral] vprintf_unfiltered (fmt, args); ^~~ Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it. Strangely, gcc doesn't warn about non-literal format strings when calling vprintf (or a vprintf-style function, like vprintf_unfiltered). I filed this gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206 gdb/ChangeLog: * microblaze-tdep.c (microblaze_debug): Add ATTRIBUTE_PRINTF. --- gdb/ChangeLog | 4 ++++ gdb/microblaze-tdep.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
Comments
On 09/21/2017 05:11 AM, Simon Marchi wrote: > I am getting this warning with clang: > > /home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error: format string is not a string literal [-Werror,-Wformat-nonliteral] > vprintf_unfiltered (fmt, args); > ^~~ > > Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it. Strangely, > gcc doesn't warn about non-literal format strings when calling vprintf > (or a vprintf-style function, like vprintf_unfiltered). I filed this > gcc bug: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206 I'll admit to not being familiar with the nuances of __attribute__ ((format ...)), or why adding this to the function declaration of microblaze_debug() would suppress a diagnostic on the call to vprintf_unfiltered(), but the better fix seems to me to be to turn off the obviously inappropriate -Wformat-nonliteral option in microblaze_debug() using #pragma GCC diagnostic ignored "-Wformat-nonliteral" See https://stackoverflow.com/questions/12171132/avoid-warning-in-wrapper-around-printf
On 09/25/2017 03:14 PM, Michael Eager wrote: > On 09/21/2017 05:11 AM, Simon Marchi wrote: >> I am getting this warning with clang: >> >> /home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error: >> format string is not a string literal [-Werror,-Wformat-nonliteral] >> vprintf_unfiltered (fmt, args); >> ^~~ >> >> Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it. Strangely, >> > gcc doesn't warn about non-literal format strings when calling vprintf >> (or a vprintf-style function, like vprintf_unfiltered). I filed this >> gcc bug: >> >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206 > > I'll admit to not being familiar with the nuances of __attribute__ > ((format ...)), > or why adding this to the function declaration of microblaze_debug() > would suppress > a diagnostic on the call to vprintf_unfiltered(), Because with that the compiler can assume that the 'fmt' argument as passed down to microblaze_debug is a string literal. I.e., the compiler can tell that the argument to vprintf_unfiltered is itself transitively a string literal. > but the better fix > seems to me to > be to turn off the obviously inappropriate -Wformat-nonliteral option in > microblaze_debug() using > #pragma GCC diagnostic ignored "-Wformat-nonliteral" That doesn't make sense to me. Thanks, Pedro Alves
On 09/25/2017 09:06 AM, Pedro Alves wrote: >> but the better fix >> seems to me to >> be to turn off the obviously inappropriate -Wformat-nonliteral option in >> microblaze_debug() using >> #pragma GCC diagnostic ignored "-Wformat-nonliteral" > That doesn't make sense to me. The argument passed to vprintf_unformatted in microblaze_debug is not a string literal. The diagnostic message is correct. If you don't want the diagnostic, turning it off seems correct. This is somewhat moot. All uses of microblaze_debug use literal string formats, so adding ATTRIBUTE_PRINTF is OK.
On 09/25/2017 05:43 PM, Michael Eager wrote: > On 09/25/2017 09:06 AM, Pedro Alves wrote: >>> but the better fix >>> seems to me to >>> be to turn off the obviously inappropriate -Wformat-nonliteral option in >>> microblaze_debug() using >>> #pragma GCC diagnostic ignored "-Wformat-nonliteral" >> That doesn't make sense to me. > > The argument passed to vprintf_unformatted in microblaze_debug is not a > string > literal. The diagnostic message is correct. If you don't want the > diagnostic, > turning it off seems correct. The diagnostic hasn't gone away. Instead, a warning is now emitted one level up, at the microblaze_debug call sites, iff someone passes a non-literal string as format string by mistake. That makes total sense, because microblaze_debug is just a wrapper around *printf_unfiltered. > This is somewhat moot. All uses of microblaze_debug use literal string > formats, > so adding ATTRIBUTE_PRINTF is OK. And if someone passes a non-literal format, we'll get a warning then. If we suppressed the warning inside microblaze_debug as you were suggesting, then we'd risk passing a non-literal as format string to vprintf_unfiltered. That's the whole point. Thanks, Pedro Alves
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index adafa4c..88e7a6e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-09-21 Simon Marchi <simon.marchi@ericsson.com> + + * microblaze-tdep.c (microblaze_debug): Add ATTRIBUTE_PRINTF. + 2017-09-21 Yao Qi <yao.qi@linaro.org> * configure.tgt (aarch64*-*-freebsd*): Add fbsd-tdep.o solib-svr4.o diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 7547581..caa7d2f 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -82,7 +82,7 @@ static const char *microblaze_register_names[] = static unsigned int microblaze_debug_flag = 0; -static void +static void ATTRIBUTE_PRINTF (1, 2) microblaze_debug (const char *fmt, ...) { if (microblaze_debug_flag)