g_dbgfilemaps: Remove uses of PDict

This commit is contained in:
Tim Wojtulewicz 2019-07-26 13:23:56 -07:00 committed by Jon Siwek
parent a3deb0446c
commit d0e8af9343
4 changed files with 9 additions and 9 deletions

View file

@ -27,7 +27,7 @@ using namespace std;
bool g_policy_debug = false; bool g_policy_debug = false;
DebuggerState g_debugger_state; DebuggerState g_debugger_state;
TraceState g_trace_state; TraceState g_trace_state;
PDict<Filemap> g_dbgfilemaps; std::map<string, Filemap*> g_dbgfilemaps;
// These variables are used only to decide whether or not to print the // These variables are used only to decide whether or not to print the
// current context; you don't want to do it after a step or next // current context; you don't want to do it after a step or next
@ -364,8 +364,8 @@ vector<ParseLocationRec> parse_location_string(const string& s)
if ( plr.type == plrFileAndLine ) if ( plr.type == plrFileAndLine )
{ {
Filemap* map = g_dbgfilemaps.Lookup(loc_filename); auto iter = g_dbgfilemaps.find(loc_filename);
if ( ! map ) if ( iter == g_dbgfilemaps.end() )
reporter->InternalError("Policy file %s should have been loaded\n", reporter->InternalError("Policy file %s should have been loaded\n",
loc_filename); loc_filename);
@ -378,7 +378,7 @@ vector<ParseLocationRec> parse_location_string(const string& s)
} }
StmtLocMapping* hit = 0; StmtLocMapping* hit = 0;
for ( const auto entry : *map ) for ( const auto entry : *(iter->second) )
{ {
plr.filename = entry->Loc().filename; plr.filename = entry->Loc().filename;

View file

@ -176,7 +176,7 @@ string get_context_description(const Stmt* stmt, const Frame* frame);
extern Frame* g_dbg_locals; // variables created within debugger context extern Frame* g_dbg_locals; // variables created within debugger context
extern PDict<Filemap> g_dbgfilemaps; // filename => filemap extern std::map<string, Filemap*> g_dbgfilemaps; // filename => filemap
// Perhaps add a code/priority argument to do selective output. // Perhaps add a code/priority argument to do selective output.
int debug_msg(const char* fmt, ...) __attribute__ ((format (printf, 1, 2))); int debug_msg(const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));

View file

@ -50,11 +50,11 @@ bool Stmt::SetLocationInfo(const Location* start, const Location* end)
// Update the Filemap of line number -> statement mapping for // Update the Filemap of line number -> statement mapping for
// breakpoints (Debug.h). // breakpoints (Debug.h).
Filemap* map_ptr = (Filemap*) g_dbgfilemaps.Lookup(location->filename); auto map_iter = g_dbgfilemaps.find(location->filename);
if ( ! map_ptr ) if ( map_iter == g_dbgfilemaps.end() )
return false; return false;
Filemap& map = *map_ptr; Filemap& map = *(map_iter->second);
StmtLocMapping* new_mapping = new StmtLocMapping(GetLocationInfo(), this); StmtLocMapping* new_mapping = new StmtLocMapping(GetLocationInfo(), this);

View file

@ -671,7 +671,7 @@ static int load_files(const char* orig_file)
// Add the filename to the file mapping table (Debug.h). // Add the filename to the file mapping table (Debug.h).
Filemap* map = new Filemap; Filemap* map = new Filemap;
HashKey* key = new HashKey(file_path.c_str()); HashKey* key = new HashKey(file_path.c_str());
g_dbgfilemaps.Insert(key, map); g_dbgfilemaps.emplace(file_path, map);
LoadPolicyFileText(file_path.c_str()); LoadPolicyFileText(file_path.c_str());
} }