Skip to content

Commit

Permalink
add inline coloring to every brush
Browse files Browse the repository at this point in the history
this patch shows inlined frames in a different color in every color
scheme
  • Loading branch information
lievenhey committed Dec 11, 2023
1 parent 25462f6 commit ce97bfa
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/flamegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,22 +338,27 @@ QBrush brushBinary(const Data::Symbol& symbol)
{
static QHash<QString, QBrush> brushes;

auto& brush = brushes[symbol.binary];
auto brush = brushes[symbol.binary];
if (brush == QBrush()) {
brush = brushImpl(qHash(symbol.binary), BrushType::Hot);
}
if (symbol.isInline) {
brush.setColor(brush.color().lighter(150));
}
return brush;
}

QBrush brushKernel(const Data::Symbol& symbol)
{
static auto kernel = QBrush(QColor(255, 0, 0, 125));
static auto kernelInline = QBrush(QColor(255, 100, 0, 125));
static auto user = QBrush(QColor(0, 0, 255, 125));
static auto userInline = QBrush(QColor(0, 100, 255, 125));

if (symbol.isKernel) {
return kernel;
return symbol.isInline ? kernelInline : kernel;
}
return user;
return symbol.isInline ? userInline : user;
}

bool isInPathList(const QStringList& paths, const QString& subPath)
Expand All @@ -376,16 +381,18 @@ bool isUserPath(const QString& path)
QBrush brushSystem(const Data::Symbol& symbol)
{
static const auto system = QBrush(QColor(0, 125, 0, 125));
static const auto systemInline = QBrush(QColor(0, 125, 100, 125));
static const auto user = QBrush(QColor(200, 200, 0, 125));
static const auto userInline = QBrush(QColor(200, 200, 100, 125));
static const auto unknown = QBrush(QColor(50, 50, 50, 125));

// remark lievenhey: I have seen [ only on kernel calls
if (symbol.path.isEmpty() || symbol.path.startsWith(QLatin1Char('['))) {
return unknown;
} else if (!isUserPath(symbol.path) && isSystemPath(symbol.path)) {
return system;
return symbol.isInline ? systemInline : system;
}
return user;
return symbol.isInline ? userInline : user;
}

QBrush brush(const Data::Symbol& entry, Settings::ColorScheme scheme)
Expand All @@ -398,7 +405,7 @@ QBrush brush(const Data::Symbol& entry, Settings::ColorScheme scheme)
case Settings::ColorScheme::System:
return brushSystem(entry);
case Settings::ColorScheme::Default:
return brushImpl(qHash(entry), BrushType::Hot);
return brushImpl(qHash(entry), entry.isInline ? BrushType::Memory : BrushType::Hot);
case Settings::ColorScheme::NumColorSchemes:
Q_UNREACHABLE();
}
Expand Down

0 comments on commit ce97bfa

Please sign in to comment.