}
/// Render a snippet of the address space near a location.
-static void renderMemorySnippet(MemoryLocation Loc,
+static void renderMemorySnippet(bool UseAnsiColor, MemoryLocation Loc,
Range *Ranges, unsigned NumRanges,
const Diag::Arg *Args) {
const unsigned BytesToShow = 32;
RawWrite("\n");
// Emit highlights.
+ if (UseAnsiColor)
+ RawWrite("\033[1;32m");
Range *InRange = upperBound(Min, Ranges, NumRanges);
for (uptr P = Min; P != Max; ++P) {
char Pad = ' ', Byte = ' ';
char Buffer[] = { Pad, Pad, P == Loc ? '^' : Byte, Byte, 0 };
RawWrite((P % 8 == 0) ? Buffer : &Buffer[1]);
}
+ if (UseAnsiColor)
+ RawWrite("\033[0m");
RawWrite("\n");
// Go over the line again, and print names for the ranges.
RawWrite("\n");
if (Loc.isMemoryLocation())
- renderMemorySnippet(Loc.getMemoryLocation(), Ranges, NumRanges, Args);
+ renderMemorySnippet(UseAnsiColor, Loc.getMemoryLocation(), Ranges,
+ NumRanges, Args);
}