|
8 | 8 | // granted to it by virtue of its status as an Intergovernmental Organization |
9 | 9 | // or submit itself to any jurisdiction. |
10 | 10 | #include "Framework/FrameworkGUIDebugger.h" |
11 | | -#include <algorithm> |
12 | | -#include <iostream> |
13 | | -#include <set> |
14 | | -#include <string> |
15 | | -#include <cinttypes> |
16 | 11 | #include "Framework/ConfigContext.h" |
17 | 12 | #include "Framework/ConfigParamRegistry.h" |
18 | 13 | #include "DebugGUI/imgui.h" |
|
26 | 21 | #include "Framework/PaletteHelpers.h" |
27 | 22 | #include "Framework/FrameworkGUIState.h" |
28 | 23 |
|
| 24 | +#include <fmt/format.h> |
| 25 | + |
| 26 | +#include <algorithm> |
| 27 | +#include <iostream> |
| 28 | +#include <set> |
| 29 | +#include <string> |
| 30 | +#include <cinttypes> |
| 31 | + |
29 | 32 | // Simplify debugging |
30 | 33 | template class std::vector<o2::framework::DeviceMetricsInfo>; |
31 | 34 |
|
@@ -734,6 +737,42 @@ void displayDriverInfo(DriverInfo const& driverInfo, DriverControl& driverContro |
734 | 737 | if (ImGui::Button("SIGCONT all children")) { |
735 | 738 | kill(0, SIGCONT); |
736 | 739 | } |
| 740 | + ImGui::SameLine(); |
| 741 | + if (ImGui::Button("Debug driver")) { |
| 742 | + std::string pidStr = std::to_string(pid); |
| 743 | + setenv("O2DEBUGGEDPID", pidStr.c_str(), 1); |
| 744 | +#ifdef __APPLE__ |
| 745 | + std::string defaultAppleDebugCommand = |
| 746 | + "osascript -e 'tell application \"Terminal\" to activate'" |
| 747 | + " -e 'tell application \"Terminal\" to do script \"lldb -p \" & (system attribute \"O2DEBUGGEDPID\")'"; |
| 748 | + setenv("O2DPLDEBUG", defaultAppleDebugCommand.c_str(), 0); |
| 749 | +#else |
| 750 | + setenv("O2DPLDEBUG", "xterm -hold -e gdb attach $O2DEBUGGEDPID &", 0); |
| 751 | +#endif |
| 752 | + int retVal = system(getenv("O2DPLDEBUG")); |
| 753 | + (void)retVal; |
| 754 | + } |
| 755 | + |
| 756 | + ImGui::SameLine(); |
| 757 | + if (ImGui::Button("Profile")) { |
| 758 | + std::string pidStr = std::to_string(pid); |
| 759 | + setenv("O2PROFILEDPID", pidStr.c_str(), 1); |
| 760 | +#ifdef __APPLE__ |
| 761 | + auto defaultAppleProfileCommand = fmt::format( |
| 762 | + "osascript -e 'tell application \"Terminal\" to activate'" |
| 763 | + " -e 'tell application \"Terminal\" to do script \"xcrun xctrace record --output dpl-profile-{}.trace" |
| 764 | + " --time-limit 30s --template Time\\\\ Profiler --attach {} " |
| 765 | + " && open dpl-profile-{}.trace && exit\"'" |
| 766 | + " && open dpl-driver-profile-{}.trace", |
| 767 | + pid, pid, pid, pid); |
| 768 | + std::cout << defaultAppleProfileCommand << std::endl; |
| 769 | + setenv("O2DPLPROFILE", defaultAppleProfileCommand.c_str(), 0); |
| 770 | +#else |
| 771 | + setenv("O2DPLPROFILE", "xterm -hold -e perf record -a -g -p $O2PROFILEDPID > perf-$O2PROFILEDPID.data &", 0); |
| 772 | +#endif |
| 773 | + int retVal = system(getenv("O2DPLPROFILE")); |
| 774 | + (void)retVal; |
| 775 | + } |
737 | 776 |
|
738 | 777 | for (size_t i = 0; i < driverInfo.states.size(); ++i) { |
739 | 778 | ImGui::Text("#%lu: %s", i, DriverHelper::stateToString(driverInfo.states[i])); |
|
0 commit comments