llvm / llvm/llvm-project

[LLDB] eFormatBytesWithASCII output is unintuitive and confusing

Open
#170,030 1 comment 0 reactions 0 assignees View on GitHub
lldb
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Specifically the "ascii" part. I would expect the latter half to be identical to the output of `eFormatChar`, but it is not. It instead seems to follow `eFormatCharPrintable`, which has the same unintuitive behavior. There are 2 issues:

1. characters are not delimited, making the space character (0x20) "invisible"
2. non-printable characters are printed as a period, presumably due to [this](https://github.com/llvm/llvm-project/blob/22257e8d6ed5600d9c689fecbd17ea68e9d08a6f/lldb/source/Core/DumpDataExtractor.cpp#L51), which can easily be confused with an *actual* period character.

With delimiters (e.g. `eFormatChar` which prints with single quotes: `'a'`) non-printable chars could just be empty single-quotes `''`, and printable periods would no longer be ambiguous. Also, known escape sequences ([these](https://github.com/llvm/llvm-project/blob/22257e8d6ed5600d9c689fecbd17ea68e9d08a6f/lldb/source/Core/DumpDataExtractor.cpp#L173)) should be printed instead of the fallback "non-printable" value.

Contributor guide

Open the contributing guide

Research direction

Start in lldb/source/Core/DumpDataExtractor.cpp at the linked formatting logic and compare the eFormatBytesWithASCII, eFormatChar, and eFormatCharPrintable entry points. Confirm that the ASCII output uses delimiters, represents non-printable characters with empty quotes, and uses the known escape sequences instead of periods; verify the resulting formatting behavior with the relevant LLDB tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.