Subject: | duplicate file-static variables OR what's up with rbtdb64.c? |
I ran into this while looking through a core file. At first I thought that
gdb had lost its mind, but now I think that maybe we've got a problem in
our code.
It seems that the file-static variable zone_methods is declared twice in
lib/dns/rbtdb.c (currently lines 6460 and 7870).
gdb shows both of these in the output of 'info variables zone_methods',
and will report both addresses as being 'zone_methods'.
----BEGIN GDB OUTPUT #1----
(gdb) info variables zone_methods
All variables matching regular expression "zone_methods":
File rbtdb.c:
static dns_dbmethods_t zone_methods;
static dns_dbmethods_t zone_methods;
(gdb) print &zone_methods
$1 = (dns_dbmethods_t *) 0x8b9e40 <zone_methods>
(gdb) info symbol 0x8b9e40
zone_methods in section .data
(gdb) info symbol 0x8ba200
zone_methods in section .data
----END GDB OUTPUT #1----
Although, as I've been collecting data and output for this ticket, I'm
starting to wonder if the duplication goes deeper:
----BEGIN GDB OUTPUT #2----
(gdb) print *(dns_dbmethods_t*)0x8b9e40
$4 = {attach = 0x4d1290 <attach>, [...]}
(gdb) print *(dns_dbmethods_t*)0x8ba200
$5 = {attach = 0x4e7fb0 <attach>, [...]}
(gdb) info functions ^attach$
All functions matching regular expression "^attach$":
File rbtdb.c:
static void attach(dns_db_t *, dns_db_t **);
static void attach(dns_db_t *, dns_db_t **);
File sdb.c:
static void attach(dns_db_t *, dns_db_t **);
File sdlz.c:
static void attach(dns_db_t *, dns_db_t **);
File ecdb.c:
static void attach(dns_db_t *, dns_db_t **);
----END GDB OUTPUT #2----
Looking at the contents of libdns.a with 'nm', I think it has to do
with rbtdb64.c. The contents of which, excluding comments, is included
inline here:
----BEGIN rbtdb64.c----
#define DNS_RBTDB_VERSION64 1
#include "rbtdb.c"
----END rbtdb64.c----
It seems that maybe gdb is picking up the 'rbtdb.c' file name for the
symbols (both functions and variables) declared and defined in rbtdb64.c
via #include of rbtdb.c.
What is the purpose of, and value provided by, rbtdb64.c?