This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] bug fix for gdb 16039
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: "Dave.Tian" <xhengdf at gmail dot com>
- Cc: tromey at redhat dot com, gdb-patches at sourceware dot org
- Date: Mon, 28 Oct 2013 21:33:04 -0200
- Subject: Re: [PATCH] bug fix for gdb 16039
- Authentication-results: sourceware.org; auth=none
- References: <CAKjgB1NmhyvBFfBF2HgQc-9KP0OMPMb9fNXJAe3QxejdD3-X1g at mail dot gmail dot com> <m3bo2pj3ha dot fsf at redhat dot com> <CAKjgB1OyrUtz9xqcqDSxEe72kDGEWBKy9LxZEkXDDd7RbX7y=A at mail dot gmail dot com> <m3k3h9c1tq dot fsf at redhat dot com> <CAKjgB1NDEZX3hDFY6pFzH397nMtNOkwtKVm-msR_5D5eZSGWyQ at mail dot gmail dot com>
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