Another #SF patch merge

another patch to fix compilation with vc8 (or, more
precisely with Dimkunware STL). It corrects the usage of std::set
iterators.
This commit is contained in:
Stanislav Shwartsman 2008-03-26 22:39:07 +00:00
parent 8c24dfc01b
commit 15106acdba
1 changed files with 89 additions and 81 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: symbols.cc,v 1.8 2008-02-05 22:33:33 sshwarts Exp $ // $Id: symbols.cc,v 1.9 2008-03-26 22:39:07 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -125,20 +125,25 @@ struct lt_rsymbol_entry_t
struct context_t struct context_t
{ {
typedef set<symbol_entry_t*,lt_symbol_entry_t> sym_set_t;
typedef set<symbol_entry_t*,lt_rsymbol_entry_t> rsym_set_t;
context_t (Bit32u); context_t (Bit32u);
~context_t(); ~context_t();
static context_t* get_context(Bit32u); static context_t* get_context(Bit32u);
symbol_entry_t* get_symbol_entry(Bit32u); symbol_entry_t* get_symbol_entry(Bit32u);
symbol_entry_t* get_symbol_entry(const char *Symbol) const; symbol_entry_t* get_symbol_entry(const char *Symbol) const;
void add_symbol(symbol_entry_t*); void add_symbol(symbol_entry_t*);
const set<symbol_entry_t*,lt_symbol_entry_t>* get_all_symbols() const {return syms;} const sym_set_t* get_all_symbols() const {return syms;}
const set<symbol_entry_t*,lt_rsymbol_entry_t>* get_all_rsymbols() const {return rsyms;} const rsym_set_t* get_all_rsymbols() const {return rsyms;}
private: private:
static hash_map<int,context_t*>* map; static hash_map<int,context_t*>* map;
// Forvard references (find name by address) // Forvard references (find name by address)
set<symbol_entry_t*,lt_symbol_entry_t>* syms; sym_set_t* syms;
// Reverse references (find address by name) // Reverse references (find address by name)
set<symbol_entry_t*,lt_rsymbol_entry_t>* rsyms; rsym_set_t* rsyms;
Bit32u id; Bit32u id;
}; };
@ -147,21 +152,22 @@ hash_map<int,context_t*>* context_t::map = new hash_map<int,context_t*>;
context_t::context_t (Bit32u _id) context_t::context_t (Bit32u _id)
{ {
id = _id; id = _id;
syms = new set<symbol_entry_t*, lt_symbol_entry_t>; syms = new sym_set_t;
rsyms = new set<symbol_entry_t*, lt_rsymbol_entry_t>; rsyms = new rsym_set_t;
(*map)[id] = this; (*map)[id] = this;
} }
context_t::~context_t() context_t::~context_t()
{ {
set<symbol_entry_t*>::iterator iter;
if(syms) { if(syms) {
sym_set_t::iterator iter;
for(iter=syms->begin();iter!=syms->end();++iter) for(iter=syms->begin();iter!=syms->end();++iter)
if(*iter) if(*iter)
delete *iter; delete *iter;
} }
if(rsyms) { if(rsyms) {
rsym_set_t::iterator iter;
for(iter=rsyms->begin();iter!=rsyms->end();++iter) for(iter=rsyms->begin();iter!=rsyms->end();++iter)
if(*iter) if(*iter)
delete *iter; delete *iter;
@ -179,7 +185,7 @@ symbol_entry_t* context_t::get_symbol_entry(Bit32u ip)
probe.start = ip; probe.start = ip;
// find the first symbol whose address is greater than ip. // find the first symbol whose address is greater than ip.
if (syms->empty ()) return 0; if (syms->empty ()) return 0;
set<symbol_entry_t*>::iterator iter = syms->upper_bound(&probe); sym_set_t::iterator iter = syms->upper_bound(&probe);
if (iter == syms->end()) { // No symbol found if (iter == syms->end()) { // No symbol found
return 0; return 0;
@ -196,7 +202,7 @@ symbol_entry_t* context_t::get_symbol_entry(const char *Symbol) const
if (rsyms->empty()) if (rsyms->empty())
return 0; return 0;
set<symbol_entry_t*>::const_iterator iter; rsym_set_t::const_iterator iter;
iter=rsyms->find(&probe); iter=rsyms->find(&probe);
if(iter==rsyms->end()) // No symbol found if(iter==rsyms->end()) // No symbol found
return 0; return 0;
@ -358,7 +364,7 @@ void bx_dbg_info_symbols_command(char *Symbol)
} }
if(Symbol) { if(Symbol) {
const set<symbol_entry_t*,lt_rsymbol_entry_t>* rsyms; const context_t::rsym_set_t* rsyms;
rsyms=cntx->get_all_rsymbols(); rsyms=cntx->get_all_rsymbols();
if (rsyms->empty ()) { if (rsyms->empty ()) {
@ -372,18 +378,19 @@ void bx_dbg_info_symbols_command(char *Symbol)
symbol_entry_t probe; symbol_entry_t probe;
probe.name=Symbol; probe.name=Symbol;
set<symbol_entry_t*>::const_iterator iter; context_t::rsym_set_t::const_iterator iter;
iter=rsyms->lower_bound(&probe); iter=rsyms->lower_bound(&probe);
if(iter==rsyms->end() || !bx_dbg_strprefix(Symbol, (*iter)->name)) if(iter==rsyms->end() || !bx_dbg_strprefix(Symbol, (*iter)->name))
dbg_printf ("No symbols found\n"); dbg_printf ("No symbols found\n");
else else {
for(;iter!=rsyms->end() && bx_dbg_strprefix(Symbol, (*iter)->name);++iter) { for(;iter!=rsyms->end() && bx_dbg_strprefix(Symbol, (*iter)->name);++iter) {
dbg_printf ("%08x: %s\n", (*iter)->start, (*iter)->name); dbg_printf ("%08x: %s\n", (*iter)->start, (*iter)->name);
} }
} }
}
else { else {
const set<symbol_entry_t*,lt_symbol_entry_t>* syms; const context_t::sym_set_t* syms;
syms=cntx->get_all_symbols(); syms=cntx->get_all_symbols();
if (syms->empty ()) { if (syms->empty ()) {
@ -391,7 +398,7 @@ void bx_dbg_info_symbols_command(char *Symbol)
return; return;
} }
set<symbol_entry_t*>::const_iterator iter; context_t::sym_set_t::const_iterator iter;
for(iter = syms->begin();iter!=syms->end();++iter) { for(iter = syms->begin();iter!=syms->end();++iter) {
dbg_printf ("%08x: %s\n", (*iter)->start, (*iter)->name); dbg_printf ("%08x: %s\n", (*iter)->start, (*iter)->name);
} }
@ -415,5 +422,6 @@ int bx_dbg_lbreakpoint_symbol_command(char *Symbol)
dbg_printf ("Symbol not found\n"); dbg_printf ("Symbol not found\n");
return -1; return -1;
} }
#endif #endif
#endif #endif