-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add detection for inlined code in disassembly
this adds a dector to detect and hide inlined code in the disassembly
- Loading branch information
Showing
6 changed files
with
313 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
SPDX-FileCopyrightText: Lieven Hey <[email protected]> | ||
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected] | ||
SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#include "disassemblyentry.h" | ||
|
||
DisassemblyEntry::DisassemblyEntry(DisassemblyEntry* parent, int row, | ||
const DisassemblyOutput::DisassemblyLine& disassemblyLine, QTextLine textLine) | ||
: m_parent(parent) | ||
, m_disassemblyLine(disassemblyLine) | ||
, m_textLine(textLine) | ||
, m_row(row) | ||
{ | ||
} | ||
|
||
DisassemblyEntry* DisassemblyEntry::lastChild() | ||
{ | ||
if (m_lines.isEmpty()) { | ||
return nullptr; | ||
} | ||
|
||
return &m_lines[m_lines.size() - 1]; | ||
} | ||
|
||
void DisassemblyEntry::addChild(const DisassemblyEntry& line) | ||
{ | ||
m_lines.push_back(line); | ||
} | ||
|
||
void DisassemblyEntry::clear() | ||
{ | ||
m_lines.clear(); | ||
} | ||
|
||
DisassemblyEntry::Iterator::Iterator(const DisassemblyEntry* entry, int child) | ||
: m_entry(const_cast<DisassemblyEntry*>(entry)) | ||
, m_child(child) | ||
{ | ||
} | ||
|
||
DisassemblyEntry& DisassemblyEntry::Iterator::operator*() const | ||
{ | ||
if (m_child == -1) { | ||
return *m_entry; | ||
} | ||
return *m_entry->child(m_child); | ||
} | ||
|
||
DisassemblyEntry* DisassemblyEntry::Iterator::operator->() const | ||
{ | ||
if (m_child == -1) { | ||
return m_entry; | ||
} | ||
return m_entry->child(m_child); | ||
} | ||
|
||
DisassemblyEntry::Iterator& DisassemblyEntry::Iterator::operator++() | ||
{ | ||
if (m_child == -1) { | ||
m_entry++; | ||
if (m_entry->childCount() > 0) { | ||
m_child = 0; | ||
} else { | ||
m_child = -1; | ||
} | ||
return *this; | ||
} | ||
|
||
m_child++; | ||
|
||
if (m_child >= m_entry->childCount()) { | ||
m_entry++; | ||
if (m_entry->childCount() > 0) { | ||
m_child = 0; | ||
} else { | ||
m_child = -1; | ||
} | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
bool DisassemblyEntry::Iterator::operator==(const DisassemblyEntry::Iterator& other) const | ||
{ | ||
return this->m_entry == other.m_entry && this->m_child == other.m_child; | ||
} | ||
|
||
DisassemblyEntry::Iterator DisassemblyEntry::begin() const | ||
{ | ||
return Iterator(&m_lines[0], m_lines[0].childCount() == 0 ? -1 : 0); | ||
} | ||
|
||
DisassemblyEntry::Iterator DisassemblyEntry::end() const | ||
{ | ||
return Iterator(m_lines.end(), -1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
SPDX-FileCopyrightText: Lieven Hey <[email protected]> | ||
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected] | ||
SPDX-License-Identifier: GPL-2.0-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "disassemblyoutput.h" | ||
#include <iterator> | ||
#include <QTextLine> | ||
#include <QVector> | ||
|
||
class DisassemblyEntry | ||
{ | ||
public: | ||
DisassemblyEntry(DisassemblyEntry* parent, int row, const DisassemblyOutput::DisassemblyLine& disassemblyLine = {}, | ||
QTextLine textLine = {}); | ||
|
||
~DisassemblyEntry() = default; | ||
|
||
DisassemblyEntry* parent() const | ||
{ | ||
return m_parent; | ||
} | ||
|
||
int row() const | ||
{ | ||
return m_row; | ||
} | ||
|
||
DisassemblyEntry* child(int row) | ||
{ | ||
return &m_lines[row]; | ||
} | ||
|
||
DisassemblyEntry* lastChild(); | ||
|
||
DisassemblyOutput::DisassemblyLine disassemblyLine() const | ||
{ | ||
return m_disassemblyLine; | ||
} | ||
|
||
QTextLine textLine() const | ||
{ | ||
return m_textLine; | ||
} | ||
|
||
int childCount() const | ||
{ | ||
return m_lines.size(); | ||
} | ||
|
||
void clear(); | ||
void addChild(const DisassemblyEntry& line); | ||
|
||
class Iterator : public std::iterator<std::forward_iterator_tag, DisassemblyEntry> | ||
{ | ||
public: | ||
Iterator(const DisassemblyEntry* entry, int child); | ||
DisassemblyEntry& operator*() const; | ||
DisassemblyEntry* operator->() const; | ||
|
||
Iterator& operator++(); | ||
Iterator operator++(int) | ||
{ | ||
Iterator tmp = *this; | ||
++(*this); | ||
return tmp; | ||
} | ||
|
||
bool operator==(const Iterator& other) const; | ||
bool operator!=(const Iterator& other) const | ||
{ | ||
return !(*this == other); | ||
} | ||
|
||
private: | ||
DisassemblyEntry* m_entry = nullptr; | ||
int m_child = -1; | ||
}; | ||
|
||
Iterator begin() const; | ||
Iterator end() const; | ||
|
||
private: | ||
DisassemblyEntry* m_parent; | ||
QVector<DisassemblyEntry> m_lines; | ||
DisassemblyOutput::DisassemblyLine m_disassemblyLine; | ||
QTextLine m_textLine; | ||
int m_row; | ||
}; |
Oops, something went wrong.