Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: Re: [RFC 3/3] Test on solib load and unload
Date: Wed, 28 Aug 2013 04:27:00 -0000	[thread overview]
Message-ID: <521D7BCA.10806@codesourcery.com> (raw)
In-Reply-To: <1377663394-4975-4-git-send-email-yao@codesourcery.com>

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 <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __WIN32__
+#include <windows.h>
+#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 <dlfcn.h>
+#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 <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.
+
+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 <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
+
+            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


  reply	other threads:[~2013-08-28  4:27 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 13:01 [RFC] GDB performance testing infrastructure Yao Qi
2013-08-21 20:39 ` Tom Tromey
2013-08-27  6:21   ` Yao Qi
2013-08-27 13:49 ` Agovic, Sanimir
2013-08-28  3:04   ` Yao Qi
2013-09-19  0:36     ` Doug Evans
2013-08-28  4:17 ` [RFC 0/3] GDB Performance testing Yao Qi
2013-08-28  4:17   ` [RFC 2/3] Perf test framework Yao Qi
2013-08-28  9:57     ` Agovic, Sanimir
2013-09-03  1:45       ` Yao Qi
2013-09-03  6:38         ` Agovic, Sanimir
2013-09-19 19:09     ` Doug Evans
2013-09-20  8:04       ` Yao Qi
2013-09-20 16:51         ` Doug Evans
2013-09-22  2:54           ` Yao Qi
2013-09-22 23:14             ` Doug Evans
2013-09-20 17:12         ` Doug Evans
2013-08-28  4:17   ` [RFC 1/3] New make target 'check-perf' and new dir gdb.perf Yao Qi
2013-08-28  9:40     ` Agovic, Sanimir
2013-09-19 17:47     ` Doug Evans
2013-09-20 19:00       ` Tom Tromey
2013-09-20 18:59     ` Tom Tromey
2013-08-28  4:17   ` [RFC 3/3] Test on solib load and unload Yao Qi
2013-08-28  4:27     ` Yao Qi [this message]
2013-08-28 11:31       ` Agovic, Sanimir
2013-09-03  1:59         ` Yao Qi
2013-09-03  6:33           ` Agovic, Sanimir
2013-09-02 15:24       ` Blanc, Nicolas
2013-09-03  2:04         ` Yao Qi
2013-09-03  7:50           ` Blanc, Nicolas
2013-09-19 22:45       ` Doug Evans
2013-09-20 19:19         ` Tom Tromey
2013-10-05  0:34           ` Doug Evans
2013-10-07 16:31             ` Tom Tromey
2013-09-22  6:25         ` Yao Qi
2013-09-23  0:14           ` Doug Evans
2013-09-24  2:31             ` Yao Qi
2013-10-05  0:37               ` Doug Evans
2013-09-20 19:14       ` Tom Tromey
2013-09-19 17:25   ` [RFC 0/3] GDB Performance testing Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=521D7BCA.10806@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox