From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id E3D653858C62 for ; Fri, 20 Jan 2023 09:26:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3D653858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674206786; x=1705742786; h=from:to:subject:date:message-id:references:in-reply-to: mime-version:content-transfer-encoding; bh=SyNT74GWOKM/M11GYdmgT9f0MOj7bV7v7WxCXOjPP4M=; b=eZYptNBPe2SIiZtXe2W8vpJXEW2fBuNtk3LynCVtQ4Mbp3sxjZfyS9hC WyxOPBdYyPrhC20RO/Z8kR6c7hV+X9Ewhb5yYzRxuIsZNOUIThtx9hW0D BoLQDTq1oui3PDxuWpo6WV/JBO9SMt+SQKuiIED6eu5yOTVJp0lyTG3ee zGbeyQZWbEOdKSyPeqKlVISfOrmgwyqkF3be+eiJd6HCv7VyuYcmHWq/4 f6U7VFmqc+9UC4uBeRvizftFV0wJ4CpOChFhn7lvbRMFZXESbUr4LKIMC 2o8iStiGMrwf1cqWffmWLo6l8ZJ+YMPb0LL1ZjHaGAsvMPAYcwoivGvwN Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="313430077" X-IronPort-AV: E=Sophos;i="5.97,231,1669104000"; d="scan'208";a="313430077" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2023 01:26:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="653733630" X-IronPort-AV: E=Sophos;i="5.97,231,1669104000"; d="scan'208";a="653733630" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga007.jf.intel.com with ESMTP; 20 Jan 2023 01:26:24 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 20 Jan 2023 01:26:23 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 20 Jan 2023 01:26:23 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Fri, 20 Jan 2023 01:26:23 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.48) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 20 Jan 2023 01:26:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/CdWJSse4GIahR67vKVApsOqbJUujcINxgxnE1iYzpmoajVWsXIz9+ztjn+YX+laplZwm8em2XhMTbclxX3Ar8tBBivPac94v8e3HHsDaiXjyMtE76OvayWxP/TmU5yym+Rlwic++D11EzAVKyyLMY8Ulk8bQwMaIVp3nULu7C/fPJsVqOBHPe3aZTbz5o7HtBb+ZpnHTIb3DqgXZPUvhQR0otJW/SFGSratwMmUxFzNgKxoijoQIz8vzYOnyKe63+57ayjfsnT0WkwPOGycec1EMmKqXFjOwUWk/3hAi3POZBdi6J+JwpQhGf7zT2q3xmo+u2k9YQbHBTJjHaQ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TxNsEeTzYXbZqM+j74B85lFikE3bfsLb0lPMkFk2Tgw=; b=gRsnKSRlgvcQF+p1l4KBXFgCw5qcGuB2gIfBeByC469P+WTXWHkRezLeCy5aMDA74JMZUqMiJ40/h2W1RH6QfHJjiNK9iubK0QvSLmVdrDk7z2qzwqzT2gLKWXkCi3lX84mjkeY8YH96zqLJ8b1ub5ED981x8GH20MkmwcuHGlBUCnReLqkAc4cMdiXEqUipMR3bsBhySVgWW34iJMnL+2VyC0Gi5kRjXKWYqU1mdQh8ShY89llWS/4ephJe59qNnNYGQ+BwQZDCjae9QmH4gegEeDLn16UKTzLRlKexlyRYksOG4ETY8RIDgXGCwenMAH03WGUGGiMSkKzM8ajfEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB7303.namprd11.prod.outlook.com (2603:10b6:8:108::21) by MW3PR11MB4537.namprd11.prod.outlook.com (2603:10b6:303:5d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Fri, 20 Jan 2023 09:26:21 +0000 Received: from DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::dec6:d57d:f767:c5f2]) by DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::dec6:d57d:f767:c5f2%4]) with mapi id 15.20.6002.026; Fri, 20 Jan 2023 09:26:20 +0000 From: "Aktemur, Tankut Baris" To: Andrew Burgess , "gdb-patches@sourceware.org" Subject: RE: [PATCHv2 12/13] gdb: introduce unwind-on-timeout setting Thread-Topic: [PATCHv2 12/13] gdb: introduce unwind-on-timeout setting Thread-Index: AQHZK1i4owwPk5GqJUCH+6jyiw99DK6nCIMQ Date: Fri, 20 Jan 2023 09:26:20 +0000 Message-ID: References: <0a8172f909c477fc7bab48c99df5860c887b8024.1674058360.git.aburgess@redhat.com> In-Reply-To: <0a8172f909c477fc7bab48c99df5860c887b8024.1674058360.git.aburgess@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB7303:EE_|MW3PR11MB4537:EE_ x-ms-office365-filtering-correlation-id: 72c7ce07-426b-4c72-9420-08dafac8641a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1U6iSk6dvK8vg4181D+gucPJF53YXXTvO1I0PpTgzJ3NxYm1fKiy9mbGV9XW5J5WcehFAnhLynCxTeNEseJSW2+qdcLrhPwU6Oqvk3O1vNtXNYrz2D2u4/7X/+MBBCrtw69CqQHo6yh1AuzzAC7lky0uq0x4EK5WmUvaaDPMa5/3HSaNBwYqvjzDv5IVPEilqLXvC14ysAQ3HwausNDM0P6qdYpHT1JMeSzhBDvHYQxdDVA13y0rBrCWsXN38pNHbcCwq/DlyHiiDwIFxGq+MH7u6RWgKOVGOVXsCVZBd0bEW7xNec/1j591FyLmp5UTFWUb5AS/pjItixLVzG1bpAj+m4zoN5HacctKVZfokxjSGBfGuPH0UAhtuj3SGR69sOjq9NqGtBw+EaX9JhwbvCYbca36+EpX/NBQxAdUiXq7sF8+InyBsxP/3l3HKO/yA/KaSuy+ETog9MilB7aLC26X1REtffLwZandYEHZ2dp0wTbD9Og8SRGFlh+haTqgr6Vmsd56GdbClrnEz4PH9+EvAi9SikDKcajIav59FIrUD7M83+awyBE3V+yX5bewsEiPOpjsZXAif5ucTfs/CgvUPHh08xzCqaqX496e7Gch3fndhxItH6BrGKmP41V2RHXE+RdZYRWqG3yB96dMGTB0NomIg4DzZM+ehCpTIvUuS3b9832+mFGocK1dnXmHyrv76ropOpfJmEu99Ysmhw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB7303.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(346002)(396003)(376002)(39860400002)(136003)(451199015)(82960400001)(66476007)(52536014)(76116006)(38100700002)(122000001)(66556008)(478600001)(86362001)(8936002)(5660300002)(33656002)(55016003)(30864003)(2906002)(66946007)(64756008)(66446008)(41300700001)(26005)(8676002)(83380400001)(9686003)(186003)(71200400001)(316002)(53546011)(7696005)(38070700005)(110136005)(6506007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?H1U4O6JABfSiLSUK7r9BaGcv7bLEdKH6mjrkR5nqYc6gPr1PaS48Cf9XuHmB?= =?us-ascii?Q?cWVqLuVp4Hme1nPvbcOaCzGjRTsgGO1x1PE0sFwm3MSQmOLlByIBWfq36Fen?= =?us-ascii?Q?u3mSvxIMxCCQPyDAYXtfb8MkO+/5Ph0C8iUMeLKRNJTx5+YvaqvkZh4tYO3F?= =?us-ascii?Q?Wtcud0hrzdtNQuFURUed+Zc1WK+VvIH5ml0UNGGQk8Nr7tCQjlvUAmHMLRS+?= =?us-ascii?Q?sjI6fREeYmkSZHetS9SEnBpWnKe15W5XOfkU6saZ8J1AYuTKRUwzJ0YVgGYZ?= =?us-ascii?Q?c6AuXvdInmo6yjB9YR8K9s/1WMZIxoMlz383g8Xwakt8kTQ0ziF9GH5LLYVq?= =?us-ascii?Q?1TSi98behhYE+ZNF6XmHweG9bTPiUbtD6/jWrtRSiV9MYxU/fJ8QX/boOog4?= =?us-ascii?Q?MTrz1jQL+RtCEBmivNmAL+T+dP7LAZbOKE+ONj0SxmlohME0esYK2KQVKyXb?= =?us-ascii?Q?QkgVmpOK5FGaQlmtrjVugL3WfaUE/vJvATzJCpvNh+Nn5KVEPouSdwSOuNFe?= =?us-ascii?Q?UugYcHZI4HjPU4YoAzuRqg/DnIKGUy1Js0wj1Jiug/YSI3YFzKLZxuYOsv4W?= =?us-ascii?Q?jOYeE+w6CEDHwG0WqCJpEWs65RthQZRYKDdLNOd5YzfAblMYF7Vzee9giS6j?= =?us-ascii?Q?PjQ0uHsddk8BnjRyPU0Pm2UPUkn0rBoIwUBVMGzp4l9asuQeHmy8jHx4mck6?= =?us-ascii?Q?HhKWqbXsGWYwwgCaDDassuw/HBUJKtJ4Y2Z4/wXXX2sE3V2eaXGSl9DxZ4nk?= =?us-ascii?Q?LQNy2r+bRvBfi30w1GOPRdAURRCIm/g/J9xzbKWcHioBsR1MLd7Khbz4gCv1?= =?us-ascii?Q?C6RaVT43yPzmNA3ka5RwCKPgNXnsqrOFZ08jBQ0m5Gg8l/dK7ztLO2GBfVo5?= =?us-ascii?Q?lYHSAYNaNLFfVaJKiy2gSENnd+PgnaZ/BN39iisIOs3voGAVztcp7X1g6Tjr?= =?us-ascii?Q?P84mnOxn153eFJAeUp9pXbBfpq63hr0vGvlRf8tpxMpcaGOladRMDSXCUKft?= =?us-ascii?Q?6GwQ0rpOg6RY3rTyMu47bJn5dN8GMr8gvG4pR+x32Gns33unbIvluVdVr8ht?= =?us-ascii?Q?e3Liwgp7yr1uZbl+V/uWz+nz9eck9gwu8urZiPfOkbRBNq/7gLQOzPMz+cXt?= =?us-ascii?Q?AJXnthKi0CxT2I54SIrPdZsI2FEgQJ/8Y/T4SGkszGPmxklTY5c0DwMFFPtF?= =?us-ascii?Q?vKHuZs+/2dAJ3wikwHyaNy51/FyGXkqe3MR8Az0t8yid/xuHXSyIF1ENEssu?= =?us-ascii?Q?H7eRFUP4h/Y2hGOrId+4iYrHviR1FQhQHbLf9hKl60gTiF7e834BDHoOtGX6?= =?us-ascii?Q?10cPkCwqfno38w5ocTxa5Hn5rjE/WDqFXlN9lSXBKSClvt5qjC25b54i2NAi?= =?us-ascii?Q?OmjGE4hVhO1y6A9sUBAda1nbAA03Hg3OP5abeaYfzebDpMtW0dkA5t3ZWfbk?= =?us-ascii?Q?ACGeG5aS+IkRD/VwC8vER8CnZ+GIHu7NfgSUCUczHGp/Wx5565N/+MZhHME0?= =?us-ascii?Q?NK0ZQltYklcgsQO222YUvrY97+m2plRqO42wk0P0cE1Lobjrzw4ULRQg52F/?= =?us-ascii?Q?PaKO48yJGe8hJJBBB2pgfu3lS4I5CdpoGIRaZ/E2DR4B1fgz3ZJ6cCTD5H5c?= =?us-ascii?Q?Sw=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB7303.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72c7ce07-426b-4c72-9420-08dafac8641a X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2023 09:26:20.5588 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2gIZKMo1LcuxMiYxOsZUr5DM5S85B+sW/vq3Ku1DEk1wF55V4qfzo1MArhYePaqa6OzgH6rltWB0A6qe9WZM1SEQk8azc7NTQXbQGyB6p7I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4537 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wednesday, January 18, 2023 5:18 PM, Andrew Burgess wrote: > Now that inferior function calls can timeout (see the recent > introduction of direct-call-timeout and indirect-call-timeout), this > commit adds a new setting unwind-on-timeout. > = > This new setting is just like the existing unwindonsignal and > unwind-on-terminating-exception, but the new setting will cause GDB to > unwind the stack if an inferior function call times out. > = > The existing inferior function call timeout tests have been updated to > cover the new setting. > --- > gdb/NEWS | 9 +++ > gdb/doc/gdb.texinfo | 33 +++++++--- > gdb/infcall.c | 62 ++++++++++++++++--- > gdb/testsuite/gdb.base/infcall-timeout.exp | 49 +++++++++++---- > .../infcall-from-bp-cond-timeout.exp | 55 +++++++++++----- > 5 files changed, 164 insertions(+), 44 deletions(-) > = > diff --git a/gdb/NEWS b/gdb/NEWS > index 2689569a8f3..511a750407a 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -35,6 +35,15 @@ show indirect-call-timeout > ignored, GDB will wait indefinitely for an inferior function to > complete, unless interrupted by the user using Ctrl-C. > = > +set unwind-on-timeout on|off > +show unwind-on-timeout > + These commands control whether GDB should unwind the stack when a > + timeout occurs during an inferior function call. The default is > + off, in which case the inferior will remain in the frame where the > + timeout occurred. When on GDB will unwind the stack remocing the > + dummy frame that was added for the inferior call, and restoring the > + inferior state to how it was before the inferior call started. > + > * MI changes > = > ** mi now reports 'no-history' as a stop reason when hitting the end of = the > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 9eb8b1db00e..aa88221677e 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -5719,10 +5719,10 @@ > the called function, or the called function may receive a signal > (e.g.@ a @code{SIGSEGV}) as a result of some undefined behaviour, if > this happens then @value{GDBN} will stop. Depending on the settings > -@code{unwindonsignal} and @code{unwind-on-terminating-exception} > -(@pxref{Calling,,Calling Program Functions}) @value{GDBN} may unwind > -the stack back to the breakpoint location, or may leave the program at > -the frame where the stop occurred. > +@code{unwindonsignal}, @code{unwind-on-terminating-exception}, and > +@code{unwind-on-timeout} (@pxref{Calling,,Calling Program Functions}) > +@value{GDBN} may unwind the stack back to the breakpoint location, or > +may leave the program at the frame where the stop occurred. > = > Breakpoint conditions can also be evaluated on the target's side if > the target supports it. Instead of evaluating the conditions locally, > @@ -20718,6 +20718,21 @@ > Show the current setting of stack unwinding in the functions called by > @value{GDBN}. > = > +@item set unwind-on-timeout > +@kindex set unwind-on-timeout > +@cindex unwind stack in called functions when timing out > +@cindex call dummy stack unwinding on timeout. > +Set unwinding of the stack if a function called from @value{GDBN} > +times out. If set to @code{off} (the default), @value{GDBN} stops in > +the frame where the timeout occurred. If set to @code{on}, > +@value{GDBN} unwinds the stack it created for the call and restores > +the context to what it was before the call. > + > +@item show unwind-on-timeout > +@kindex show unwind-on-timeout > +Show whether @value{GDBN} will unwind the stack if a function called > +from @value{GDBN} times out. > + > @item set may-call-functions > @kindex set may-call-functions > @cindex disabling calling functions in the program > @@ -20748,11 +20763,11 @@ > call by typing the interrupt character (often @kbd{Ctrl-c}). > = > If a called function is interrupted for any reason, and the stack is > -not unwound (due to @code{set unwind-on-terminating-exception on} or > -@code{set unwindonsignal on}), then the dummy-frame, created by > -@value{GDBN} to facilitate the call to the program function, will be > -visible in the backtrace, for example frame @code{#3} in the following > -backtrace: > +not unwound (due to @code{set unwind-on-terminating-exception on}, > +@code{set unwind-on-timeout}, or @code{set unwindonsignal on}), then > +the dummy-frame, created by @value{GDBN} to facilitate the call to the > +program function, will be visible in the backtrace, for example frame > +@code{#3} in the following backtrace: > = > @smallexample > (@value{GDBP}) backtrace > diff --git a/gdb/infcall.c b/gdb/infcall.c > index 9afca4f5bc6..272e3cccf87 100644 > --- a/gdb/infcall.c > +++ b/gdb/infcall.c > @@ -217,6 +217,27 @@ show_unwind_on_terminating_exception_p (struct ui_fi= le *file, int > from_tty, > value); > } > = > +/* This boolean tells what gdb should do if a signal is received while > + in a function called from gdb (call dummy). If set, gdb unwinds In a former review comment, I was asked to use "GDB" (all uppercase) as the spelling. > + the stack and restore the context to what as it was before the restore -> restores And "as" should be removed. > + call. > + > + The default is to stop in the frame where the signal was received. */ > + > +static bool unwind_on_timeout_p =3D false; > + > +/* Implement 'show unwind-on-timeout'. */ > + > +static void > +show_unwind_on_timeout_p (struct ui_file *file, int from_tty, > + struct cmd_list_element *c, const char *value) > +{ > + gdb_printf (file, > + _("Unwinding of stack if a timeout occurs " > + "while in a call dummy is %s.\n"), > + value); > +} > + > /* Perform the standard coercions that are specified > for arguments to be passed to C, Ada or Fortran functions. > = > @@ -1691,14 +1712,27 @@ When the function is done executing, GDB will sil= ently stop."), > /* A timeout results in a signal being sent to the inferior. */ > gdb_assert (stopped_by_random_signal); > = > - /* Indentation is weird here. A later patch is going to move the > - following block into an if/else, so I'm leaving the indentation > - here to minimise the later patch. > + if (unwind_on_timeout_p) > + { > + /* The user wants the context restored. */ > + > + /* We must get back to the frame we were before the > + dummy call. */ > + dummy_frame_pop (dummy_id, call_thread.get ()); > + > + /* We also need to restore inferior status to that before the > + dummy call. */ > + restore_infcall_control_state (inf_status.release ()); > = > - Also, the error message used below refers to 'set > - unwind-on-timeout' which doesn't exist yet. This will be added > - in a later commit, I'm leaving this in for now to minimise the > - churn caused by the commit that adds unwind-on-timeout. */ > + error (_("\ > +The program being debugged timed out while in a function called from GDB= .\n\ > +GDB has restored the context to what it was before the call.\n\ > +To change this behavior use \"set unwind-on-timeout off\".\n\ > +Evaluation of the expression containing the function\n\ > +(%s) will be abandoned."), > + name.c_str ()); > + } > + else > { > /* The user wants to stay in the frame where we stopped > (default). Discard inferior status, we're not at the same > @@ -1824,6 +1858,20 @@ The default is to unwind the frame."), > show_unwind_on_terminating_exception_p, > &setlist, &showlist); > = > + add_setshow_boolean_cmd ("unwind-on-timeout", no_class, > + &unwind_on_timeout_p, _("\ > +Set unwinding of stack if a timeout occurs while in a call dummy."), _("\ > +Show unwinding of stack if a timeout occurs while in a call dummy."), > + _("\ > +The unwind on timeout flag lets the user determine what gdb should do if= \n\ > +gdb times out while in a function called from gdb. If set, gdb unwinds\= n\ > +the stack and restores the context to what it was before the call. If\n\ > +unset, gdb leaves the inferior in the frame where the timeout occurred.\= n\ > +The default is to stop in the frame where the timeout occurred."), > + NULL, > + show_unwind_on_timeout_p, > + &setlist, &showlist); > + > add_setshow_uinteger_cmd ("direct-call-timeout", no_class, > &direct_call_timeout, _("\ > Set the timeout, for direct calls to inferior function calls."), _("\ > diff --git a/gdb/testsuite/gdb.base/infcall-timeout.exp b/gdb/testsuite/g= db.base/infcall- > timeout.exp > index bd6b2bfac3e..a4d9fd6ee61 100644 > --- a/gdb/testsuite/gdb.base/infcall-timeout.exp > +++ b/gdb/testsuite/gdb.base/infcall-timeout.exp > @@ -28,7 +28,11 @@ if { [build_executable "failed to prepare" ${binfile} = "${srcfile}" \ > # the direct-call-timeout, and make an inferior function call that > # will never return. GDB should eventually timeout and stop the > # inferior. > -proc_with_prefix run_test { target_async target_non_stop } { > +# > +# When UNWIND is "off" the inferior wil be left in the frame where the > +# timeout occurs, otherwise, when UNWIND is "on", GDB should unwind > +# back to the frame where the inferior call was made. > +proc_with_prefix run_test { target_async target_non_stop unwind } { > save_vars { ::GDBFLAGS } { > append ::GDBFLAGS \ > " -ex \"maint set target-non-stop $target_non_stop\"" > @@ -44,19 +48,36 @@ proc_with_prefix run_test { target_async target_non_s= top } { > } > = > gdb_test_no_output "set direct-call-timeout 5" > + gdb_test_no_output "set unwind-on-timeout $unwind" > + > + if { $unwind } { > + gdb_test "print function_that_never_returns ()" \ > + [multi_line \ > + "Program stopped\\." \ > + ".*" \ > + "The program being debugged timed out while in a function called from= GDB\\." > \ > + "GDB has restored the context to what it was before the call\\." \ > + "To change this behavior use \"set unwind-on-timeout off\"\\." \ > + "Evaluation of the expression containing the function" \ > + "\\(function_that_never_returns\\) will be abandoned\\."] > = > - gdb_test "print function_that_never_returns ()" \ > - [multi_line \ > - "Program stopped\\." \ > - ".*" \ > - "The program being debugged timed out while in a function called f= rom GDB\\." \ > - "GDB remains in the frame where the timeout occurred\\." \ > - "To change this behavior use \"set unwind-on-timeout on\"\\." \ > - "Evaluation of the expression containing the function" \ > - "\\(function_that_never_returns\\) will be abandoned\\." \ > - "When the function is done executing, GDB will silently stop\\."] > + gdb_test "bt" \ > + "#0\\s+main \\(\\).*" > + } else { > + gdb_test "print function_that_never_returns ()" \ > + [multi_line \ > + "Program stopped\\." \ > + ".*" \ > + "The program being debugged timed out while in a function called from= GDB\\." > \ > + "GDB remains in the frame where the timeout occurred\\." \ > + "To change this behavior use \"set unwind-on-timeout on\"\\." \ > + "Evaluation of the expression containing the function" \ > + "\\(function_that_never_returns\\) will be abandoned\\." \ > + "When the function is done executing, GDB will silently stop\\."] > = > - gdb_test "bt" ".* function_that_never_returns .*.*" > + gdb_test "bt" \ > + ".* function_that_never_returns .*.*" > + } > } > = > foreach_with_prefix target_async { "on" "off" } { > @@ -70,6 +91,8 @@ foreach_with_prefix target_async { "on" "off" } { > } > = > foreach_with_prefix target_non_stop { "on" "off" } { > - run_test $target_async $target_non_stop > + foreach_with_prefix unwind { "on" "off" } { > + run_test $target_async $target_non_stop $unwind > + } > } > } > diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp > b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp > index 9ba38e6896a..847a850673d 100644 > --- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp > +++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp > @@ -41,7 +41,12 @@ set segfault_line [gdb_get_line_number "Segfault here"] > # thread, on which the inferior call relies, either hits a breakpoint > # (when OTHER_THREAD_BP is true), or crashes (when OTHER_THREAD_BP is > # false). > -proc run_test { target_async target_non_stop other_thread_bp } { > +# > +# When UNWIND is "on" GDB will unwind the thread which performed the > +# inferior function call back to the state where the inferior call was > +# made (when the inferior call times out). Otherwise, when UNWIND is > +# "off", the inferior is left in the frame where the timeout occurred. > +proc run_test { target_async target_non_stop other_thread_bp unwind } { > save_vars { ::GDBFLAGS } { > append ::GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\"" > append ::GDBFLAGS " -ex \"maintenance set target-async ${target_async}\= "" > @@ -72,6 +77,7 @@ proc run_test { target_async target_non_stop other_thre= ad_bp } { > # for this timeout. For now though, we just hope 5 seconds is > # enough. > gdb_test_no_output "set indirect-call-timeout 5" > + gdb_test_no_output "set unwind-on-timeout $unwind" > = > gdb_breakpoint \ > "${::srcfile}:${::cond_bp_line} if (condition_func ())" > @@ -92,18 +98,35 @@ proc run_test { target_async target_non_stop other_th= read_bp } { > "get number for segfault breakpoint"] > } > = > - gdb_test "continue" \ > - [multi_line \ > - "Thread ${::decimal} \"\[^\r\n\"\]+\" stopped\\." \ > - ".*" \ > - "Error in testing condition for breakpoint ${bp_num}:" \ > - "The program being debugged timed out while in a function called f= rom GDB\\." \ > - "GDB remains in the frame where the timeout occurred\\." \ > - "To change this behavior use \"set unwind-on-timeout on\"\\." \ > - "Evaluation of the expression containing the function" \ > - "\\(condition_func\\) will be abandoned\\." \ > - "When the function is done executing, GDB will silently stop\\."] \ > - "expected timeout waiting for inferior call to complete" > + if { $unwind } { > + gdb_test "continue" \ > + [multi_line \ > + "Thread ${::decimal} \"\[^\r\n\"\]+\" stopped\\." \ > + ".*" \ > + "Error in testing condition for breakpoint ${bp_num}:" \ > + "The program being debugged timed out while in a function called from= GDB\\." > \ > + "GDB has restored the context to what it was before the call\\." \ > + "To change this behavior use \"set unwind-on-timeout off\"\\." \ > + "Evaluation of the expression containing the function" \ > + "\\(condition_func\\) will be abandoned\\." \ > + "" \ > + "Thread ${::decimal}\[^\r\n\]*hit Breakpoint ${bp_num}, \[^\r\n\]+" \ > + "\[^\r\n\]+ Conditional breakpoint here\\. \[^\r\n\]+"] \ > + "expected timeout waiting for inferior call to complete" > + } else { > + gdb_test "continue" \ > + [multi_line \ > + "Thread ${::decimal} \"\[^\r\n\"\]+\" stopped\\." \ > + ".*" \ > + "Error in testing condition for breakpoint ${bp_num}:" \ > + "The program being debugged timed out while in a function called from= GDB\\." > \ > + "GDB remains in the frame where the timeout occurred\\." \ > + "To change this behavior use \"set unwind-on-timeout on\"\\." \ > + "Evaluation of the expression containing the function" \ > + "\\(condition_func\\) will be abandoned\\." \ > + "When the function is done executing, GDB will silently stop\\."] \ > + "expected timeout waiting for inferior call to complete" > + } > = > # Remember that other thread that either crashed (with a segfault) > # or hit a breakpoint? Now that the inferior call has timed out, > @@ -142,8 +165,10 @@ foreach_with_prefix target_async {"on" "off" } { > } > = > foreach_with_prefix target_non_stop {"off" "on"} { > - foreach_with_prefix other_thread_bp { true false } { > - run_test $target_async $target_non_stop $other_thread_bp > + foreach_with_prefix unwind {"off" "on"} { > + foreach_with_prefix other_thread_bp { true false } { > + run_test $target_async $target_non_stop $other_thread_bp $unwind > + } > } > } > } > -- > 2.25.4 Regards -Baris Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928