diff --git a/src/Debug.cc b/src/Debug.cc index de84471691..5f6c3bd7fb 100644 --- a/src/Debug.cc +++ b/src/Debug.cc @@ -27,7 +27,7 @@ using namespace std; bool g_policy_debug = false; DebuggerState g_debugger_state; TraceState g_trace_state; -PDict g_dbgfilemaps; +std::map g_dbgfilemaps; // 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 @@ -364,8 +364,8 @@ vector parse_location_string(const string& s) if ( plr.type == plrFileAndLine ) { - Filemap* map = g_dbgfilemaps.Lookup(loc_filename); - if ( ! map ) + auto iter = g_dbgfilemaps.find(loc_filename); + if ( iter == g_dbgfilemaps.end() ) reporter->InternalError("Policy file %s should have been loaded\n", loc_filename); @@ -378,7 +378,7 @@ vector parse_location_string(const string& s) } StmtLocMapping* hit = 0; - for ( const auto entry : *map ) + for ( const auto entry : *(iter->second) ) { plr.filename = entry->Loc().filename; diff --git a/src/Debug.h b/src/Debug.h index 7e414262c9..16d6761bce 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -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 PDict g_dbgfilemaps; // filename => filemap +extern std::map g_dbgfilemaps; // filename => filemap // Perhaps add a code/priority argument to do selective output. int debug_msg(const char* fmt, ...) __attribute__ ((format (printf, 1, 2))); diff --git a/src/Stmt.cc b/src/Stmt.cc index 2576fc544f..fca38a357a 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -50,11 +50,11 @@ bool Stmt::SetLocationInfo(const Location* start, const Location* end) // Update the Filemap of line number -> statement mapping for // breakpoints (Debug.h). - Filemap* map_ptr = (Filemap*) g_dbgfilemaps.Lookup(location->filename); - if ( ! map_ptr ) + auto map_iter = g_dbgfilemaps.find(location->filename); + if ( map_iter == g_dbgfilemaps.end() ) return false; - Filemap& map = *map_ptr; + Filemap& map = *(map_iter->second); StmtLocMapping* new_mapping = new StmtLocMapping(GetLocationInfo(), this); diff --git a/src/scan.l b/src/scan.l index ce389bb9fd..1cb6119f81 100644 --- a/src/scan.l +++ b/src/scan.l @@ -671,7 +671,7 @@ static int load_files(const char* orig_file) // Add the filename to the file mapping table (Debug.h). Filemap* map = new Filemap; HashKey* key = new HashKey(file_path.c_str()); - g_dbgfilemaps.Insert(key, map); + g_dbgfilemaps.emplace(file_path, map); LoadPolicyFileText(file_path.c_str()); }