public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "jsrhbz at kanargh dot force9 dot co dot uk" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/11035] New: gdb ignores explicit scoping for ambiguous symbols
Date: Mon, 30 Nov 2009 16:16:00 -0000 [thread overview]
Message-ID: <20091130161616.11035.jsrhbz@kanargh.force9.co.uk> (raw)
Take the trivial example using 2 shared objects:
----m.cpp----
#include <stdio.h>
#include <dlfcn.h>
typedef void (*vvf)();
vvf so1_func;
vvf so2_func;
void m()
{
printf(">>>m\n");
so1_func();
so2_func();
printf("<<<m\n");
}
int main(int argc, char *argv[])
{
void *p = dlopen("./so1.so", RTLD_LOCAL|RTLD_LAZY);
so1_func = (vvf)dlsym(p, "so1_func");
printf("p=%p f=%p\n", p, so1_func);
p = dlopen("./so2.so", RTLD_LOCAL|RTLD_LAZY);
so2_func = (vvf)dlsym(p, "so2_func");
printf("p=%p f=%p\n", p, so2_func);
m();
}
----so1.cpp----
#include <stdio.h>
class A {
public:
void pA() { printf("so1::pA() in %p\n", this); }
int so1_a;
} foo;
extern "C" void so1_func()
{
printf("so1::foo = %p\n", &foo);
foo.pA();
}
----so2.cpp----
#include <stdio.h>
class A {
public:
void pA() { printf("so2::pA() in %p\n", this); }
int so2_a;
} foo;
extern "C" void so2_func()
{
printf("so2::foo = %p\n", &foo);
foo.pA();
}
----Makefile----
all: m so1.so so2.so
m: m.cpp
$(CXX) -g m.cpp -o m -ldl
so1.so: so1.cpp
$(CXX) -g so1.cpp -o so1.so -shared -rdynamic -fPIC
so2.so: so2.cpp
$(CXX) -g so2.cpp -o so2.so -shared -rdynamic -fPIC
----
Executing ./m shows that both .so instances can quite happily maintain their own
"foo" instances with no confusion. However, breakpointing in gdb just before the
call to m():
26 m();
(gdb) print foo
$1 = {so1_a = 0}
(gdb) print 'so1.cpp'::foo
$2 = {so1_a = 0}
(gdb) print 'so2.cpp'::foo
$3 = {so1_a = 0}
(gdb) print *(A*)0x7ffff7dbda38
$4 = {so1_a = 0}
(gdb) print *('so2.cpp'::A*)0x7ffff7dbda38
A syntax error in expression, near `)0x7ffff7dbda38'.
(gdb)
The scoping should direct gdb to a particular instance, however it is ignored so
there seems to be no way to directly inspect the other instance.
Even if you can extract the address of the instance (here, from the output of
m(), but usually via a conveniant variable or function argument), gdb will by
default interpret the cast in the context of the wrong module, and there doesn't
appear to tell it to use the definition of A from so2 instead.
--
Summary: gdb ignores explicit scoping for ambiguous symbols
Product: gdb
Version: 6.8
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: symtab
AssignedTo: unassigned at sourceware dot org
ReportedBy: jsrhbz at kanargh dot force9 dot co dot uk
CC: gdb-prs at sourceware dot org
GCC host triplet: x86_64-redhat-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11035
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
next reply other threads:[~2009-11-30 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-30 16:16 jsrhbz at kanargh dot force9 dot co dot uk [this message]
2010-03-22 15:13 ` [Bug symtab/11035] " tromey at redhat dot com
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=20091130161616.11035.jsrhbz@kanargh.force9.co.uk \
--to=sourceware-bugzilla@sourceware.org \
--cc=gdb-prs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).