[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- CommandObjectApropos.cpp ------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
#include "CommandObjectApropos.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2015-03-04 09:58:01 +08:00
|
|
|
#include "lldb/Interpreter/Property.h"
|
2018-04-18 02:53:35 +08:00
|
|
|
#include "lldb/Utility/Args.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// CommandObjectApropos
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectApropos::CommandObjectApropos(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(
|
|
|
|
interpreter, "apropos",
|
|
|
|
"List debugger commands related to a word or subject.", nullptr) {
|
2010-10-05 06:28:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData search_word_arg;
|
|
|
|
|
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
search_word_arg.arg_type = eArgTypeSearchWord;
|
|
|
|
search_word_arg.arg_repetition = eArgRepeatPlain;
|
|
|
|
|
|
|
|
// There is only one variant this argument could be; put it into the argument
|
|
|
|
// entry.
|
|
|
|
arg.push_back(search_word_arg);
|
|
|
|
|
|
|
|
// Push the data for the first argument into the m_arguments vector.
|
|
|
|
m_arguments.push_back(arg);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
CommandObjectApropos::~CommandObjectApropos() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
|
2013-01-26 02:06:21 +08:00
|
|
|
const size_t argc = args.GetArgumentCount();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (argc == 1) {
|
2019-09-13 19:26:48 +08:00
|
|
|
auto search_word = args[0].ref();
|
2016-12-09 09:20:58 +08:00
|
|
|
if (!search_word.empty()) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// The bulk of the work must be done inside the Command Interpreter,
|
|
|
|
// since the command dictionary is private.
|
2010-06-09 00:52:24 +08:00
|
|
|
StringList commands_found;
|
|
|
|
StringList commands_help;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-10-13 01:55:24 +08:00
|
|
|
m_interpreter.FindCommandsForApropos(
|
|
|
|
search_word, commands_found, commands_help, true, true, true, true);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-23 09:21:55 +08:00
|
|
|
if (commands_found.GetSize() == 0) {
|
2010-11-03 02:23:13 +08:00
|
|
|
result.AppendMessageWithFormat("No commands found pertaining to '%s'. "
|
|
|
|
"Try 'help' to see a complete list of "
|
2016-03-23 09:21:55 +08:00
|
|
|
"debugger commands.\n",
|
2016-12-09 09:20:58 +08:00
|
|
|
args[0].c_str());
|
2016-03-23 09:21:55 +08:00
|
|
|
} else {
|
2013-05-17 09:30:37 +08:00
|
|
|
if (commands_found.GetSize() > 0) {
|
|
|
|
result.AppendMessageWithFormat(
|
2016-12-09 09:20:58 +08:00
|
|
|
"The following commands may relate to '%s':\n", args[0].c_str());
|
2019-08-19 15:59:44 +08:00
|
|
|
const size_t max_len = commands_found.GetMaxStringLength();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
for (size_t i = 0; i < commands_found.GetSize(); ++i)
|
|
|
|
m_interpreter.OutputFormattedHelpText(
|
|
|
|
result.GetOutputStream(), commands_found.GetStringAtIndex(i),
|
2010-06-09 00:52:24 +08:00
|
|
|
"--", commands_help.GetStringAtIndex(i), max_len);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-08-23 01:17:09 +08:00
|
|
|
std::vector<const Property *> properties;
|
|
|
|
const size_t num_properties =
|
2019-04-27 14:19:42 +08:00
|
|
|
GetDebugger().Apropos(search_word, properties);
|
2012-08-23 01:17:09 +08:00
|
|
|
if (num_properties) {
|
|
|
|
const bool dump_qualified_name = true;
|
2016-12-16 12:27:00 +08:00
|
|
|
result.AppendMessageWithFormatv(
|
|
|
|
"\nThe following settings variables may relate to '{0}': \n\n",
|
2019-09-13 19:26:48 +08:00
|
|
|
args[0].ref());
|
2012-08-23 01:17:09 +08:00
|
|
|
for (size_t i = 0; i < num_properties; ++i)
|
|
|
|
properties[i]->DumpDescription(
|
2013-05-17 09:30:37 +08:00
|
|
|
m_interpreter, result.GetOutputStream(), 0, dump_qualified_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2010-06-09 00:52:24 +08:00
|
|
|
result.AppendError("'' is not a valid search word.\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result.AppendError("'apropos' must be called with exactly one argument.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|