Skip to content

Display placement information in variable list #7019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ui/variablelist.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <clickablelabel.h>
#include <QtCore/QSortFilterProxyModel>
#include <QtCore/QTimer>
#include <QtWidgets/QListView>
Expand Down Expand Up @@ -44,14 +45,15 @@ class VariableListItem
BinaryNinja::DataVariable m_dataVar;
BinaryNinja::PossibleValueSet m_pvs;
bool m_hasUidf;
bool m_showPlacementInformation;

public:
//! Create a new VariableListItem of the LocalVariable type.
VariableListItem(
FunctionRef func, BinaryNinja::Variable var, BinaryNinja::PossibleValueSet pvs, bool hasUidf, std::string name);
FunctionRef func, BinaryNinja::Variable var, BinaryNinja::PossibleValueSet pvs, bool hasUidf, std::string name, bool showPlacementInformation);

//! Create a new VariableListItem of the DataVariable type.
VariableListItem(FunctionRef func, BinaryNinja::DataVariable dataVar, uint64_t refPoint, std::string name);
VariableListItem(FunctionRef func, BinaryNinja::DataVariable dataVar, uint64_t refPoint, std::string name, bool showPlacementInformation);

//! Get the type of this list item.
VariableListItemType type() const;
Expand All @@ -70,6 +72,7 @@ class VariableListItem

std::vector<BinaryNinja::InstructionTextToken> tokensBeforeName() const;
std::vector<BinaryNinja::InstructionTextToken> tokensAfterName() const;
void displayVariablePlacementInfo(std::vector<BinaryNinja::InstructionTextToken>& tokens) const;

//! Shorthand to get concatenated type, name, and value tokens.
std::vector<BinaryNinja::InstructionTextToken> displayTokens() const;
Expand Down Expand Up @@ -111,6 +114,7 @@ class BINARYNINJAUIAPI VariableListModel : public QAbstractListModel

size_t m_prevVariableCount;
uint64_t m_prevSelectionId;
bool m_showPlacementInformation;

public:
VariableListModel(QWidget* parent, ViewFrame* view, BinaryViewRef data);
Expand All @@ -127,6 +131,9 @@ class BINARYNINJAUIAPI VariableListModel : public QAbstractListModel
//! Whether or not the function exceeds the set complexity threshold
bool functionExceedsComplexity() const { return m_funcExceedsComplexity; }

//! Get the showPlacementInformation setting
bool showPlacementInformation() const { return m_showPlacementInformation; }

//! Set the focused function and update the content of the list.
void setFunction(FunctionRef func, const BinaryNinja::FunctionViewType& il, const HighlightTokenState& hts);

Expand Down Expand Up @@ -180,6 +187,9 @@ class BINARYNINJAUIAPI VariableList : public SidebarWidget, public FilterTarget
FilterEdit* m_filterEdit;
FilteredView* m_filteredList;

ClickableIcon* m_hamburgerButton;
QMenu* m_hamburgerMenu;

ViewFrame* m_view;
BinaryViewRef m_data;

Expand All @@ -206,6 +216,7 @@ class BINARYNINJAUIAPI VariableList : public SidebarWidget, public FilterTarget

//! Get the VariableListItem corresponding to the current selection.
VariableListItem* selectedItem() const;
void showHamburgerMenu() const;

//! Show the rename dialog for the selected variable.
void changeSelectedVariableName();
Expand Down