| 693 | |
| 694 | |
| 695 | DebuggerState::DebuggerState(BinaryViewRef data, DebuggerController* controller) : m_controller(controller) |
| 696 | { |
| 697 | INIT_DEBUGGER_API_OBJECT(); |
| 698 | |
| 699 | m_adapter = nullptr; |
| 700 | m_modules = new DebuggerModules(this); |
| 701 | m_registers = new DebuggerRegisters(this); |
| 702 | m_threads = new DebuggerThreads(this); |
| 703 | m_breakpoints = new DebuggerBreakpoints(this); |
| 704 | m_breakpoints->UnserializedMetadata(); |
| 705 | m_memory = new DebuggerMemory(this); |
| 706 | |
| 707 | // TODO: A better way to deal with this is to have the adapters return a fitness score, and then we pick the highest |
| 708 | // one from the list. Similar to what we do for the views. |
| 709 | m_availableAdapters = DebugAdapterType::GetAvailableAdapters(data); |
| 710 | m_adapterType = DebugAdapterType::GetBestAdapterForCurrentSystem(data); |
| 711 | // Check whether there is no available adapters at all |
| 712 | if (m_availableAdapters.size() == 0) |
| 713 | { |
| 714 | m_adapterType = ""; |
| 715 | } |
| 716 | else if (std::find(m_availableAdapters.begin(), m_availableAdapters.end(), m_adapterType) |
| 717 | == m_availableAdapters.end()) |
| 718 | { |
| 719 | // The system's default adapter does not work with the current data, e.g., an .exe is opened on macOS, |
| 720 | // then pick one from the available ones. |
| 721 | m_adapterType = m_availableAdapters[0]; |
| 722 | } |
| 723 | |
| 724 | Ref<Metadata> metadata; |
| 725 | metadata = m_controller->GetData()->QueryMetadata("debugger.command_line_args"); |
| 726 | if (metadata && metadata->IsString()) |
| 727 | m_commandLineArgs = metadata->GetString(); |
| 728 | |
| 729 | metadata = m_controller->GetData()->QueryMetadata("debugger.input_file"); |
| 730 | if (metadata && metadata->IsString()) |
| 731 | m_inputFile = metadata->GetString(); |
| 732 | |
| 733 | if (m_inputFile == "") |
| 734 | m_inputFile = m_controller->GetData()->GetFile()->GetOriginalFilename(); |
| 735 | |
| 736 | metadata = m_controller->GetData()->QueryMetadata("debugger.executable_path"); |
| 737 | if (metadata && metadata->IsString()) |
| 738 | m_executablePath = metadata->GetString(); |
| 739 | |
| 740 | if (m_executablePath == "") |
| 741 | m_executablePath = m_controller->GetData()->GetFile()->GetOriginalFilename(); |
| 742 | |
| 743 | metadata = m_controller->GetData()->QueryMetadata("debugger.working_directory"); |
| 744 | if (metadata && metadata->IsString()) |
| 745 | m_workingDirectory = metadata->GetString(); |
| 746 | |
| 747 | if (m_workingDirectory == "") |
| 748 | { |
| 749 | // This mitigates https://github.com/Vector35/debugger/issues/469. However, it is NOT a proper fix since the |
| 750 | // debugger still will not be able to launch the target properly. We will need to deal with the charset issue |
| 751 | // to get this really fixed. |
| 752 | try |
nothing calls this directly
no test coverage detected