summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Disassembler.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2018-04-30 16:49:04 +0000
committerAdrian Prantl <aprantl@apple.com>2018-04-30 16:49:04 +0000
commit05097246f352eca76207c9ebb08656c88bdf751a (patch)
treebfc4ec8250a939aaf4ade6fc6c528726183e5367 /lldb/source/Core/Disassembler.cpp
parentadd59c052dd6768fd54431e6a3bf045e7f25cb59 (diff)
downloadbcm5719-llvm-05097246f352eca76207c9ebb08656c88bdf751a.tar.gz
bcm5719-llvm-05097246f352eca76207c9ebb08656c88bdf751a.zip
Reflow paragraphs in comments.
This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
Diffstat (limited to 'lldb/source/Core/Disassembler.cpp')
-rw-r--r--lldb/source/Core/Disassembler.cpp83
1 files changed, 38 insertions, 45 deletions
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index 6d463d552da..7fa72f60ccf 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -96,8 +96,8 @@ DisassemblerSP Disassembler::FindPluginForTarget(const TargetSP target_sp,
const char *plugin_name) {
if (target_sp && flavor == nullptr) {
// FIXME - we don't have the mechanism in place to do per-architecture
- // settings. But since we know that for now
- // we only support flavors on x86 & x86_64,
+ // settings. But since we know that for now we only support flavors on x86
+ // & x86_64,
if (arch.GetTriple().getArch() == llvm::Triple::x86 ||
arch.GetTriple().getArch() == llvm::Triple::x86_64)
flavor = target_sp->GetDisassemblyFlavor();
@@ -108,8 +108,8 @@ DisassemblerSP Disassembler::FindPluginForTarget(const TargetSP target_sp,
static void ResolveAddress(const ExecutionContext &exe_ctx, const Address &addr,
Address &resolved_addr) {
if (!addr.IsSectionOffset()) {
- // If we weren't passed in a section offset address range,
- // try and resolve it to something
+ // If we weren't passed in a section offset address range, try and resolve
+ // it to something
Target *target = exe_ctx.GetTargetPtr();
if (target) {
if (target->GetSectionLoadList().IsEmpty()) {
@@ -118,8 +118,7 @@ static void ResolveAddress(const ExecutionContext &exe_ctx, const Address &addr,
target->GetSectionLoadList().ResolveLoadAddress(addr.GetOffset(),
resolved_addr);
}
- // We weren't able to resolve the address, just treat it as a
- // raw address
+ // We weren't able to resolve the address, just treat it as a raw address
if (resolved_addr.IsValid())
return;
}
@@ -410,15 +409,13 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
disassembly_format = &format;
}
- // First pass: step through the list of instructions,
- // find how long the initial addresses strings are, insert padding
- // in the second pass so the opcodes all line up nicely.
+ // First pass: step through the list of instructions, find how long the
+ // initial addresses strings are, insert padding in the second pass so the
+ // opcodes all line up nicely.
// Also build up the source line mapping if this is mixed source & assembly
- // mode.
- // Calculate the source line for each assembly instruction (eliding inlined
- // functions
- // which the user wants to skip).
+ // mode. Calculate the source line for each assembly instruction (eliding
+ // inlined functions which the user wants to skip).
std::map<FileSpec, std::set<uint32_t>> source_lines_seen;
Symbol *previous_symbol = nullptr;
@@ -495,17 +492,13 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
if (mixed_source_and_assembly) {
// If we've started a new function (non-inlined), print all of the
- // source lines from the
- // function declaration until the first line table entry - typically
- // the opening curly brace of
- // the function.
+ // source lines from the function declaration until the first line
+ // table entry - typically the opening curly brace of the function.
if (previous_symbol != sc.symbol) {
- // The default disassembly format puts an extra blank line between
- // functions - so
- // when we're displaying the source context for a function, we
- // don't want to add
- // a blank line after the source context or we'll end up with two
- // of them.
+ // The default disassembly format puts an extra blank line
+ // between functions - so when we're displaying the source
+ // context for a function, we don't want to add a blank line
+ // after the source context or we'll end up with two of them.
if (previous_symbol != nullptr)
source_lines_to_display.print_source_context_end_eol = false;
@@ -520,9 +513,9 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
func_decl_line);
if (func_decl_file == prologue_end_line.file ||
func_decl_file == prologue_end_line.original_file) {
- // Add all the lines between the function declaration
- // and the first non-prologue source line to the list
- // of lines to print.
+ // Add all the lines between the function declaration and
+ // the first non-prologue source line to the list of lines
+ // to print.
for (uint32_t lineno = func_decl_line;
lineno <= prologue_end_line.line; lineno++) {
SourceLine this_line;
@@ -530,8 +523,8 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
this_line.line = lineno;
source_lines_to_display.lines.push_back(this_line);
}
- // Mark the last line as the "current" one. Usually
- // this is the open curly brace.
+ // Mark the last line as the "current" one. Usually this
+ // is the open curly brace.
if (source_lines_to_display.lines.size() > 0)
source_lines_to_display.current_source_line =
source_lines_to_display.lines.size() - 1;
@@ -542,8 +535,8 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
current_source_line_range);
}
- // If we've left a previous source line's address range, print a new
- // source line
+ // If we've left a previous source line's address range, print a
+ // new source line
if (!current_source_line_range.ContainsFileAddress(addr)) {
sc.GetAddressRange(scope, 0, use_inline_block_range,
current_source_line_range);
@@ -558,8 +551,8 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
// Only print this source line if it is different from the
// last source line we printed. There may have been inlined
// functions between these lines that we elided, resulting in
- // the same line being printed twice in a row for a contiguous
- // block of assembly instructions.
+ // the same line being printed twice in a row for a
+ // contiguous block of assembly instructions.
if (this_line != previous_line) {
std::vector<uint32_t> previous_lines;
@@ -710,16 +703,16 @@ void Instruction::Dump(lldb_private::Stream *s, uint32_t max_opcode_byte_size,
if (show_bytes) {
if (m_opcode.GetType() == Opcode::eTypeBytes) {
- // x86_64 and i386 are the only ones that use bytes right now so
- // pad out the byte dump to be able to always show 15 bytes (3 chars each)
- // plus a space
+ // x86_64 and i386 are the only ones that use bytes right now so pad out
+ // the byte dump to be able to always show 15 bytes (3 chars each) plus a
+ // space
if (max_opcode_byte_size > 0)
m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1);
else
m_opcode.Dump(&ss, 15 * 3 + 1);
} else {
- // Else, we have ARM or MIPS which can show up to a uint32_t
- // 0x00000000 (10 spaces) plus two for padding...
+ // Else, we have ARM or MIPS which can show up to a uint32_t 0x00000000
+ // (10 spaces) plus two for padding...
if (max_opcode_byte_size > 0)
m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1);
else
@@ -903,7 +896,8 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
option_value_sp.reset();
return option_value_sp;
}
- // We've used the data_type to read an array; re-set the type to Invalid
+ // We've used the data_type to read an array; re-set the type to
+ // Invalid
data_type = OptionValue::eTypeInvalid;
} else if ((value[0] == '0') && (value[1] == 'x')) {
value_sp = std::make_shared<OptionValueUInt64>(0, 0);
@@ -1107,9 +1101,9 @@ InstructionList::GetIndexOfNextBranchInstruction(uint32_t start,
}
}
- // Hexagon needs the first instruction of the packet with the branch.
- // Go backwards until we find an instruction marked end-of-packet, or
- // until we hit start.
+ // Hexagon needs the first instruction of the packet with the branch. Go
+ // backwards until we find an instruction marked end-of-packet, or until we
+ // hit start.
if (target.GetArchitecture().GetTriple().getArch() == llvm::Triple::hexagon) {
// If we didn't find a branch, find the last packet start.
if (next_branch == UINT32_MAX) {
@@ -1128,8 +1122,8 @@ InstructionList::GetIndexOfNextBranchInstruction(uint32_t start,
// If we have an error reading memory, return start
if (!error.Success())
return start;
- // check if this is the last instruction in a packet
- // bits 15:14 will be 11b or 00b for a duplex
+ // check if this is the last instruction in a packet bits 15:14 will be
+ // 11b or 00b for a duplex
if (((inst_bytes & 0xC000) == 0xC000) ||
((inst_bytes & 0xC000) == 0x0000)) {
// instruction after this should be the start of next packet
@@ -1257,8 +1251,7 @@ Disassembler::Disassembler(const ArchSpec &arch, const char *flavor)
m_flavor.assign(flavor);
// If this is an arm variant that can only include thumb (T16, T32)
- // instructions, force the arch triple to be "thumbv.." instead of
- // "armv..."
+ // instructions, force the arch triple to be "thumbv.." instead of "armv..."
if (arch.IsAlwaysThumbInstructions()) {
std::string thumb_arch_name(arch.GetTriple().getArchName().str());
// Replace "arm" with "thumb" so we get all thumb variants correct
OpenPOWER on IntegriCloud