| 11 | } |
| 12 | |
| 13 | SymbolHandler* SymbolManager::GetForProcess(DWORD pid) { |
| 14 | auto it = _procSymbols.find(pid); |
| 15 | if (it == _procSymbols.end()) { |
| 16 | // attempt to get one |
| 17 | auto symbols = SymbolHandler::CreateForProcess(pid); |
| 18 | if (symbols == nullptr) |
| 19 | return nullptr; |
| 20 | auto sym = symbols.get(); |
| 21 | _procSymbols.insert({ pid,std::move(symbols) }); |
| 22 | return sym; |
| 23 | } |
| 24 | if (::WaitForSingleObject(it->second->GetHandle(), 0) == WAIT_OBJECT_0) { |
| 25 | // process dead,remove and try again |
| 26 | _procSymbols.erase(pid); |
| 27 | return GetForProcess(pid); |
| 28 | } |
| 29 | return it->second.get(); |
| 30 | } |
| 31 | |
| 32 | std::unique_ptr<SymbolInfo> SymbolManager::GetSymbolFromAddress(DWORD pid, DWORD64 address, PDWORD64 offset) { |
| 33 | if ((int64_t)address < 0) { |