| 2031 | |
| 2032 | |
| 2033 | std::string DebuggerController::GetAddressInformation(uint64_t address) |
| 2034 | { |
| 2035 | // Avoid too many results in the register widget when the address is 0x0 |
| 2036 | if (address == 0) |
| 2037 | return ""; |
| 2038 | |
| 2039 | const DataBuffer memory = ReadMemory(address, 128); |
| 2040 | auto result = CheckForPrintableString(memory); |
| 2041 | // If we can find a string at the address, return it |
| 2042 | if (!result.empty()) |
| 2043 | return result; |
| 2044 | |
| 2045 | // Check pointer to strings |
| 2046 | auto buffer = m_liveView->ReadBuffer(address, m_liveView->GetAddressSize()); |
| 2047 | if (buffer.GetLength() == m_liveView->GetAddressSize()) |
| 2048 | { |
| 2049 | uint64_t pointerValue = *reinterpret_cast<std::uintptr_t*>(buffer.GetData()); |
| 2050 | if (pointerValue != 0) |
| 2051 | { |
| 2052 | const DataBuffer pointerMemory = ReadMemory(pointerValue, 128); |
| 2053 | result = CheckForPrintableString(pointerMemory); |
| 2054 | if (!result.empty()) |
| 2055 | return std::string("&") + result; |
| 2056 | } |
| 2057 | } |
| 2058 | |
| 2059 | |
| 2060 | // Look for functions starting at the address |
| 2061 | auto func = m_liveView->GetAnalysisFunction(m_liveView->GetDefaultPlatform(), address); |
| 2062 | if (func) |
| 2063 | { |
| 2064 | auto sym = func->GetSymbol(); |
| 2065 | if (sym) |
| 2066 | return sym->GetShortName(); |
| 2067 | } |
| 2068 | |
| 2069 | // Look for functions containing the address |
| 2070 | for (const auto& func: m_liveView->GetAnalysisFunctionsContainingAddress(address)) |
| 2071 | { |
| 2072 | auto sym = func->GetSymbol(); |
| 2073 | if (sym) |
| 2074 | { |
| 2075 | return fmt::format("{} + 0x{:x}", sym->GetShortName(), address - func->GetStart()); |
| 2076 | } |
| 2077 | } |
| 2078 | |
| 2079 | // Look for symbols |
| 2080 | auto sym = m_liveView->GetSymbolByAddress(address); |
| 2081 | if (sym) |
| 2082 | { |
| 2083 | return sym->GetShortName(); |
| 2084 | } |
| 2085 | |
| 2086 | // Look for data variables |
| 2087 | DataVariable var; |
| 2088 | if (m_liveView->GetDataVariableAtAddress(address, var)) |
| 2089 | { |
| 2090 | sym = m_liveView->GetSymbolByAddress(var.address); |
no test coverage detected