Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
symbolize.cpp File Reference

sonde symbolize (design 0016). More...

#include "symbolize.h"
#include "commands.h"
#include "common.h"
#include "stackcapture_p.h"
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QJsonDocument>
#include <QtCore/QProcess>
#include <QtCore/QRegularExpression>
#include <QtCore/QStandardPaths>
#include <QtCore/QSysInfo>
#include <QtCore/QtEndian>
#include <cstring>
#include <functional>
#include <optional>

Classes

struct  Sonde::Cli::anonymous_namespace{symbolize.cpp}::Named
 A frame's name, and its source file and line, as a tool printed them. More...
struct  Sonde::Cli::anonymous_namespace{symbolize.cpp}::Spot
 Where an unnamed frame is in a stall's samples. More...

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

QByteArray Sonde::Cli::anonymous_namespace{symbolize.cpp}::readAt (QFile &file, qint64 offset, qint64 size)
 size bytes of file at offset; shorter at the end of the file.
template<typename T>
T Sonde::Cli::anonymous_namespace{symbolize.cpp}::le (const QByteArray &data, qsizetype at)
 An unsigned little-endian integer of N bytes at at in data, or 0.
quint32 Sonde::Cli::anonymous_namespace{symbolize.cpp}::be32 (const QByteArray &data, qsizetype at)
 A big-endian 32-bit integer at at in data, or 0.
BinaryFacts Sonde::Cli::anonymous_namespace{symbolize.cpp}::elfFacts (QFile &file)
 The facts of a 64-bit little-endian ELF file.
QString Sonde::Cli::anonymous_namespace{symbolize.cpp}::machUuid (QFile &file, qint64 offset)
 The UUID of the Mach-O image at offset in file (a thin image, or a slice).
BinaryFacts Sonde::Cli::anonymous_namespace{symbolize.cpp}::machFacts (QFile &file)
 The facts of a Mach-O file, thin or universal (the slice of this machine).
std::optional< QString > Sonde::Cli::anonymous_namespace{symbolize.cpp}::runTool (const QString &program, const QStringList &args)
 Runs program with args, returning its standard output, or nothing.
Named Sonde::Cli::anonymous_namespace{symbolize.cpp}::withFileLine (Named named, QString location)
 "file:line", or "file:line:column", with an optional " (discriminator N)".
std::optional< QList< Named > > Sonde::Cli::anonymous_namespace{symbolize.cpp}::nameInElf (const QString &path, const QStringList &addresses)
 Names addresses (the file's own addresses, as hex) in the ELF file path, with addr2line, or llvm-symbolizer if there is no addr2line.
std::optional< QList< Named > > Sonde::Cli::anonymous_namespace{symbolize.cpp}::nameInMachO (const QString &path, const QString &base, const QStringList &addresses)
 Names addresses (as loaded at base, as hex) in the Mach-O file path, with atos.
BinaryFacts Sonde::Cli::binaryFacts (const QString &path)
 Reads the facts of the binary at path.
QList< std::pair< QString, QJsonObject > > Sonde::Cli::findStalls (const QJsonValue &json)
 The stalls in json: every object with "samples" and "modules" arrays, however deep, with a title for each (from the event around it, if any).
std::pair< QList< Spot >, QStringList > Sonde::Cli::anonymous_namespace{symbolize.cpp}::unnamedFrames (const QJsonArray &samples, int module, quint64 base, const BinaryFacts &facts, bool elf)
 The unnamed frames of samples in module module, and the address to look up for each (a return address points after its call: the byte before it is looked up), as the naming tool wants it: the file's own address on Linux, the loaded one (base) on macOS.
void Sonde::Cli::anonymous_namespace{symbolize.cpp}::applyNames (QJsonArray &samples, const QList< Spot > &spots, const QList< Named > &named)
 Puts the names in named into the frames of samples at spots.
QString Sonde::Cli::anonymous_namespace{symbolize.cpp}::whyNotNamed (const QJsonObject &module, const BinaryFacts &facts, QStringList &notes)
 Why the frames of module can't be named from facts, or an empty string.
QJsonObject Sonde::Cli::nameFrames (QJsonObject stall, QStringList &notes)
 Names the unnamed frames of stall ("samples" and "modules") with the platform's tools, after checking each module's build ID against its file.
void Sonde::Cli::symbolizeCommand (const Options &options, const QStringList &args)
 sonde symbolize [FILE] [--json]: the stalls in FILE ('-' for standard input), or the application's current and recent stalls, with their frames named.

Detailed Description

sonde symbolize (design 0016).

Function Documentation

◆ nameFrames()

QJsonObject Sonde::Cli::nameFrames ( QJsonObject stall,
QStringList & notes )

Names the unnamed frames of stall ("samples" and "modules") with the platform's tools, after checking each module's build ID against its file.

Adds a line to notes for each module it couldn't check or name.