a bit more logging

This commit is contained in:
T0b1
2023-06-29 02:29:28 +02:00
parent 6f0b3b9e99
commit d4e4fc8c5a
3 changed files with 67 additions and 10 deletions

View File

@@ -4,6 +4,8 @@
#include "imgui.h"
#include "imgui_internal.h"
#include <spdlog/spdlog.h>
using namespace dbgui;
using namespace dbgui::frontend;
@@ -336,7 +338,7 @@ void Frontend::handle_msgs()
}
auto *msg = opt->get();
printf("Got msg %u\n", msg->type);
spdlog::debug("Got msg {}", msg->type);
switch (msg->type)
{
@@ -380,7 +382,7 @@ void Frontend::handle_msgs()
for (size_t i = 0; i < result.nodes.size(); ++i)
{
uint16_t idx = result.nodes[i].idx;
printf("Got data result for %u\n", idx);
spdlog::trace("Got data result for {}", idx);
if (this->target->data_res_nodes.size() <= idx)
{
this->target->data_res_nodes.resize(idx + 1);
@@ -448,7 +450,8 @@ void Frontend::handle_state_change(const BackToFront::StateChange &info)
this->target->state = info.new_state;
// TODO: display in status bar
printf("State changed to %u because %u\n", info.new_state, info.reason);
spdlog::debug("State changed to '{}' because '{}'", info.new_state,
info.reason);
}
void Frontend::handle_proc_info(BackToFront::InitialProcessInfo &&info)
@@ -457,18 +460,18 @@ void Frontend::handle_proc_info(BackToFront::InitialProcessInfo &&info)
this->target->id = info.pid;
auto &sets = this->target->reg_sets;
printf("RegSet Size: %lu\n", info.reg_sets.size());
spdlog::trace("RegSet Size: {}", info.reg_sets.size());
for (size_t set_idx = 0; set_idx < info.reg_sets.size(); ++set_idx)
{
sets.emplace_back();
auto &set = sets.back();
printf("Got set %s\n", info.reg_sets[set_idx].name.c_str());
spdlog::trace("Got set {}", info.reg_sets[set_idx].name.c_str());
set.name = std::move(info.reg_sets[set_idx].name);
for (size_t i = 0; i < info.reg_sets[set_idx].reg_names.size(); ++i)
{
set.regs.emplace_back();
printf(" Got reg %s\n", info.reg_sets[set_idx].reg_names[i].c_str());
spdlog::trace(" Got reg {}", info.reg_sets[set_idx].reg_names[i].c_str());
set.regs.back().name = std::move(info.reg_sets[set_idx].reg_names[i]);
}
}
@@ -562,8 +565,8 @@ void Frontend::handle_frame_change(BackToFront::FrameChanged &&info)
auto &frame = frames[info.idx];
if (!frame)
{
printf("Adding new frame at %u with name '%s'\n", info.idx,
info.display_name.c_str());
spdlog::trace("Adding new frame at {} with name '{}'", info.idx,
info.display_name.c_str());
frame = Target::Frame{
.ip = info.ip,
.display_name = info.display_name,
@@ -571,8 +574,8 @@ void Frontend::handle_frame_change(BackToFront::FrameChanged &&info)
return;
}
printf("Updating frame at %u with name '%s'\n", info.idx,
info.display_name.c_str());
spdlog::trace("Updating frame at {} with name '{}'", info.idx,
info.display_name.c_str());
frame->ip = info.ip;
frame->display_name = info.display_name;
}

View File

@@ -26,6 +26,7 @@ static void glfw_error_callback(int error, const char *description)
// Main code
int main(int, char **)
{
spdlog::set_level(spdlog::level::trace);
spdlog::cfg::load_env_levels();
pthread_setname_np(pthread_self(), "render_thread");

View File

@@ -6,6 +6,9 @@
#include <vector>
#include <optional>
#include <spdlog/spdlog.h>
#include <spdlog/fmt/ostr.h>
#include "data.h"
namespace dbgui
@@ -181,5 +184,55 @@ namespace dbgui
TypeInfo>
data;
};
inline std::ostream &operator<<(std::ostream &os, const MsgType &type)
{
switch (type)
{
using enum MsgType;
case state_change: os << "StateChange"; break;
case ip_change: os << "IPChange"; break;
case initial_proc_info: os << "InitProcInfo"; break;
case regs_changed: os << "RegsChanged"; break;
case thread_changed: os << "ThreadChanged"; break;
case thread_removed: os << "ThreadRemoved"; break;
case frame_changed: os << "FrameChanged"; break;
case frame_removed: os << "FrameRemoved"; break;
case data_result: os << "DataResult"; break;
case remove_data_node: os << "RemoveDataNode"; break;
case selected_frame_changed: os << "SelectedFrameChanged"; break;
case selected_thread_changed: os << "SelectedThreadChanged"; break;
case remove_src_id_mapping: os << "RemoveSrcIDMapping"; break;
case type_info: os << "TypeInfo"; break;
}
return os;
}
} // namespace BackToFront
inline std::ostream &operator<<(std::ostream &os, const TargetState &type)
{
switch (type)
{
using enum TargetState;
case startup: os << "startup"; break;
case stopped: os << "stopped"; break;
case running: os << "running"; break;
case paused: os << "paused"; break;
}
return os;
}
inline std::ostream &operator<<(std::ostream &os,
const StateChangeReason &type)
{
switch (type)
{
using enum StateChangeReason;
case unknown: os << "unknown"; break;
case initial_entry: os << "initial"; break;
case breakpoint: os << "breakpoint"; break;
case exception: os << "exception"; break;
}
return os;
}
} // namespace dbgui