diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-04-30 16:49:04 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-04-30 16:49:04 +0000 |
commit | 05097246f352eca76207c9ebb08656c88bdf751a (patch) | |
tree | bfc4ec8250a939aaf4ade6fc6c528726183e5367 /lldb/source/Commands/CommandObjectSource.cpp | |
parent | add59c052dd6768fd54431e6a3bf045e7f25cb59 (diff) | |
download | llvm-05097246f352eca76207c9ebb08656c88bdf751a.zip llvm-05097246f352eca76207c9ebb08656c88bdf751a.tar.gz llvm-05097246f352eca76207c9ebb08656c88bdf751a.tar.bz2 |
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/Commands/CommandObjectSource.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 123 |
1 files changed, 53 insertions, 70 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 7f2b9f0..19e2e44 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -148,16 +148,13 @@ public: Options *GetOptions() override { return &m_options; } protected: - // Dump the line entries in each symbol context. - // Return the number of entries found. - // If module_list is set, only dump lines contained in one of the modules. - // If file_spec is set, only dump lines in the file. - // If the start_line option was specified, don't print lines less than - // start_line. + // Dump the line entries in each symbol context. Return the number of entries + // found. If module_list is set, only dump lines contained in one of the + // modules. If file_spec is set, only dump lines in the file. If the + // start_line option was specified, don't print lines less than start_line. // If the end_line option was specified, don't print lines greater than - // end_line. - // If the num_lines option was specified, dont print more than num_lines - // entries. + // end_line. If the num_lines option was specified, dont print more than + // num_lines entries. uint32_t DumpLinesInSymbolContexts(Stream &strm, const SymbolContextList &sc_list, const ModuleList &module_list, @@ -222,14 +219,11 @@ protected: } // Dump the requested line entries for the file in the compilation unit. - // Return the number of entries found. - // If module_list is set, only dump lines contained in one of the modules. - // If the start_line option was specified, don't print lines less than - // start_line. - // If the end_line option was specified, don't print lines greater than - // end_line. - // If the num_lines option was specified, dont print more than num_lines - // entries. + // Return the number of entries found. If module_list is set, only dump lines + // contained in one of the modules. If the start_line option was specified, + // don't print lines less than start_line. If the end_line option was + // specified, don't print lines greater than end_line. If the num_lines + // option was specified, dont print more than num_lines entries. uint32_t DumpFileLinesInCompUnit(Stream &strm, Module *module, CompileUnit *cu, const FileSpec &file_spec) { uint32_t start_line = m_options.start_line; @@ -259,8 +253,8 @@ protected: while (true) { LineEntry line_entry; - // Find the lowest index of a line entry with a line equal to - // or higher than 'line'. + // Find the lowest index of a line entry with a line equal to or + // higher than 'line'. uint32_t start_idx = 0; start_idx = cu->FindLineEntry(start_idx, line, &cu_file_spec, /*exact=*/false, &line_entry); @@ -271,7 +265,8 @@ protected: if (end_line > 0 && line_entry.line > end_line) break; - // Loop through to find any other entries for this line, dumping each. + // Loop through to find any other entries for this line, dumping + // each. line = line_entry.line; do { num_matches++; @@ -305,22 +300,18 @@ protected: return num_matches; } - // Dump the requested line entries for the file in the module. - // Return the number of entries found. - // If module_list is set, only dump lines contained in one of the modules. - // If the start_line option was specified, don't print lines less than - // start_line. - // If the end_line option was specified, don't print lines greater than - // end_line. - // If the num_lines option was specified, dont print more than num_lines - // entries. + // Dump the requested line entries for the file in the module. Return the + // number of entries found. If module_list is set, only dump lines contained + // in one of the modules. If the start_line option was specified, don't print + // lines less than start_line. If the end_line option was specified, don't + // print lines greater than end_line. If the num_lines option was specified, + // dont print more than num_lines entries. uint32_t DumpFileLinesInModule(Stream &strm, Module *module, const FileSpec &file_spec) { uint32_t num_matches = 0; if (module) { // Look through all the compilation units (CUs) in this module for ones - // that - // contain lines of code from this source file. + // that contain lines of code from this source file. for (size_t i = 0; i < module->GetNumCompileUnits(); i++) { // Look for a matching source file in this CU. CompUnitSP cu_sp(module->GetCompileUnitAtIndex(i)); @@ -334,10 +325,8 @@ protected: } // Given an address and a list of modules, append the symbol contexts of all - // line entries - // containing the address found in the modules and return the count of - // matches. If none - // is found, return an error in 'error_strm'. + // line entries containing the address found in the modules and return the + // count of matches. If none is found, return an error in 'error_strm'. size_t GetSymbolContextsForAddress(const ModuleList &module_list, lldb::addr_t addr, SymbolContextList &sc_list, @@ -347,8 +336,8 @@ protected: assert(module_list.GetSize() > 0); Target *target = m_exe_ctx.GetTargetPtr(); if (target->GetSectionLoadList().IsEmpty()) { - // The target isn't loaded yet, we need to lookup the file address in - // all modules. Note: the module list option does not apply to addresses. + // The target isn't loaded yet, we need to lookup the file address in all + // modules. Note: the module list option does not apply to addresses. const size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; ++i) { ModuleSP module_sp(module_list.GetModuleAtIndex(i)); @@ -370,8 +359,8 @@ protected: " not found in any modules.\n", addr); } else { - // The target has some things loaded, resolve this address to a - // compile unit + file + line and display + // The target has some things loaded, resolve this address to a compile + // unit + file + line and display if (target->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) { ModuleSP module_sp(so_addr.GetModule()); // Check to make sure this module is in our list. @@ -409,8 +398,8 @@ protected: return num_matches; } - // Dump the line entries found in functions matching the name specified in the - // option. + // Dump the line entries found in functions matching the name specified in + // the option. bool DumpLinesInFunctions(CommandReturnObject &result) { SymbolContextList sc_list_funcs; ConstString name(m_options.symbol_name.c_str()); @@ -774,9 +763,9 @@ public: const char *GetRepeatCommand(Args ¤t_command_args, uint32_t index) override { - // This is kind of gross, but the command hasn't been parsed yet so we can't - // look at the option values for this invocation... I have to scan the - // arguments directly. + // This is kind of gross, but the command hasn't been parsed yet so we + // can't look at the option values for this invocation... I have to scan + // the arguments directly. auto iter = llvm::find_if(current_command_args, [](const Args::ArgEntry &e) { return e.ref == "-r" || e.ref == "--reverse"; @@ -864,11 +853,9 @@ protected: } // This is a little hacky, but the first line table entry for a function - // points to the "{" that - // starts the function block. It would be nice to actually get the - // function - // declaration in there too. So back up a bit, but not further than what - // you're going to display. + // points to the "{" that starts the function block. It would be nice to + // actually get the function declaration in there too. So back up a bit, + // but not further than what you're going to display. uint32_t extra_lines; if (m_options.num_lines >= 10) extra_lines = 5; @@ -881,8 +868,7 @@ protected: line_no = start_line - extra_lines; // For fun, if the function is shorter than the number of lines we're - // supposed to display, - // only display the function... + // supposed to display, only display the function... if (end_line != 0) { if (m_options.num_lines > end_line - line_no) m_options.num_lines = end_line - line_no + extra_lines; @@ -913,14 +899,13 @@ protected: return 0; } - // From Jim: The FindMatchingFunctions / FindMatchingFunctionSymbols functions - // "take a possibly empty vector of strings which are names of modules, and - // run the two search functions on the subset of the full module list that - // matches the strings in the input vector". If we wanted to put these - // somewhere, - // there should probably be a module-filter-list that can be passed to the - // various ModuleList::Find* calls, which would either be a vector of string - // names or a ModuleSpecList. + // From Jim: The FindMatchingFunctions / FindMatchingFunctionSymbols + // functions "take a possibly empty vector of strings which are names of + // modules, and run the two search functions on the subset of the full module + // list that matches the strings in the input vector". If we wanted to put + // these somewhere, there should probably be a module-filter-list that can be + // passed to the various ModuleList::Find* calls, which would either be a + // vector of string names or a ModuleSpecList. size_t FindMatchingFunctions(Target *target, const ConstString &name, SymbolContextList &sc_list) { // Displaying the source for a symbol: @@ -997,8 +982,7 @@ protected: size_t num_matches = FindMatchingFunctions(target, name, sc_list); if (!num_matches) { // If we didn't find any functions with that name, try searching for - // symbols - // that line up exactly with function addresses. + // symbols that line up exactly with function addresses. SymbolContextList sc_list_symbols; size_t num_symbol_matches = FindMatchingFunctionSymbols(target, name, sc_list_symbols); @@ -1065,8 +1049,8 @@ protected: SymbolContextList sc_list; if (target->GetSectionLoadList().IsEmpty()) { - // The target isn't loaded yet, we need to lookup the file address - // in all modules + // The target isn't loaded yet, we need to lookup the file address in + // all modules const ModuleList &module_list = target->GetImages(); const size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; ++i) { @@ -1091,8 +1075,8 @@ protected: return false; } } else { - // The target has some things loaded, resolve this address to a - // compile unit + file + line and display + // The target has some things loaded, resolve this address to a compile + // unit + file + line and display if (target->GetSectionLoadList().ResolveLoadAddress(m_options.address, so_addr)) { ModuleSP module_sp(so_addr.GetModule()); @@ -1169,11 +1153,10 @@ protected: } } } else if (m_options.file_name.empty()) { - // Last valid source manager context, or the current frame if no - // valid last context in source manager. - // One little trick here, if you type the exact same list command twice in - // a row, it is - // more likely because you typed it once, then typed it again + // Last valid source manager context, or the current frame if no valid + // last context in source manager. One little trick here, if you type the + // exact same list command twice in a row, it is more likely because you + // typed it once, then typed it again if (m_options.start_line == 0) { if (target->GetSourceManager().DisplayMoreWithLineNumbers( &result.GetOutputStream(), m_options.num_lines, |