From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123912 invoked by alias); 16 Oct 2017 17:07:25 -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 123901 invoked by uid 89); 16 Oct 2017 17:07:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Mon, 16 Oct 2017 17:07:22 +0000 Received: from ESESSHC014.ericsson.se (Unknown_Domain [153.88.183.60]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 74.27.26775.747E4E95; Mon, 16 Oct 2017 19:07:19 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.60) with Microsoft SMTP Server (TLS) id 14.3.352.0; Mon, 16 Oct 2017 19:06:28 +0200 Received: from [142.133.49.59] (192.75.88.130) by AMSPR07MB310.eurprd07.prod.outlook.com (2a01:111:e400:802f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.5; Mon, 16 Oct 2017 17:06:26 +0000 Subject: Re: [PATCH v2] symlookup: improves symbol lookup when a file is specified. To: Walfred Tedeschi , , CC: References: <1507727728-30540-1-git-send-email-walfred.tedeschi@intel.com> From: Simon Marchi Message-ID: <88efd84d-5449-f2d3-3757-c16c6f201506@ericsson.com> Date: Mon, 16 Oct 2017 17:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1507727728-30540-1-git-send-email-walfred.tedeschi@intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DM5PR19CA0004.namprd19.prod.outlook.com (2603:10b6:3:151::14) To AMSPR07MB310.eurprd07.prod.outlook.com (2a01:111:e400:802f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dccdbe30-ea6b-4cf1-12ec-08d514b83cdc X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603219)(201703131423075)(201703031133081)(201702281549075);SRVR:AMSPR07MB310; X-Microsoft-Exchange-Diagnostics: 1;AMSPR07MB310;3:MWkGHY1NXNF/uhYZwQNh1OJCKEYIl1QiG/z0EcZTUAYRCWf70+u7NvwpOW9x3a/Bgo+QFFhe8bvrC5HIRXdz27bqdj6ZqwqNj2L3Q4NataDa+FD3vKSMflURCylrsKW1rx7gtHDBIu6Ux9dIOu+u1tqK2Fow1zK4DId7XVVtxDTwm/TlwmUKdAWj+zzoyI/V5JNSV8DsaONnqbi311GbJNSXr4myW9ouiiLLr8jFOfET5DtNYSqM7fjnS0kcdQoy;25:rZTVltAQIsZMPb/sKkbXHcG7yY8qJAaxqjqM4robDNBOhiEsldixplMkv6UiOWKpBhbc2lrzEA1wpX1sELigMmsvjLrUkWWxJSa9vmlBifRgkBCbX4W/4qTtNMANVfaONNwA14BxxA+wkkNBgdRYkpj8LksWZ/5Js0UrBNAqeU3oAa7UYIemtwNhGEmAFJhiVyWVfhIkeROite2tY9F7LXqt64Fnd+q8w7TAeRs0Kv96AGK6hXzHAa46woYCbSDpYtrnNr+wYWs3Gy/MxQC7ApAaoDPvBT2xckKcCF8VN3TqaY0kfyQAUBa45nzuP0iVX5lDAPZAeQtEHJTzWSJO/n6vVgjPLmIcRPBLwhkMAAU=;31:lF4ThsZJCy1JbVlJC3QkIIglcQhwPYt0QZNHUOwMxkqzk8qsL6MqGadiCKUw9HXRbCfhXcYo/jpl4qVU6jNT97dWwAMnGXY4TYFfAR4BkUfqW0YWX/FCnP+guTEuxNmry/deS6/EnO2XD73y6F/8jvthY8kzzsyEcvGwBDY2shRTFDOLFiAokIC6EUK5QQ3auOa4IjsDexSwgluhF+H9GPU0Q/fKP5dQbQocz+OyhhM= X-MS-TrafficTypeDiagnostic: AMSPR07MB310: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1;AMSPR07MB310;20:LvWf6TbB6KrObLld8EJ64ofkvSPGW/ToMoS7VkO+Mth0q7iUBpEGLeBi2XOM8sCH66emXzKjuglulb31hTmOoGxbHH/hyUEpokZ6F2eISRtF+XDeI2YgPsRvkFroSSSAph9QG9/hztzLzrOyMBjoAjz8/57up8zaMBiBhnVJFpNor5JWYVInauquKMe5LOzk9pAcKlLT8k969uGzJSy//tXrdBYemrlMDQ897jrQjfOfTtaM2R+/f659/jftB5N3Y+dm8FNhLEHT1aOIYhdr0Q6GLFuErSgYeoz6l3iFgL/NeZ8zzsbTXV8SWbhA86yqOo6zIEZReR+F5Dk+A26K5/FqjjoBnwSicqoevphNeNBw3mPAzMwoAisx5C0+FT5HCyub4vSR6hm4U6XHom4jIeVM2YQAMyGfD86PjB/yI2PCnsG7MXEOzv1YOL4K9sRSsDbrJ4rJTibGzE4CYRpY/VdsDmoSXwft4k5AFzHujvmYVaR1sHrYE249tAyF49MV;4:ze1Gg8XIdFYS1zNIWpFn/jt3WVv1aR5CjkpxNkSFOnkh+aOsR8+k+fkzIhA2wveMYLcv2SziRcz4dQWEHgBGxhsdyRNf4J9Yedqgg5DGVt5T+v5YcdhMHd3evfsnSV/Jx/QY5uF5SMxFfOXkZY4qVLjrj+auRuPuG2yto9L76EusandCNHUKUKn/muIlTgZrTr2GEycypmpNwrFIA3HXetqlOqYg22g0eXdypVjXIsAhBfKWkTcW8s9ELXGB3n4HvUnVGDKp9GBRW8o3pB8GGeM3KXIkoZyQSXxtxcsWZLKdtAlIO5oxDwEFgBS4uCN9dV6FrjH8iCwA/hdsauJU7/VGIh9Ji1qqKM3q6B6u4K2TLBsKzHaDxQLRWft4XOue X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(100000703101)(100105400095)(3002001)(93006095)(93001095)(6041248)(20161123564025)(20161123558100)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AMSPR07MB310;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AMSPR07MB310; X-Forefront-PRVS: 0462918D61 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6049001)(346002)(376002)(39860400002)(199003)(377454003)(377424004)(54534003)(24454002)(189002)(76176999)(16526018)(23676002)(2950100002)(54356999)(97736004)(50986999)(83506001)(6116002)(3846002)(6666003)(8936002)(230700001)(4001150100001)(6306002)(36756003)(16576012)(316002)(53936002)(6246003)(229853002)(4326008)(6486002)(58126008)(101416001)(65956001)(86362001)(66066001)(65806001)(31696002)(50466002)(31686004)(33646002)(65826007)(47776003)(305945005)(5660300001)(68736007)(189998001)(25786009)(81156014)(7736002)(8676002)(81166006)(64126003)(53546010)(106356001)(49976008)(478600001)(2906002)(105586002)(78286006)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:AMSPR07MB310;H:[142.133.49.59];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTVNQUjA3TUIzMTA7MjM6N1lGaTB6ajBuNXZlRjRpVVZGc2I2dG5nMng1?= =?utf-8?B?RWZWYURYRm9uRmtSY3ZJbXkvZHdOQUtNdGQva1dCcDV6SVpNZkVLY2JIUWl6?= =?utf-8?B?VGpVYURBR2lKNUhObnhyOVM2alZsN3IxM0JpVlBFUmtmM3k4TVlaUGg0VG41?= =?utf-8?B?bXp3Q3dYNkN4ZUU3Qi9OdHR2NFczc0djZERTc0tybG03UWxSWUVDSHlIVzFS?= =?utf-8?B?ZDlPWTArZ1RPb3dxNHQwSm1DWTJ4QTZIOHYvZXpsajg0ME0zd2lBVjlXS2Z4?= =?utf-8?B?NHdyWFFGY01wLzRMMUIrRXBRbTVzb2pUeFhHUXJldzRNdW5RV1hOclBNRUJE?= =?utf-8?B?V0k1N09lcDZyWDZocHY4VDFYaVlrcmVrREFxcnR4WDlOd3Z3c04xcDY2MjFx?= =?utf-8?B?Tm9tcm01TkhPcjg1U1Jub3Z3bVhXSkhiZk1pYTYxQWZ3eFhaa0I3ZnNmY1pV?= =?utf-8?B?R3BKVkg4bFN3bUZmSFdvekdPTlM0dTlZcEw1RmZEU3FLVmxQYkx1dHRDdGNs?= =?utf-8?B?L1dLN2s1TTltdzkzSEd1MGw0aE8ySlZNVm1veDB0QkJmOEl6Q3ZNQUJlamR0?= =?utf-8?B?eVpEVnE2STVxdnk1MUF3ZXVtWkE5UXA1bVd1eURwdll6amlGeFhvZnA1cVA0?= =?utf-8?B?TjhyejNmTjZ6cjdkbmJPZng5Y3pPK3hJNFhHNDhrRndVSW1EM243M2x0NFd3?= =?utf-8?B?dzdhQkJ0ejh6UTM5OUZQM2ljZUk0Ym5CUDNCR3VkR3owcmR1bXc4YmpqNjhy?= =?utf-8?B?elhjaHJTV25Sd2J1a1dMZXlkN0Vid1RTTlN5NUttNTNqOXpIUjV1RzVjando?= =?utf-8?B?a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z00XCbOyH5POodUz4+esn+AlojQfO0NZ+lNuZ9mTb8DD4q8odtDhpw6OoXpAh+tlJeomE8THvCjv+flWi5K8r7D+lXCgIwx8NpnbhlpxGFEq1WMiweavMyDLN2e8f/hPUcpu5OFY2piFcOhkdamQMP+BmxLU0AJO84izGXEw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2017 17:06:26.0855 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR07MB310 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00451.txt.bz2 On 2017-10-11 09:15 AM, Walfred Tedeschi wrote: > The provided patch adds a scope lookup with higher priority in the case a > a file is provided for the evaluation. > > Usual symbol lookup from GDB follows linker logic. This is what is > desired most of the time. In the usage case presented a full qualified scope > is provided provided, so the lookup has to follow this priority. Failing in "provided provided" > finding the symbol at this scope usual path is followed. > > As use and test case it is presented two shared objects having a global > variable with the same name but comming from different source files. > Without the patch evaluating those variables providing the file scope > returns the wrong value; It returns the value seen in the first loaded > shared object. Using the patch the value defined in the file scope is > the one returned. > > One of the already existing test cases in print-file-var.exp starts to > fail after aplying this patch. In fact the value that the linker > sees is different then the one debugger can read from the shared object. > In this sense it looks like to me that the test has to be changed. > The fail is in the call: > print 'print-file-var-lib2.c'::this_version_id == v2 > > During load of the libraries linker resolves the symbol as the first one > loaded and independent of the scope the symbol will have the same value, > as defined in the first library loaded. > However, when defining the scope the value should represent the value > in that context. Diferent evaluations of the same symbols might also better > spot the issue in users code. > > - I haven't changed the test because I wanted to hear the community > thought on the subject. I can't really comment on how right the fix is, but I can see that the current behavior is clearly wrong: (gdb) p 'print-file-var-dlopen-lib1.c'::this_version_id $1 = 104 (gdb) p 'print-file-var-dlopen-lib2.c'::this_version_id $2 = 104 And that your patch fixes it: (gdb) p 'print-file-var-dlopen-lib1.c'::this_version_id $1 = 104 (gdb) p 'print-file-var-dlopen-lib2.c'::this_version_id $2 = 203 > 2017-07-13 Walfred Tedeschi > > gdb/ChangeLog: > > * symtab.c (lookup_global_symbol): Add new lookup to ensure > priority on given block. > > gdb/testsuite/ChangeLog: > > * gdb.base/print-file-var-dlopen-main.c: New file. > * gdb.base/print-file-var-dlopen.exp: New test based on > print-file-var.exp. > * gdb.base/print-file-var-dlopen-lib1.c: New file. > * gdb.base/print-file-var-dlopen-lib2.c: New file. > > > --- > gdb/symtab.c | 4 + > .../gdb.base/print-file-var-dlopen-lib1.c | 25 +++++ > .../gdb.base/print-file-var-dlopen-lib2.c | 25 +++++ > .../gdb.base/print-file-var-dlopen-main.c | 61 +++++++++++ > gdb/testsuite/gdb.base/print-file-var-dlopen.exp | 113 +++++++++++++++++++++ > 5 files changed, 228 insertions(+) > create mode 100644 gdb/testsuite/gdb.base/print-file-var-dlopen-lib1.c > create mode 100644 gdb/testsuite/gdb.base/print-file-var-dlopen-lib2.c > create mode 100644 gdb/testsuite/gdb.base/print-file-var-dlopen-main.c > create mode 100644 gdb/testsuite/gdb.base/print-file-var-dlopen.exp > > diff --git a/gdb/symtab.c b/gdb/symtab.c > index 16a6b2e..a2c307f 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -2589,6 +2589,10 @@ lookup_global_symbol (const char *name, > if (objfile != NULL) > result = solib_global_lookup (objfile, name, domain); > > + /* We still need to look on the global scope of current object file. */ > + if (result.symbol == NULL && objfile != NULL) > + result = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain); > + > /* If that didn't work go a global search (of global blocks, heh). */ > if (result.symbol == NULL) > { > diff --git a/gdb/testsuite/gdb.base/print-file-var-dlopen-lib1.c b/gdb/testsuite/gdb.base/print-file-var-dlopen-lib1.c > new file mode 100644 > index 0000000..09ec947 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/print-file-var-dlopen-lib1.c > @@ -0,0 +1,25 @@ > +/* This testcase is part of GDB, the GNU debugger. > + Copyright 2012-2017 Free Software Foundation, Inc. Are the years right here (the 2012)? > + > + 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 . */ > + > +int this_version_id = 104; > + > +int > +get_version (void) > +{ > + static int test; > + test = this_version_id; > + return test; > +} > diff --git a/gdb/testsuite/gdb.base/print-file-var-dlopen-lib2.c b/gdb/testsuite/gdb.base/print-file-var-dlopen-lib2.c > new file mode 100644 > index 0000000..b097cd2 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/print-file-var-dlopen-lib2.c > @@ -0,0 +1,25 @@ > +/* This testcase is part of GDB, the GNU debugger. > + Copyright 2012-2017 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 . */ > + > +int this_version_id = 203; > + > +int > +get_version (void) > +{ > + static int test; > + test = this_version_id; > + return test; > +} > diff --git a/gdb/testsuite/gdb.base/print-file-var-dlopen-main.c b/gdb/testsuite/gdb.base/print-file-var-dlopen-main.c > new file mode 100644 > index 0000000..954a64e > --- /dev/null > +++ b/gdb/testsuite/gdb.base/print-file-var-dlopen-main.c > @@ -0,0 +1,61 @@ > +/* This testcase is part of GDB, the GNU debugger. > + Copyright 2017 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 . */ > + > +#include > +#include > +#include > + > +int > +dummy (void) > +{ > + return 1; > +} > + > +int > +main (void) > +{ > + int (*get_version1) (void); > + int (*get_version2) (void); > + int v1, v2; > + > + void *lib1 = dlopen ("print-file-var-dlopen-lib1.so", RTLD_LAZY); > + void *lib2 = dlopen ("print-file-var-dlopen-lib2.so", RTLD_LAZY); > + > + if (lib1 == NULL || lib2 == NULL) > + return 1; > + > + *(int **) (&get_version1) = dlsym (lib1, "get_version"); > + *(int **) (&get_version2) = dlsym (lib2, "get_version"); > + > + if (get_version1 != NULL > + && get_version2 != NULL) > + { > + v1 = get_version1(); > + v2 = get_version2(); > + } > + > + > + if (v1 != 104 || v2 != 203) > + return 1; > + > + dummy (); /* STOP */ > + > + dlclose (lib1); > + dlclose (lib2); > + > + return 0; > +} > + > diff --git a/gdb/testsuite/gdb.base/print-file-var-dlopen.exp b/gdb/testsuite/gdb.base/print-file-var-dlopen.exp > new file mode 100644 > index 0000000..1c331ba > --- /dev/null > +++ b/gdb/testsuite/gdb.base/print-file-var-dlopen.exp > @@ -0,0 +1,113 @@ > +# Copyright 2017 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 . */ > + > +if {[skip_shlib_tests]} { > + return 0 > +} > + > +set executable print-file-var-dlopen-main > + > +set lib1 "print-file-var-dlopen-lib1" > +set lib2 "print-file-var-dlopen-lib2" > +set libsrc1 $srcdir/$subdir/${lib1}.c > +set libsrc2 $srcdir/$subdir/${lib2}.c > +set libobj1 [standard_output_file ${lib1}.so] > +set libobj2 [standard_output_file ${lib2}.so] > +set lib_dlopen1 [shlib_target_file ${libobj1}] > +set lib_dlopen2 [shlib_target_file ${libobj2}] > + > +set srcfile $srcdir/$subdir/$executable.c > +set binfile [standard_output_file $executable] > +set shlibdir [standard_output_file {}] > + > +set lib_opts debug > +set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen1}\" additional_flags=-DSHLIB_NAME2=\"${lib_dlopen2}\"] > + > +if { [gdb_compile_shlib $libsrc1 $libobj1 $lib_opts] != "" > + || [gdb_compile_shlib $libsrc2 $libobj2 $lib_opts] != "" > + || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { > + untested "failed to compile" > + return -1 > +} > + > +if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1}.c \ > + ${libobj1} \ > + ${lib_opts} ] != "" } { > + return -1 > +} > +if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2}.c \ > + ${libobj2} \ > + ${lib_opts} ] != "" } { > + return -1 > +} > +if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \ > + [standard_output_file ${executable}] \ > + executable \ > + [list debug shlib=-ldl]] > + != ""} { > + return -1 > +} > + > + > +clean_restart $executable > + > +if ![runto_main] { > + untested "could not run to main" > + return -1 > +} > + > +# Try printing "this_version_num" qualified with the name of the file > +# where the variables are defined. There are two global variables > +# with that name, and some systems such as GNU/Linux merge them > +# into one single entity, while some other systems such as Windows > +# keep them separate. I don't really understand what you mean by "GNU/Linux merge them into one single entity". There are still two distinct variables, no? > +gdb_test "continue" \ > + "Breakpoint \[0-9\]+, main \\(\\) at.*" \ > + "continue to STOP marker" You could use gdb_continue_to_breakpoint. Simon