Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion include/Comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#ifndef COMMENT_H_
#define COMMENT_H_

#include "Types.h"
#include "Module.h"
#include "Types.h"

#include <QString>

Expand Down
2 changes: 1 addition & 1 deletion include/IBreakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#ifndef IBREAKPOINT_H_20060720_
#define IBREAKPOINT_H_20060720_

#include "Types.h"
#include "Module.h"
#include "Types.h"

#include <QString>
#include <exception>
Expand Down
8 changes: 0 additions & 8 deletions include/IDebugEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class IDebugEvent {
};

struct Message {
Message() = default;
Message(QString c, QString m, QString s)
: caption(std::move(c)), message(std::move(m)), statusMessage(std::move(s)) {
}

QString caption;
QString message;
QString statusMessage;
Expand All @@ -38,9 +33,6 @@ class IDebugEvent {
public:
virtual ~IDebugEvent() = default;

public:
[[nodiscard]] virtual IDebugEvent *clone() const = 0;

public:
[[nodiscard]] virtual Message errorDescription() const = 0;
[[nodiscard]] virtual REASON reason() const = 0;
Expand Down
1 change: 1 addition & 0 deletions include/IProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class IProcess {
public:
[[nodiscard]] virtual edb::address_t debugPointer() const { return 0; }
[[nodiscard]] virtual edb::address_t calculateMain() const { return 0; }
[[nodiscard]] virtual edb::address_t heapStart() const { return 0; }

public:
// only legal to call when attached
Expand Down
60 changes: 57 additions & 3 deletions plugins/Analyzer/Analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ bool split_function(Function &func) {
return false;
}

/**
* @brief Splits basic blocks within all functions in the given region data.
*
* This function iterates over all functions in the region data and repeatedly splits basic blocks
* that contain call instructions, ensuring that each call instruction is the last instruction in its basic block.
*
* @param data The region data containing the functions to process.
*/
void Analyzer::splitBlocks(RegionData *data) {
Q_ASSERT(data);

Expand All @@ -501,6 +509,14 @@ void Analyzer::splitBlocks(RegionData *data) {
}
}

/**
* @brief Computes which functions in the given region data are non-returning.
*
* This function iterates over all functions in the region data and checks the last instruction of each basic block.
* If all basic blocks in a function do not indicate a return (e.g., they end with halt, UD, or internal jumps), the function is marked as non-returning.
*
* @param data The region data containing the functions to analyze.
*/
void Analyzer::computeNonReturning(Analyzer::RegionData *data) {
Q_UNUSED(data);

Expand Down Expand Up @@ -558,7 +574,7 @@ void Analyzer::computeNonReturning(Analyzer::RegionData *data) {
/**
* @brief Performs recursive disassembly from all known entry points to build the complete function and basic block maps.
*
* @param data
* @param data The region data containing the known functions and basic blocks to collect.
*/
void Analyzer::collectFunctions(Analyzer::RegionData *data) {
Q_ASSERT(data);
Expand Down Expand Up @@ -710,7 +726,7 @@ void Analyzer::collectFunctions(Analyzer::RegionData *data) {
/**
* @brief Heuristically discovers additional function entry points by scanning for call targets and ENDBR instructions.
*
* @param data
* @param data The region data containing the memory and known functions to analyze for potential fuzzy function entry points.
*/
void Analyzer::collectFuzzyFunctions(RegionData *data) {
Q_ASSERT(data);
Expand Down Expand Up @@ -754,9 +770,47 @@ void Analyzer::collectFuzzyFunctions(RegionData *data) {
if (!data->knownFunctions.contains(addr)) {
fuzzy_functions[addr] = MinRefCount + 1;
}

// look for push rbp; mov ebp, esp as it is a common function prologue
} else if (inst->id == X86_INS_PUSH && inst[0]->reg == X86_REG_EBP) {

const edb::address_t next_addr = addr + inst.byteSize();
if (auto inst2 = edb::Instruction(p + inst.byteSize(), last, next_addr)) {

if (inst2->id == X86_INS_MOV) {

if (inst2.operandCount() == 2 && is_register(inst2[0]) && is_register(inst2[1])) {

if (inst2[0]->reg == X86_REG_EBP && inst2[1]->reg == X86_REG_ESP) {

if (!data->knownFunctions.contains(addr)) {
fuzzy_functions[addr] = MinRefCount + 1;
}
}
}
}
}
} else if (inst->id == X86_INS_PUSH && inst[0]->reg == X86_REG_RBP) {

const edb::address_t next_addr = addr + inst.byteSize();
if (auto inst2 = edb::Instruction(p + inst.byteSize(), last, next_addr)) {

if (inst2->id == X86_INS_MOV) {

if (inst2.operandCount() == 2 && is_register(inst2[0]) && is_register(inst2[1])) {

if (inst2[0]->reg == X86_REG_RBP && inst2[1]->reg == X86_REG_RSP) {

if (!data->knownFunctions.contains(addr)) {
fuzzy_functions[addr] = MinRefCount + 1;
}
}
}
}
}
}
#endif
#endif
}
}
++p;
}
Expand Down
49 changes: 24 additions & 25 deletions plugins/DebuggerCore/unix/freebsd/PlatformEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ PlatformEvent::PlatformEvent()
: status(0), pid(-1), tid(-1), fault_address_(0), fault_code_(0) {
}

/**
* @brief Creates a new PlatformEvent instance that is a copy of the current instance.
*
* @return A pointer to the newly created PlatformEvent instance.
*/
PlatformEvent *PlatformEvent::clone() const {
return new PlatformEvent(*this);
}

/**
* @brief Returns a user-friendly error message describing the reason for the debug event, if it is an error event.
*
Expand All @@ -53,60 +44,68 @@ IDebugEvent::Message PlatformEvent::error_description() const {

switch (code()) {
case SIGSEGV:
return Message(
return Message{
tr("Illegal Access Fault"),
tr(
"<p>The debugged application encountered a segmentation fault.<br />The address <strong>0x%1</strong> could not be accessed.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
.arg(edb::v1::format_pointer(fault_address)));
.arg(edb::v1::format_pointer(fault_address)),
};
case SIGILL:
return Message(
return Message{
tr("Illegal Instruction Fault"),
tr(
"<p>The debugged application attempted to execute an illegal instruction.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
case SIGFPE:
switch (fault_code_) {
case FPE_INTDIV:
return Message(
return Message{
tr("Divide By Zero"),
tr(
"<p>The debugged application tried to divide an integer value by an integer divisor of zero.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
default:
return Message(
return Message{
tr("Floating Point Exception"),
tr(
"<p>The debugged application encountered a floating-point exception.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
}

case SIGABRT:
return Message(
return Message{
tr("Application Aborted"),
tr(
"<p>The debugged application has aborted.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
case SIGBUS:
return Message(
return Message{
tr("Bus Error"),
tr(
"<p>The debugged application tried to read or write data that is misaligned.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
#ifdef SIGSTKFLT
case SIGSTKFLT:
return Message(
return Message{
tr("Stack Fault"),
tr(
"<p>The debugged application encountered a stack fault.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
#endif
case SIGPIPE:
return Message(
return Message{
tr("Broken Pipe Fault"),
tr(
"<p>The debugged application encountered a broken pipe fault.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"));
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>"),
};
default:
return Message();
}
Expand Down
3 changes: 0 additions & 3 deletions plugins/DebuggerCore/unix/freebsd/PlatformEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class PlatformEvent : IDebugEvent {
public:
PlatformEvent();

public:
PlatformEvent *clone() const override;

public:
Message error_description() const override;
REASON reason() const override;
Expand Down
Loading