Index: gdb/testsuite/gdb.perf/solib.c |
diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.c b/gdb/testsuite/gdb.perf/solib.c |
similarity index 56% |
copy from gdb/testsuite/gdb.base/watchpoint-solib.c |
copy to gdb/testsuite/gdb.perf/solib.c |
index a14c15a01f85d5f13622a8e1d698f5a2c1ce7da2..5da944d89cbe9cd2ab206aed179136e58513eb65 100644 |
--- a/gdb/testsuite/gdb.base/watchpoint-solib.c |
+++ b/gdb/testsuite/gdb.perf/solib.c |
@@ -1,6 +1,6 @@ |
/* This testcase is part of GDB, the GNU debugger. |
- Copyright 2004, 2007, 2009-2012 Free Software Foundation, Inc. |
+ 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 |
@@ -13,7 +13,7 @@ |
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/>. */ |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
#include <stdio.h> |
#include <stdlib.h> |
@@ -21,51 +21,63 @@ |
#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 |
+static void **handles; |
-void open_shlib () |
+void |
+do_test_load (int number) |
{ |
- void *handle; |
- void (*foo) (int); |
+ char libname[40]; |
+ int i; |
- handle = dlopen (SHLIB_NAME, RTLD_LAZY); |
- |
- if (!handle) |
+ handles = malloc (sizeof (void *) * number); |
+ if (handles == NULL) |
{ |
-#ifdef __WIN32__ |
- fprintf (stderr, "error %d occurred\n", GetLastError ()); |
-#else |
- fprintf (stderr, "%s\n", dlerror ()); |
-#endif |
- exit (1); |
+ printf ("ERROR on malloc\n"); |
+ exit (-1); |
} |
- foo = (void (*)(int))dlsym (handle, "foo"); |
- |
- if (!foo) |
+ for (i = 0; i < number; i++) |
{ |
- fprintf (stderr, "%s\n", dlerror ()); |
- exit (1); |
+ sprintf (libname, "solib-lib%d", i); |
+ handles[i] = dlopen (libname, RTLD_LAZY); |
+ if (handles[i] == NULL) |
+ { |
+ printf ("ERROR on dlopen %s\n", libname); |
+ exit (-1); |
+ } |
} |
+} |
+ |
+void |
+do_test_unload (int number) |
+{ |
+ int i; |
- foo (1); // call to foo |
- foo (2); |
+ /* Unload shared libraries in different orders. */ |
+#ifndef SOLIB_DLCLOSE_REVERSED_ORDER |
+ for (i = 0; i < number; i++) |
+#else |
+ for (i = number - 1; i >= 0; i--) |
+#endif |
+ dlclose (handles[i]); |
- dlclose (handle); |
+ free (handles); |
} |
+static void |
+end (void) |
+{} |
-int main() |
+int |
+main (void) |
{ |
- open_shlib (); |
+ end (); |
+ |
return 0; |
} |