From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25699 invoked by alias); 1 Apr 2002 00:53:48 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 25692 invoked from network); 1 Apr 2002 00:53:47 -0000 Received: from unknown (HELO smtp.comcast.net) (24.153.64.2) by sources.redhat.com with SMTP; 1 Apr 2002 00:53:47 -0000 Received: from rogue (bgp507590bgs.verona01.nj.comcast.net [68.38.9.13]) by mtaout02.icomcast.net (iPlanet Messaging Server 5.1 (built Feb 6 2002)) with ESMTP id <0GTV00K736HNEQ@mtaout02.icomcast.net> for gdb@sources.redhat.com; Sun, 31 Mar 2002 19:53:47 -0500 (EST) Date: Sun, 31 Mar 2002 16:53:00 -0000 From: Koon-Seng Lim Subject: Setting breakpoints in a virtual function on a dynamically loaded DLL To: gdb@sources.redhat.com Reply-to: koonseng@ctr.columbia.edu Message-id: <000001c1d917$853ae830$9e01a8c0@rogue> Organization: Columbia University MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-SW-Source: 2002-03/txt/msg00309.txt.bz2 Hi, I'm trying to set a breakpoint in a virtual function (new_foo::bar()) implemented in a DLL (testdll.dll) which I load dynamically from an .exe (fooloader.exe). I get the following errors: $ gdb fooloader.exe ... (gdb) shared testdll.dll (gdb) (gdb) break new_foo::bar Error: Cannot access memory at address 0x010001014 If I forcibly set a breakpoint at new_foo::bar using the GUI, I get an error dialog that says "cannot insert breakpoint 1:" and the message "Error: Cannot access memory at address 0x01000101e" in the console window. My question is: 1. Is there any way at all to set a breakpoint in the testdll.dll? 2. Did I doing something silly? The code is very simple and it steps correctly under the MSVC debugger. I'm running gdb 5.0 with the Insight GUI on cygwin 1.3.10 on a windows box. Any help is greatly appreciated!!! The 3 files listed below are compiled and linked using: c++ -g -DVERBOSE -DWIN32 -DDLL_EXPORT -I. -c -o fooloader.o fooloader.cpp c++ -g -DVERBOSE -DWIN32 -DDLL_EXPORT -I. -c -o testdll.o testdll.cpp c++ -shared -o testdll.dll -mwindows --export-all testdll.o /lib/libstdc++.a c++ -o fooloader.exe fooloader.o --------------------------foo.h ------------------------- class foo { public: virtual void bar() = 0; }; -----------------------testdll.cpp----------------------- #include #include "foo.h" #ifdef __cplusplus extern "C" { #endif void *create_object(); #ifdef __cplusplus } #endif class new_foo : foo { public: void bar(); }; void new_foo::bar() { printf("in new_foo::bar()\n"); } void *create_object() { return (void *)new new_foo; } -----------------------fooloader.cpp------------------------ #include #include "foo.h" typedef void *(*CREATE_OBJECT)(); int main() { HMODULE module = LoadLibrary("testdll.dll"); CREATE_OBJECT create_foo = (CREATE_OBJECT)GetProcAddress(module, "create_object"); foo *my_foo = (foo *)(create_foo)(); my_foo->bar(); }