Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2aedf373 authored by Nicolas Roulet's avatar Nicolas Roulet
Browse files

NBLog: add buffer hex dump

Bug: 36724290
Test: create and print entries, check dump matches expected content
Change-Id: I71c4df287535b460838afc2d3ce651744850bf49
parent 537ad7da
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -1018,6 +1018,23 @@ void NBLog::appendPID(String8 *body, const void* data, size_t length) {
    body->appendFormat("<PID: %d, name: %.*s>", id, (int) (length - sizeof(pid_t)), name);
}

String8 NBLog::bufferHexDump(const uint8_t *buffer, size_t size)
{
    String8 str;
    str.append("[ ");
    for(size_t i = 0; i < size; i++)
    {
        str.appendFormat("%02x ", buffer[i]);
    }
    str.append("]");
    return str;
}

String8 NBLog::bufferHexDump(const EntryIterator &it)
{
    return bufferHexDump(it, it->length + Entry::kOverhead);
}

NBLog::EntryIterator NBLog::Reader::handleFormat(const FormatEntry &fmtEntry,
                                                         String8 *timestamp,
                                                         String8 *body) {
+2 −1
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ struct HistIntEntry {
    static void    appendPID(String8 *body, const void *data, size_t length);
    static void    appendTimestamp(String8 *body, const void *data);
    static size_t  fmtEntryLength(const uint8_t *data);

    static String8 bufferHexDump(const uint8_t *buffer, size_t size);
    static String8 bufferHexDump(const EntryIterator &it);
public:

// Located in shared memory, must be POD.