From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (vps-42846194.vps.ovh.net [IPv6:2001:41d0:801:2000::2400]) by sourceware.org (Postfix) with ESMTPS id 2A5113857BA9 for ; Mon, 20 Jun 2022 18:36:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A5113857BA9 Received: from ubuntu.lan (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id F24A486CF5; Mon, 20 Jun 2022 18:36:37 +0000 (UTC) Date: Mon, 20 Jun 2022 18:36:32 +0000 From: Lancelot SIX To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Add gdb.free_objfile event registry Message-ID: <20220620183612.px4ct47mq36tyqfo@ubuntu.lan> References: <20220620173622.2711270-1-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220620173622.2711270-1-tromey@adacore.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Mon, 20 Jun 2022 18:36:38 +0000 (UTC) X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_XBL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2022 18:36:41 -0000 Hi, I have minor remarks / questions down below. > diff --git a/gdb/testsuite/gdb.python/py-event-load.c b/gdb/testsuite/gdb.python/py-event-load.c > new file mode 100644 > index 00000000000..515b4b0be08 > --- /dev/null > +++ b/gdb/testsuite/gdb.python/py-event-load.c > @@ -0,0 +1,42 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 2010-2022 Free Software Foundation, Inc. Is the 2010 intentional? It looks that this file is copied from gdb.base/catch-load.c which is marked 2012-2022. > + > + 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 > + > +#ifdef __WIN32__ > +#include > +#define dlopen(name, mode) LoadLibrary (TEXT (name)) > +#define dlclose(handle) FreeLibrary (handle) > +#else > +#include > +#endif > + > +/* This is updated by the .exp file. */ > +char *libname = "catch-load-so.so"; To be "consistent" with other files which uses this pattern, shouldn't the default libname reflect the test name? Something like py-event-load-so.so I guess. Later in the test you use "py-events-shlib.so" as actual libname. > + > +int > +main () > +{ > + void *h; > + > + h = dlopen (libname, RTLD_LAZY); > + > + dlclose (h); > + > + h = NULL; /* final breakpoint here */ > + return 0; > +} > diff --git a/gdb/testsuite/gdb.python/py-event-load.exp b/gdb/testsuite/gdb.python/py-event-load.exp > new file mode 100644 > index 00000000000..f7aeb5f33fb > --- /dev/null > +++ b/gdb/testsuite/gdb.python/py-event-load.exp > @@ -0,0 +1,67 @@ > +# Copyright 2022 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 . > +# > + > +# Test the Python free_objfile event. > + > +load_lib gdb-python.exp > + > +if {[skip_shlib_tests]} { > + untested "skipping shared library tests" > + return -1 > +} > + > +if {[get_compiler_info]} { > + warning "Could not get compiler info" > + untested "no compiler info" > + return -1 > +} > + > +standard_testfile .c > +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ > + executable {debug shlib_load}] != ""} { > + untested "failed to compile" > + return -1 > +} > + > +set testfile2 py-events-shlib > +set srcfile2 ${testfile2}.c > +set binfile2 [standard_output_file ${testfile2}.so] > +set binfile2_dlopen [shlib_target_file ${testfile2}.so] > +if {[gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" \ > + ${binfile2} {debug}] != ""} { > + untested "failed to compile shared library" > + return -1 > +} > + > +clean_restart $testfile > + > +if {![runto_main]} { > + return > +} > + > +if { [skip_python_tests] } { return } I guess that this skip check can be moved above (together with the skip_shlib_tests), so on target which skip python tests we do not bother compiling the test program. WDYT? Best, Lancelot. > + > +gdb_test_no_output "set var libname = \"$binfile2_dlopen\"" > + > +set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-event-load.py] > +gdb_test_no_output "source ${pyfile}" "load python file" > + > +gdb_breakpoint [gdb_get_line_number "final breakpoint here"] > + > +gdb_continue_to_breakpoint "run to final breakpoint" > + > +gdb_test "python print(freed_objfile)" [string_to_regexp $binfile2_dlopen] \ > + "print name of unloaded objfile" > diff --git a/gdb/testsuite/gdb.python/py-event-load.py b/gdb/testsuite/gdb.python/py-event-load.py > new file mode 100644 > index 00000000000..9cf56115205 > --- /dev/null > +++ b/gdb/testsuite/gdb.python/py-event-load.py > @@ -0,0 +1,30 @@ > +# Copyright (C) 2022 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 . > + > +# Test Python free_objfile event. > + > +import gdb > + > + > +freed_objfile = None > + > + > +def free_objfile_handler(event): > + assert isinstance(event, gdb.FreeObjFileEvent) > + global freed_objfile > + freed_objfile = event.objfile.username > + > + > +gdb.events.free_objfile.connect(free_objfile_handler) > -- > 2.34.1 >