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: [PATCH] bug fix for gdb 16039


On Monday, October 21 2013, Dave Tian wrote:

> Testcase below:
>
> ----Makefile----
> so:
>       g++ -shared -static-libstdc++ -static-libgcc -fPIC -rdynamic
> dy.cxx -m32 -o libdy.so
> all: so
>       g++ -m32 -ldl main.cxx -g -o main
>
> ----dy.cxx----
> #include <string>
> using namespace std;
>
> extern "C" const char * getVerson()
> {
>     std::string verson = "1.0";
>     return verson.c_str();
> }
>
> ----main.cxx----
> #include <dlfcn.h>
> #include <stdio.h>
> #include <string>
> #include <iostream>
> using namespace std;
>
> int main()
> {
>     void *handle = dlopen("libdy.so", RTLD_LAZY);
>     if (!handle) {
>         fprintf (stderr, "%s\n", dlerror());
>         return 1;
>     }
>
>     typedef const char*(*FUNCTION)();
>     FUNCTION f = (FUNCTION)dlsym(handle, "getVerson");
>     std::cout << f();
>
>     dlclose(handle);
>
>     // 'next' cmd stop work here
>     int a, b, c;
>     a = 1;
>     b = 2;
>     c = 3;
>     std::cout << a << b << c;
> }

Sorry for taking so long to respond.

Thanks, but this testcase should actually be made in the default
fashion, i.e., take a look at the directory gdb/testsuite and see the
many directories and testcases there.

You will also find this link useful:

<https://sourceware.org/gdb/wiki/GDBTestcaseCookbook>

Thanks for persevering.

-- 
Sergio


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