From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16036 invoked by alias); 28 Aug 2013 04:27:06 -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 16021 invoked by uid 89); 28 Aug 2013 04:27:03 -0000 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2013 04:27:03 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RDNS_NONE,SPF_HELO_FAIL autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VEXLO-0007Z0-L6 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 27 Aug 2013 21:26:58 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 27 Aug 2013 21:26:58 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Tue, 27 Aug 2013 21:26:57 -0700 Message-ID: <521D7BCA.10806@codesourcery.com> Date: Wed, 28 Aug 2013 04:27:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Subject: Re: [RFC 3/3] Test on solib load and unload References: <520B7F70.6070207@codesourcery.com> <1377663394-4975-1-git-send-email-yao@codesourcery.com> <1377663394-4975-4-git-send-email-yao@codesourcery.com> In-Reply-To: <1377663394-4975-4-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-08/txt/msg00809.txt.bz2 On 08/28/2013 12:16 PM, Yao Qi wrote: > +for {set i 0} {$i < $SOLIB_NUMBER} {incr i} { > + file delete "solib-lib$i" > + file delete "solib-lib$i.c" > +} I should use proc standard_temp_file here. Here is the updated version. -- Yao (齐尧) gdb/testsuite/ * gdb.perf/solib.c: New. * gdb.perf/solib.exp: New. * gdb.perf/solib.py: New. --- gdb/testsuite/gdb.perf/solib.c | 79 ++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.perf/solib.exp | 86 ++++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.perf/solib.py | 48 +++++++++++++++++++++ 3 files changed, 213 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.perf/solib.c create mode 100644 gdb/testsuite/gdb.perf/solib.exp create mode 100644 gdb/testsuite/gdb.perf/solib.py diff --git a/gdb/testsuite/gdb.perf/solib.c b/gdb/testsuite/gdb.perf/solib.c new file mode 100644 index 0000000..948b286 --- /dev/null +++ b/gdb/testsuite/gdb.perf/solib.c @@ -0,0 +1,79 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 2013 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 + +#ifdef __WIN32__ +#include +#define dlopen(name, mode) LoadLibrary (TEXT (name)) +#ifdef _WIN32_WCE +# define dlsym(handle, func) GetProcAddress (handle, TEXT (func)) +#else +# define dlsym(handle, func) GetProcAddress (handle, func) +#endif +#define dlclose(handle) FreeLibrary (handle) +#else +#include +#endif + +void +do_test (int number) +{ + void **handles; + char libname[40]; + int i; + + handles = malloc (sizeof (void *) * number); + + for (i = 0; i < number; i++) + { + sprintf (libname, "solib-lib%d", i); + handles[i] = dlopen (libname, RTLD_LAZY); + if (handles[i] == NULL) + { + printf ("ERROR on dlopen %s\n", libname); + return; + } + } + + for (i = 0; i < number; i++) + { + char funname[20]; + void *p; + + sprintf (funname, "shr%d", i); + p = dlsym (handles[i], funname); + } + + for (i = 0; i < number; i++) + dlclose (handles[i]); + + free (handles); +} + +static void +end (void) +{} + +int +main (void) +{ + end (); + + return 0; +} diff --git a/gdb/testsuite/gdb.perf/solib.exp b/gdb/testsuite/gdb.perf/solib.exp new file mode 100644 index 0000000..8e7eaf8 --- /dev/null +++ b/gdb/testsuite/gdb.perf/solib.exp @@ -0,0 +1,86 @@ +# Copyright (C) 2013 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 . + +# This test case is to test the speed of GDB when it is handling the +# shared libraries of inferior are loaded and unloaded. + +standard_testfile .c +set executable $testfile +set expfile $testfile.exp + +# make check RUNTESTFLAGS='solib.exp SOLIB_NUMBER=1024' +if ![info exists SOLIB_NUMBER] { + set SOLIB_NUMBER 128 +} + +for {set i 0} {$i < $SOLIB_NUMBER} {incr i} { + + # Produce source files. + set libname "solib-lib$i" + set src [standard_temp_file $libname.c] + set exe [standard_temp_file $libname] + + set code "int shr$i (void) {return $i;}" + set f [open $src "w"] + puts $f $code + close $f + + # Compile. + if { [gdb_compile_shlib $src $exe {debug}] != "" } { + untested "Couldn't compile $src." + return -1 + } + + # Delete object files to save some space. + file delete [standard_temp_file "solib-lib$i.c.o"] +} + +if { [prepare_for_testing ${testfile}.exp ${binfile} ${srcfile} {debug shlib_load} ] } { + return -1 +} + +clean_restart $binfile + +if ![runto_main] { + fail "Can't run to main" + return -1 +} + +set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] + +# Set sys.path for module perftest. +gdb_test_no_output "python import os, sys" +gdb_test_no_output "python sys.path.insert\(0, os.path.abspath\(\"${srcdir}/${subdir}/lib\"\)\)" + +gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" + +gdb_test_no_output "python SolibLoadUnload\($SOLIB_NUMBER\)" + +# Call the convenience function registered by python script. +send_gdb "call \$perftest()\n" +gdb_expect 3000 { + -re "\"Done\".*${gdb_prompt} $" { + } + timeout {} +} + +remote_file host delete ${remote_python_file} + +# Remove these libraries and source files. + +for {set i 0} {$i < $SOLIB_NUMBER} {incr i} { + file delete [standard_temp_file "solib-lib$i"] + file delete [standard_temp_file "solib-lib$i.c"] +} diff --git a/gdb/testsuite/gdb.perf/solib.py b/gdb/testsuite/gdb.perf/solib.py new file mode 100644 index 0000000..7cc9c4a --- /dev/null +++ b/gdb/testsuite/gdb.perf/solib.py @@ -0,0 +1,48 @@ +# Copyright (C) 2013 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 . + +# This test case is to test the speed of GDB when it is handling the +# shared libraries of inferior are loaded and unloaded. + +import gdb +import time + +from perftest import perftest + +class SolibLoadUnload(perftest.SingleVariableTestCase): + def __init__(self, solib_number): + super (SolibLoadUnload, self).__init__ ("solib") + self.solib_number = solib_number + + def execute_test(self): + num = self.solib_number + iteration = 5; + + # Warm up. + do_test_command = "call do_test (%d)" % num + gdb.execute (do_test_command) + gdb.execute (do_test_command) + + while num > 0 and iteration > 0: + do_test_command = "call do_test (%d)" % num + + start_time = time.clock() + gdb.execute (do_test_command) + elapsed_time = time.clock() - start_time + + self.result.record (num, elapsed_time) + + num = num / 2 + iteration -= 1 -- 1.7.7.6