diff options
author | Nathan Lanza <nathan@lanza.io> | 2018-11-05 22:55:30 +0000 |
---|---|---|
committer | Nathan Lanza <nathan@lanza.io> | 2018-11-05 22:55:30 +0000 |
commit | 8b73fa61d17cd2bf8104e1488edb213f00306238 (patch) | |
tree | 66881e45ac964e4317e672d719ffa504ddf0b490 | |
parent | 08c41659ef78a25573fde7728fc2d8dbb9cda5da (diff) | |
download | bcm5719-llvm-8b73fa61d17cd2bf8104e1488edb213f00306238.tar.gz bcm5719-llvm-8b73fa61d17cd2bf8104e1488edb213f00306238.zip |
Adjust the comment section of CreateSource to account for lines longer than 60
Summary:
On rare occasions, the address, instruction and arguments of a line of
assembly in the CreateSource printout would reach > 60 characters. The
function would integer overflow and try to indent a line by `0xfff...`.
Change the calculated offset to be the maximum of 60 or
`line_strm.str().size()`
Reviewers: clayborg, xiaobai
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D52745
llvm-svn: 346179
-rw-r--r-- | lldb/tools/lldb-vscode/JSONUtils.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp index 097e2adbc80..2c6a5d6d67a 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.cpp +++ b/lldb/tools/lldb-vscode/JSONUtils.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include <algorithm> + #include "llvm/Support/FormatAdapters.h" #include "lldb/API/SBBreakpoint.h" @@ -541,8 +543,10 @@ llvm::json::Value CreateSource(lldb::SBFrame &frame, int64_t &disasm_line) { line_strm << llvm::formatv("{0:X+}: <{1}> {2} {3,12} {4}", inst_addr, inst_offset, llvm::fmt_repeat(' ', spaces), m, o); - const uint32_t comment_row = 60; - // If there is a comment append it starting at column 60 + + // If there is a comment append it starting at column 60 or after one + // space past the last char + const uint32_t comment_row = std::max(line_strm.str().size(), (size_t)60); if (c && c[0]) { if (line.size() < comment_row) line_strm.indent(comment_row - line_strm.str().size()); |