- removed unused function: SetSymbolValue

- enhanced a bit AddSymbol regarding invalid symbol management (and
  enhanced its traces)
- now printing type information in 'info sym'
This commit is contained in:
Eric Pouech 2003-02-19 03:41:48 +00:00 committed by Alexandre Julliard
parent 0607e083ac
commit d0882d5435
2 changed files with 50 additions and 67 deletions

View File

@ -330,7 +330,6 @@ extern int DEBUG_ReadLine(const char* pfx, char* buffer, int size);
/* debugger/display.c */ /* debugger/display.c */
extern int DEBUG_DoDisplay(void); extern int DEBUG_DoDisplay(void);
extern int DEBUG_AddDisplay(struct expr * exp, int count, char format); extern int DEBUG_AddDisplay(struct expr * exp, int count, char format);
extern int DEBUG_DoDisplay(void);
extern int DEBUG_DelDisplay(int displaynum); extern int DEBUG_DelDisplay(int displaynum);
extern int DEBUG_InfoDisplay(void); extern int DEBUG_InfoDisplay(void);
@ -361,7 +360,6 @@ extern struct name_hash * DEBUG_AddSymbol( const char *name,
const char *sourcefile, const char *sourcefile,
int flags); int flags);
extern enum get_sym_val DEBUG_GetSymbolValue( const char * name, const int lineno, DBG_VALUE *addr, int ); extern enum get_sym_val DEBUG_GetSymbolValue( const char * name, const int lineno, DBG_VALUE *addr, int );
extern BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *addr );
extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, extern const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
struct name_hash ** rtn, struct name_hash ** rtn,
unsigned int ebp, unsigned int ebp,

View File

@ -160,8 +160,9 @@ DEBUG_ResortSymbols(void)
if( (nh->flags & SYM_INVALID) == 0 ) if( (nh->flags & SYM_INVALID) == 0 )
nsym++; nsym++;
else else
DEBUG_Printf( DBG_CHN_MESG, "Symbol %s is invalid\n", nh->name ); DEBUG_Printf( DBG_CHN_MESG, "Symbol %s (%04lx:%08lx) is invalid\n",
} nh->name, nh->value.addr.seg, nh->value.addr.off );
}
} }
sorttab_nsym = nsym; sorttab_nsym = nsym;
@ -209,39 +210,53 @@ DEBUG_AddSymbol( const char * name, const DBG_VALUE *value,
hash = name_hash(name); hash = name_hash(name);
for (nh = name_hash_table[hash]; nh; nh = nh->next) for (nh = name_hash_table[hash]; nh; nh = nh->next)
{ {
if( ((nh->flags & SYM_INVALID) != 0) && strcmp(name, nh->name) == 0 ) if (name[0] == nh->name[0] && strcmp(name, nh->name) == 0)
{ {
#if 0 int c = memcmp(&nh->value.addr, &value->addr, sizeof(value->addr));
DEBUG_Printf(DBG_CHN_MESG, "Changing address for symbol %s (%08lx:%08lx => %08lx:%08lx)\n",
name, nh->value.addr.seg, nh->value.addr.off, value->addr.seg, value->addr.off);
#endif
nh->value.addr = value->addr;
if( nh->value.type == NULL && value->type != NULL )
{
nh->value.type = value->type;
nh->value.cookie = value->cookie;
}
/* it may happen that the same symbol is defined in several compilation
* units, but the linker decides to merge it into a single instance.
* in that case, we don't clear the invalid flag for all the compilation
* units (N_GSYM), and wait to get the symbol from the symtab
*/
if ((flags & SYM_INVALID) == 0)
nh->flags &= ~SYM_INVALID;
return nh; if ((nh->flags & SYM_INVALID) != 0)
} {
if (nh->value.addr.seg == value->addr.seg && /* this case happens in ELF files, where we don't get the
nh->value.addr.off == value->addr.off && * address of a symbol for the stabs part, but rather from
strcmp(name, nh->name) == 0 ) * the ELF sections. in this case, we'll call this function
{ * twice:
return nh; * - a first time while parsing the stabs, with a NULL
* address
* - a second time with the correct address
* SYM_INVALID is set for the first pass, and cleared in the second
* the code below gets most of information for both passes
* latest GCC version seem to provide correct address in first pass,
*/
if (nh->value.addr.seg == 0 && nh->value.addr.off == 0 && c != 0)
{
#if 0
DEBUG_Printf(DBG_CHN_MESG, "Changing address for symbol %s (%04lx:%08lx => %04lx:%08lx)\n",
name, nh->value.addr.seg, nh->value.addr.off, value->addr.seg, value->addr.off);
#endif
nh->value.addr = value->addr;
}
if (nh->value.type == NULL && value->type != NULL)
{
nh->value.type = value->type;
nh->value.cookie = value->cookie;
}
/* it may happen that the same symbol is defined in several compilation
* units, but the linker decides to merge it into a single instance.
* in that case, we don't clear the invalid flag for all the compilation
* units (N_GSYM), and wait to get the symbol from the symtab
*/
if ((flags & SYM_INVALID) == 0)
nh->flags &= ~SYM_INVALID;
return nh;
}
/* don't define a symbol twice */
if (c == 0 && (flags & SYM_INVALID) == 0) return nh;
} }
} }
#if 0 #if 0
DEBUG_Printf(DBG_CHN_TRACE, "adding symbol (%s) from file '%s' at 0x%04lx:%08lx\n", DEBUG_Printf(DBG_CHN_TRACE, "adding %s symbol (%s) from file '%s' at %04lx:%08lx\n",
name, source, value->addr.seg, value->addr.off); (flags & SYM_INVALID) ? "invalid" : " valid", name, source, value->addr.seg, value->addr.off);
#endif #endif
/* /*
@ -499,42 +514,6 @@ BOOL DEBUG_GetLineNumberAddr( const struct name_hash * nh, const int lineno,
return TRUE; return TRUE;
} }
/***********************************************************************
* DEBUG_SetSymbolValue
*
* Set the address of a named symbol.
*/
BOOL DEBUG_SetSymbolValue( const char * name, const DBG_VALUE *value )
{
char buffer[256];
struct name_hash *nh;
assert(value->cookie == DV_TARGET || value->cookie == DV_HOST);
for(nh = name_hash_table[name_hash(name)]; nh; nh = nh->next)
if (!strcmp(nh->name, name)) break;
if (!nh && (name[0] != '_'))
{
buffer[0] = '_';
strcpy(buffer+1, name);
for(nh = name_hash_table[name_hash(buffer)]; nh; nh = nh->next)
if (!strcmp(nh->name, buffer)) break;
}
if (!nh) return FALSE;
nh->value = *value;
nh->flags &= ~SYM_INVALID;
#ifdef __i386__
DEBUG_FixAddress( &nh->value.addr, DEBUG_context.SegDs );
#endif
return TRUE;
}
/*********************************************************************** /***********************************************************************
* DEBUG_FindNearestSymbol * DEBUG_FindNearestSymbol
* *
@ -1394,6 +1373,12 @@ void DEBUG_InfoSymbols(const char* str)
array[i]->value.addr.off ); array[i]->value.addr.off );
else else
DEBUG_Printf( DBG_CHN_MESG, "%08lx :", array[i]->value.addr.off ); DEBUG_Printf( DBG_CHN_MESG, "%08lx :", array[i]->value.addr.off );
if (array[i]->value.type)
{
DEBUG_Printf( DBG_CHN_MESG, " (");
DEBUG_PrintTypeCast(array[i]->value.type);
DEBUG_Printf( DBG_CHN_MESG, ")");
}
if (name) DEBUG_Printf( DBG_CHN_MESG, " %s\n", name ); if (name) DEBUG_Printf( DBG_CHN_MESG, " %s\n", name );
} }
HeapFree(GetProcessHeap(), 0, array); HeapFree(GetProcessHeap(), 0, array);