From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11606 invoked by alias); 16 Jan 2014 23:31:38 -0000 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 Received: (qmail 11596 invoked by uid 89); 16 Jan 2014 23:31:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qa0-f73.google.com Received: from mail-qa0-f73.google.com (HELO mail-qa0-f73.google.com) (209.85.216.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 16 Jan 2014 23:31:36 +0000 Received: by mail-qa0-f73.google.com with SMTP id w5so305071qac.4 for ; Thu, 16 Jan 2014 15:31:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=r6j30w2lITCSnRjStI0np59ogGFPIEqIA1cs6Vuf88U=; b=RmQZtOGc8dVPgubbr7pb7KcT1pDrN4blBkyXxc89C+YUo2ULYSOKci7pyhioADhCyj e4qtQXJBnPYd1c1ih+NVz1mVaodmQwp1PYI124BjxNWHrlmtZT150A0A34Y3ishC8mfU mvT+ZW+rs1Al5TqPUrlaROwGr4xp+H2nBBeXS0ZXP7e8cXhqcUM4S2i8s1driW9wgb43 qfNJ6LSj8gJvAJRe7N8Zm8Lk1KYi2guzY+V7Sb1+EZCEa+wJShgwznQr2o58+7ZCEP3q /Y9DxnKG2If+16fLSRAkFyk/JHeq6PbZ/ZXcG8uj16Bzr45luXzx/zHvatPkfNTlgEzh eEgQ== X-Gm-Message-State: ALoCoQlE6aARrOLXt3apGt09pCAhbxX9X0eycuH8pvdT0UyuwfiQRNuMcjCywLrgbE2u7953n8Q3fxX156Mweafn8Y1iO12DSVZi3iVDOLQn2Ky80iF6gS6Ig3eGxMMe2xSYz15kcFb8e8IgLXFNmoBH2R9NGUG2Q70HrJgeUL8/nccpsD5Gzhx/vOOTWWwbXwx+EvnxBr8sWOZnEBtMk7Yg37efGK5+oQ== X-Received: by 10.58.190.68 with SMTP id go4mr4498831vec.7.1389915094314; Thu, 16 Jan 2014 15:31:34 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id v64si2971256yhm.3.2014.01.16.15.31.34 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jan 2014 15:31:34 -0800 (PST) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 9B1585A42EB; Thu, 16 Jan 2014 15:31:33 -0800 (PST) From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21208.27605.74231.313332@ruffy.mtv.corp.google.com> Date: Thu, 16 Jan 2014 23:31:00 -0000 To: Pedro Alves , Yao Qi cc: gdb-patches Subject: [PATCH 1/3] gdbserver debug_printf+timestamps: FUNCTION_NAME In-Reply-To: <21208.27400.695984.88504@ruffy.mtv.corp.google.com> References: <52B1842F.5020401@redhat.com> <21205.55987.69477.892571@ruffy.mtv.corp.google.com> <52D81569.3080006@redhat.com> <52D82AD5.7000306@redhat.com> <21208.27400.695984.88504@ruffy.mtv.corp.google.com> X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg00658.txt.bz2 Doug Evans writes: > v2 is now split into three parts: > > 1/3 - move ASSERT_FUNCTION to FUNCTION_NAME in common-utils.h > 2/3 - create new function delim_string_to_char_ptr_vec_append in gdb_vecs.c > 3/3 - the actual debug_printf patch > > I went with --debug[=timestamp] as the option naming. I didn't do a darwin build but the change is mechanical. 2014-01-16 Doug Evans * common/common-utils.h (FUNCTION_NAME): Renamed from ASSERT_FUNCTION, and moved here ... * common/gdb_assert.h (ASSERT_FUNCTION): ... from here. #include "common-utils.h". (gdb_assert, gdb_assert_fail, gdb_assert_not_reached): Update. * common/vec.h (VEC_ASSERT_PASS): Update. * darwin-nat.h: Replace #include of gdb_assert.h with common-utils.h. (MACH_CHECK_ERROR): Update. diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h index 9777ac0..2d99549 100644 --- a/gdb/common/common-utils.h +++ b/gdb/common/common-utils.h @@ -25,6 +25,19 @@ #include #include +/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' + which contains the name of the function currently being defined. + This is broken in G++ before version 2.6. + C9x has a similar variable called __func__, but prefer the GCC one since + it demangles C++ function names. */ +#if (GCC_VERSION >= 2004) +#define FUNCTION_NAME __PRETTY_FUNCTION__ +#else +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +#define FUNCTION_NAME __func__ +#endif +#endif + extern void malloc_failure (long size) ATTRIBUTE_NORETURN; extern void internal_error (const char *file, int line, const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4); diff --git a/gdb/common/gdb_assert.h b/gdb/common/gdb_assert.h index 50f7bf2..4869fc4 100644 --- a/gdb/common/gdb_assert.h +++ b/gdb/common/gdb_assert.h @@ -19,6 +19,8 @@ #ifndef GDB_ASSERT_H #define GDB_ASSERT_H +#include "common-utils.h" /* For FUNCTION_NAME. */ + /* A static assertion. This will cause a compile-time error if EXPR, which must be a compile-time constant, is false. */ @@ -32,24 +34,11 @@ #define gdb_assert(expr) \ ((void) ((expr) ? 0 : \ - (gdb_assert_fail (#expr, __FILE__, __LINE__, ASSERT_FUNCTION), 0))) - -/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' - which contains the name of the function currently being defined. - This is broken in G++ before version 2.6. - C9x has a similar variable called __func__, but prefer the GCC one since - it demangles C++ function names. */ -#if (GCC_VERSION >= 2004) -#define ASSERT_FUNCTION __PRETTY_FUNCTION__ -#else -#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L -#define ASSERT_FUNCTION __func__ -#endif -#endif + (gdb_assert_fail (#expr, __FILE__, __LINE__, FUNCTION_NAME), 0))) /* This prints an "Assertion failed" message, asking the user if they want to continue, dump core, or just exit. */ -#if defined (ASSERT_FUNCTION) +#if defined (FUNCTION_NAME) #define gdb_assert_fail(assertion, file, line, function) \ internal_error (file, line, _("%s: Assertion `%s' failed."), \ function, assertion) @@ -62,9 +51,9 @@ /* The canonical form of gdb_assert (0). MESSAGE is a string to include in the error message. */ -#if defined (ASSERT_FUNCTION) +#if defined (FUNCTION_NAME) #define gdb_assert_not_reached(message) \ - internal_error (__FILE__, __LINE__, "%s: %s", ASSERT_FUNCTION, _(message)) + internal_error (__FILE__, __LINE__, "%s: %s", FUNCTION_NAME, _(message)) #else #define gdb_assert_not_reached(message) \ internal_error (__FILE__, __LINE__, _(message)) diff --git a/gdb/common/vec.h b/gdb/common/vec.h index 9874573..7bae2ff 100644 --- a/gdb/common/vec.h +++ b/gdb/common/vec.h @@ -398,7 +398,7 @@ extern void *vec_o_reserve (void *, int, size_t, size_t); #define VEC_ASSERT_PASS ,file_,line_ #define vec_assert(expr, op) \ ((void)((expr) ? 0 : (gdb_assert_fail (op, file_, line_, \ - ASSERT_FUNCTION), 0))) + FUNCTION_NAME), 0))) #define VEC(T) VEC_##T #define VEC_OP(T,OP) VEC_##T##_##OP diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h index 6d42a3b..84f4be1 100644 --- a/gdb/darwin-nat.h +++ b/gdb/darwin-nat.h @@ -18,7 +18,7 @@ #define __DARWIN_NAT_H__ #include -#include "gdb_assert.h" +#include "common-utils.h" /* For FUNCTION_NAME. */ /* Describe the mach exception handling state for a task. This state is saved before being changed and restored when a process is detached. @@ -136,10 +136,10 @@ extern mach_port_t darwin_port_set; /* A copy of mach_host_self (). */ extern mach_port_t darwin_host_self; -/* ASSERT_FUNCTION is defined in gdb_assert.h (or not). */ -#ifdef ASSERT_FUNCTION +/* FUNCTION_NAME is defined in common-utils.h (or not). */ +#ifdef FUNCTION_NAME #define MACH_CHECK_ERROR(ret) \ - mach_check_error (ret, __FILE__, __LINE__, ASSERT_FUNCTION) + mach_check_error (ret, __FILE__, __LINE__, FUNCTION_NAME) #else #define MACH_CHECK_ERROR(ret) \ mach_check_error (ret, __FILE__, __LINE__, "??")