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
38 changes: 26 additions & 12 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- dev
- stable

env:
LLVM_VERSION: 20
USE_APT_LLVM_ORG: false

jobs:
changes:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -38,23 +42,32 @@ jobs:
uses: actions/checkout@v7

- name: Install wget, software-properties-common, lsb-release (dependencies of LLVM install script)
if: ${{ env.USE_APT_LLVM_ORG == 'true' }}
run: sudo apt --assume-yes install wget software-properties-common lsb-release

- name: Uninstall old conflicting packages
run: sudo apt purge --assume-yes --auto-remove llvm python3-lldb-14 llvm-14
if: ${{ env.USE_APT_LLVM_ORG == 'true' }}
run: |
pkgs=$(dpkg-query -W -f='${db:Status-Abbrev} ${Package}\n' 'llvm' 'llvm-[0-9]*' 'python3-lldb-[0-9]*' 2>/dev/null \
| awk '$1 == "ii" {print $2}' | grep -v -- "-${LLVM_VERSION}$" || true)
if [ -n "$pkgs" ]; then
sudo apt-get purge --assume-yes --auto-remove $pkgs
fi

- name: Install automatic LLVM 20
run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh 20
- name: Install automatic LLVM ${{ env.LLVM_VERSION }}
if: ${{ env.USE_APT_LLVM_ORG == 'true' }}
run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh "$LLVM_VERSION"

- name: Install clang-format-20
run: sudo apt --assume-yes install clang-format-20
- name: Install clang-format-${{ env.LLVM_VERSION }}
run: |
sudo apt-get install --assume-yes "clang-format-$LLVM_VERSION"

- name: Install gitpython
run: sudo pip install gitpython

- name: Run clang-format
run: |
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 200
sudo update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-$LLVM_VERSION" 200
clang-format --version
python scripts/clang-format.py --check --verbose

Expand All @@ -78,12 +91,13 @@ jobs:
libqt6svgwidgets6 qt6-l10n-tools \
libgl1-mesa-dev libglu1-mesa-dev

- name: Install automatic LLVM 20
run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh 20
- name: Install automatic LLVM ${{ env.LLVM_VERSION }}
if: ${{ env.USE_APT_LLVM_ORG == 'true' }}
run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh "$LLVM_VERSION"

- name: Install clang-tidy-20
- name: Install clang-tidy-${{ env.LLVM_VERSION }}
run: |
sudo apt --assume-yes install clang-tidy-20
sudo apt-get install --assume-yes "clang-tidy-$LLVM_VERSION"

- name: CMake Configuration
run: |
Expand All @@ -99,7 +113,7 @@ jobs:

- name: Run Clang-Tidy
run: |
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200
sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-20 200
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy "/usr/bin/clang-tidy-$LLVM_VERSION" 200
sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy "/usr/bin/run-clang-tidy-$LLVM_VERSION" 200
clang-tidy -version
python3 scripts/clang-tidy.py
2 changes: 1 addition & 1 deletion dist/bundle_rz_frida.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (-not $dist) {
$FRIDA_VERSION = "17.17.0"

if (-not (Test-Path -Path 'rz-frida\meson.build' -PathType Leaf)) {
git clone https://github.com/rizinorg/rz-frida.git --depth 1 rz-frida
git clone https://github.com/rizinorg/rz-frida.git --depth 1 --branch "dev" rz-frida
Comment thread
wargio marked this conversation as resolved.
Resolved
}
cd rz-frida
if (-not (Test-Path -Path 'frida-core-devkit\frida-core.h' -PathType Leaf)) {
Expand Down
2 changes: 1 addition & 1 deletion rizin
Submodule rizin updated 724 files
2 changes: 1 addition & 1 deletion scripts/rz-frida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ver_newer() {
cd "$SCRIPTPATH/.."

if [[ ! -f rz-frida/meson.build ]]; then
git clone https://github.com/rizinorg/rz-frida.git --depth 1 rz-frida
git clone https://github.com/rizinorg/rz-frida.git --depth 1 --branch "dev" rz-frida
fi

cd rz-frida
Expand Down
4 changes: 3 additions & 1 deletion src/common/AnalysisTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ AnalysisTask::~AnalysisTask() {}
void AnalysisTask::interrupt()
{
AsyncTask::interrupt();
rz_cons_singleton()->context->breaked = true;

// assume caller holds the lock already so it should be safe to use raw rzCore here
rz_interrupt_set_breaked(Core()->rzCore->intr, true);
}

QString AnalysisTask::getTitle() const
Expand Down
3 changes: 2 additions & 1 deletion src/common/RunScriptTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ RunScriptTask::~RunScriptTask() {}
void RunScriptTask::interrupt()
{
AsyncTask::interrupt();
rz_cons_singleton()->context->breaked = true;
// assume caller holds the lock already so it should be safe to use raw rzCore here
rz_interrupt_set_breaked(Core()->rzCore->intr, true);
}

void RunScriptTask::runTask()
Expand Down
75 changes: 41 additions & 34 deletions src/core/Cutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ RzCoreLocked::RzCoreLocked(CutterCore *core) : core(core)
core->coreLockDepth++;
if (core->coreLockDepth == 1) {
assert(core->coreBed);
rz_cons_sleep_end(core->coreBed);
rz_interrupt_sleep_end(core->rzCore->intr, core->coreBed);
core->coreBed = nullptr;
}
}
Expand All @@ -151,7 +151,7 @@ RzCoreLocked::~RzCoreLocked()
assert(core->coreLockDepth > 0);
core->coreLockDepth--;
if (core->coreLockDepth == 0) {
core->coreBed = rz_cons_sleep_begin();
core->coreBed = rz_interrupt_sleep_begin(core->rzCore->intr);
}
core->coreMutex.unlock();
}
Expand Down Expand Up @@ -194,7 +194,6 @@ CutterCore *CutterCore::instance()

void CutterCore::initialize(bool loadPlugins)
{
rz_cons_new(); // initialize console
rzCore = rz_core_new();

#if defined(MACOS_RZ_BUNDLED)
Expand All @@ -209,7 +208,7 @@ void CutterCore::initialize(bool loadPlugins)
char **env = rz_sys_get_environ();
rzCore->io->envprofile = rz_run_get_environ_profile(env);
rz_core_task_sync_begin(&rzCore->tasks);
coreBed = rz_cons_sleep_begin();
coreBed = rz_interrupt_sleep_begin(rzCore->intr);
CORE_LOCK();

rz_event_hook(rzCore->ev, RZ_EVENT_ALL, cutterREventCallback, this);
Expand Down Expand Up @@ -240,10 +239,9 @@ void CutterCore::initialize(bool loadPlugins)
CutterCore::~CutterCore()
{
delete bbHighlighter;
rz_cons_sleep_end(coreBed);
rz_interrupt_sleep_end(rzCore->intr, coreBed);
rz_core_task_sync_end(&rzCore->tasks);
rz_core_free(this->rzCore);
rz_cons_free();
assert(uniqueInstance == this);
uniqueInstance = nullptr;
}
Expand Down Expand Up @@ -288,7 +286,7 @@ void CutterCore::loadCutterRC()
}
qInfo() << tr("Loading initialization file from ") << cutterRCFilePath;
rz_core_cmd_file(core, cutterRCFilePath.toUtf8().constData());
rz_cons_flush();
rz_cons_flush(core->cons);
}
}

Expand All @@ -302,7 +300,7 @@ void CutterCore::loadDefaultCutterRC()
}
qInfo() << tr("Loading initialization file from ") << cutterRCFilePath;
rz_core_cmd_file(core, cutterRCFilePath.toUtf8().constData());
rz_cons_flush();
rz_cons_flush(core->cons);
}

QList<QString> CutterCore::sdbList(const QString &path)
Expand Down Expand Up @@ -392,22 +390,22 @@ QString CutterCore::getFunctionExecOut(const std::function<bool(RzCore *)> &fcn,
const RVA offset = core->offset;
seekSilent(addr);
QString o = {};
rz_cons_push();
rz_cons_push(core->cons);
const bool isPipe = core->is_pipe;
core->is_pipe = true;

if (!fcn(core)) {
core->is_pipe = isPipe;
rz_cons_pop();
rz_cons_pop(core->cons);
goto clean_return;
}

core->is_pipe = isPipe;
rz_cons_filter();
o = rz_cons_get_buffer();
rz_cons_filter(core->cons);
o = rz_cons_get_buffer(core->cons);

rz_cons_pop();
rz_cons_echo(nullptr);
rz_cons_pop(core->cons);
rz_cons_echo(core->cons, nullptr);

clean_return:
if (offset != core->offset) {
Expand Down Expand Up @@ -645,7 +643,7 @@ bool CutterCore::loadFile(const QString &path, ut64 baddr, ut64 mapaddr, int per
}
}

rz_cons_flush();
rz_cons_flush(core->cons);
fflush(stdout);
return true;
}
Expand All @@ -658,7 +656,7 @@ bool CutterCore::tryFile(const QString &path, bool rw)
}
CORE_LOCK();
// clear info from previous fails
rz_cons_break_clear();
rz_interrupt_break_clear(core->intr);
RzCoreFile *cf;
int flags = RZ_PERM_R;
if (rw) {
Expand Down Expand Up @@ -746,9 +744,10 @@ CutterRzIter<RzCoreDecodedBytes> CutterCore::getRzCoreDecodedBytesSingle(RVA add
rz_io_read_at_mapped(core->io, addr, buf, sizeof(buf));

// Warning! only safe to use with stack buffer, due to instruction count being 1
auto result = CutterRzIter<RzCoreDecodedBytes>(
rz_core_analysis_bytes(core, addr, buf, sizeof(buf), 1));
return result;
RzIterator it = {};
rz_core_analysis_bytes(core, addr, buf, sizeof(buf), 1, &it);

return CutterRzIter<RzCoreDecodedBytes>(it);
}

QString CutterCore::getInstructionBytes(RVA addr)
Expand Down Expand Up @@ -1294,8 +1293,11 @@ QSet<QString> CutterCore::getConfigOptions(const char *k)
if (!(node && node->options)) {
return {};
}
RzIterator rzIt = {};
rz_set_s_as_iter(node->options, &rzIt);

QSet<QString> res;
for (auto it = CutterRzIter<const char *>(rz_set_s_as_iter(node->options)); it; ++it) {
for (auto it = CutterRzIter<const char *>(rzIt); it; ++it) {
res << QString::fromUtf8(*it);
}
return res;
Expand Down Expand Up @@ -2506,12 +2508,13 @@ void CutterCore::continueUntilSyscall()
} else {
if (!asyncTask(
[](RzCore *core) {
rz_cons_break_push(
rz_interrupt_break_push(
core->intr,
[](void *x) { rz_debug_stop(reinterpret_cast<RzDebug *>(x)); },
core->dbg);
rz_reg_arena_swap(core->dbg->reg, true);
rz_debug_continue_syscalls(core->dbg, nullptr, 0);
rz_cons_break_pop();
rz_interrupt_break_pop(core->intr);
rz_core_dbg_follow_seek_register(core);
return nullptr;
},
Expand Down Expand Up @@ -4420,12 +4423,12 @@ class CutterSearchLock
public:
CutterSearchLock(RzCore *core) : core(core)
{
rz_cons_break_push(nullptr, nullptr);
rz_interrupt_break_push(core->intr, nullptr, nullptr);
core->in_search = true;
}
~CutterSearchLock()
{
rz_cons_break_pop();
rz_interrupt_break_pop(core->intr);
core->in_search = false;
}

Expand Down Expand Up @@ -5059,9 +5062,9 @@ QList<DisassemblyLine> CutterCore::disassembleLines(RVA offset, int lines)
options.vec = vec.get();
{
auto restoreSeek = seekTemp(offset);
if (rz_cons_singleton()->is_html) {
rz_cons_singleton()->is_html = false;
rz_cons_singleton()->was_html = true;
if (core->cons->is_html) {
core->cons->is_html = false;
core->cons->was_html = true;
}
rz_core_print_disasm(core, offset, core->block, core->blocksize, lines, nullptr, &options);
}
Expand Down Expand Up @@ -5140,7 +5143,7 @@ void CutterCore::loadScript(const QString &scriptname)
{
CORE_LOCK();
rz_core_cmd_file(core, scriptname.toUtf8().constData());
rz_cons_flush();
rz_cons_flush(core->cons);
}
triggerRefreshAll();
}
Expand Down Expand Up @@ -5213,23 +5216,25 @@ QStringList CutterCore::getColorThemes()

QHash<QString, QColor> CutterCore::getTheme()
{
CORE_LOCK();
QHash<QString, QColor> theme;
for (int i = 0;; ++i) {
const char *k = rz_cons_pal_get_name(i);
const char *k = rz_cons_pal_get_name(core->cons, i);
if (!k) {
break;
}
const RzColor color = rz_cons_pal_get_i(i);
const RzColor color = rz_cons_pal_get_i(core->cons, i);
theme.insert(k, QColor(color.r, color.g, color.b));
}
return theme;
}

QStringList CutterCore::getThemeKeys()
{
CORE_LOCK();
QStringList stringList;
for (int i = 0;; ++i) {
const char *k = rz_cons_pal_get_name(i);
const char *k = rz_cons_pal_get_name(core->cons, i);
if (!k) {
break;
}
Expand All @@ -5240,10 +5245,11 @@ QStringList CutterCore::getThemeKeys()

bool CutterCore::setColor(const QString &key, const QString &color)
{
if (!rz_cons_pal_set(key.toUtf8().constData(), color.toUtf8().constData())) {
CORE_LOCK();
if (!rz_cons_pal_set(core->cons, key.toUtf8().constData(), color.toUtf8().constData())) {
return false;
}
rz_cons_pal_update_event();
rz_cons_pal_update_event(core->cons);
return true;
}

Expand All @@ -5255,10 +5261,11 @@ QString CutterCore::getColorNameFromOp(ut32 opType)

QString CutterCore::ansiEscapeToHtml(const QString &text)
{
CORE_LOCK();
int len;
QString r = text;
r.replace("\t", " ");
char *html = rz_cons_html_filter(r.toUtf8().constData(), &len);
char *html = rz_cons_html_filter(core->cons, r.toUtf8().constData(), &len);
if (!html) {
return {};
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/Cutter.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ class CUTTER_EXPORT CutterCore : public QObject
Q_OBJECT

friend class RzCoreLocked;
friend class RizinTask;
friend class Basefind;
friend class RizinTask;
friend class AnalysisTask;
friend class RunScriptTask;

public:
explicit CutterCore(QObject *parent = nullptr);
Expand Down Expand Up @@ -927,7 +929,7 @@ class CUTTER_EXPORT CutterCore : public QObject
CUTTER_DEPRECATED("Use CutterCore::lock instead")
RzCoreLocked core();

static QString ansiEscapeToHtml(const QString &text);
QString ansiEscapeToHtml(const QString &text);
BasicBlockHighlighter *getBBHighlighter();
BasicInstructionHighlighter *getBIHighlighter();

Expand Down
Loading
Loading