This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [RFC 3/3] Test on solib load and unload


lgtm for the python part. I lack some tcl/dejagnu skills to review the other part.

See comments below.

 -Sanimir

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf
> Of Yao Qi
> Sent: Wednesday, August 28, 2013 06:26 AM
> To: gdb-patches@sourceware.org
> Subject: Re: [RFC 3/3] Test on solib load and unload
> 
> 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 @@
[...]
> +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);
>
Does dlsym has any perf impact on the debugger?

> 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 @@
[...]
> +
> +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 ())"
>
The lines above seem pretty generic and could move into an own proc.

> +
> +gdb_test_no_output "python SolibLoadUnload\($SOLIB_NUMBER\)"
> +
> +# Call the convenience function registered by python script.
> +send_gdb "call \$perftest()\n"
>
Not sure if a convenience function is necessary:
python SolibLoadUnload().execute_test()
could do the job as well.

> 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 <http://www.gnu.org/licenses/>.
> +
> +# 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
>
This may raise a TypeError if num % 2 != 0

> +
> +            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
>
You may consider observing solibs loads/unloads to compute the time
between the events.
Can you re-run the sample with turned off garbage collector? It may
cause some jitter if turned on.

 -Sanimir

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]