Skip to content

Commit 107c739

Browse files
Copilotxusheng6
andcommitted
Improve stack widget with better hint generation and column sizing
Co-authored-by: xusheng6 <[email protected]>
1 parent f1a2854 commit 107c739

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

ui/stackwidget.cpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ DebugStackWidget::DebugStackWidget(const QString& name, ViewFrame* view, BinaryV
400400
m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
401401
m_table->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
402402

403+
// Set column resize modes for better display of the improved hints
404+
m_table->horizontalHeader()->setSectionResizeMode(DebugStackListModel::OffsetColumn, QHeaderView::ResizeToContents);
405+
m_table->horizontalHeader()->setSectionResizeMode(DebugStackListModel::AddressColumn, QHeaderView::ResizeToContents);
406+
m_table->horizontalHeader()->setSectionResizeMode(DebugStackListModel::ValueColumn, QHeaderView::ResizeToContents);
407+
m_table->horizontalHeader()->setSectionResizeMode(DebugStackListModel::HintColumn, QHeaderView::Stretch);
408+
403409
m_table->resizeColumnsToContents();
404410
m_table->resizeRowsToContents();
405411

@@ -416,8 +422,7 @@ DebugStackWidget::DebugStackWidget(const QString& name, ViewFrame* view, BinaryV
416422
void DebugStackWidget::notifyStackChanged(std::vector<DebugStackItem> stackItems)
417423
{
418424
m_model->updateRows(stackItems);
419-
// TODO: we could also set the columns' ResizeMode to ResizeToContents
420-
m_table->resizeColumnsToContents();
425+
// Column resize modes are now properly configured in constructor
421426
}
422427

423428

@@ -479,32 +484,9 @@ void DebugStackWidget::updateContent()
479484
std::string hint {};
480485
if (m_controller)
481486
{
482-
const DataBuffer memory = m_controller->ReadMemory(value, 128);
483-
std::string reg_string;
484-
if (memory.GetLength() > 0)
485-
reg_string = std::string((const char*)memory.GetData(), memory.GetLength());
486-
else
487-
reg_string = "x";
488-
const auto can_print = std::all_of(reg_string.begin(), reg_string.end(), [](unsigned char c) {
489-
return c == '\n' || std::isprint(c);
490-
});
491-
492-
if (!reg_string.empty() && reg_string.size() > 3 && can_print)
493-
{
494-
hint = fmt::format("\"{}\"", reg_string);
495-
}
496-
else
497-
{
498-
DataBuffer buffer = m_controller->ReadMemory(value, addressSize);
499-
if (buffer.GetLength() > 0)
500-
{
501-
hint = fmt::format("{:x}", *reinterpret_cast<std::uintptr_t*>(buffer.GetData()));
502-
}
503-
else
504-
{
505-
hint = "";
506-
}
507-
}
487+
// Use the existing GetAddressInformation API for better hint generation
488+
// This provides comprehensive symbol resolution, function names, strings, etc.
489+
hint = m_controller->GetAddressInformation(value);
508490
}
509491

510492
stackItems.emplace_back(offset, address, value, hint);

0 commit comments

Comments
 (0)