diff options
author | dim <dim@FreeBSD.org> | 2017-09-26 19:56:36 +0000 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2018-02-21 15:12:19 -0300 |
commit | 1dcd2e8d24b295bc73e513acec2ed1514bb66be4 (patch) | |
tree | 4bd13a34c251e980e1a6b13584ca1f63b0dfe670 /contrib/llvm/tools/lldb/source/Commands | |
parent | f45541ca2a56a1ba1202f94c080b04e96c1fa239 (diff) | |
download | FreeBSD-src-1dcd2e8d24b295bc73e513acec2ed1514bb66be4.zip FreeBSD-src-1dcd2e8d24b295bc73e513acec2ed1514bb66be4.tar.gz |
Merge clang, llvm, lld, lldb, compiler-rt and libc++ 5.0.0 release.
MFC r309126 (by emaste):
Correct lld llvm-tblgen dependency file name
MFC r309169:
Get rid of separate Subversion mergeinfo properties for llvm-dwarfdump
and llvm-lto. The mergeinfo confuses Subversion enormously, and these
directories will just use the mergeinfo for llvm itself.
MFC r312765:
Pull in r276136 from upstream llvm trunk (by Wei Mi):
Use ValueOffsetPair to enhance value reuse during SCEV expansion.
In D12090, the ExprValueMap was added to reuse existing value during
SCEV expansion. However, const folding and sext/zext distribution can
make the reuse still difficult.
A simplified case is: suppose we know S1 expands to V1 in
ExprValueMap, and
S1 = S2 + C_a
S3 = S2 + C_b
where C_a and C_b are different SCEVConstants. Then we'd like to
expand S3 as V1 - C_a + C_b instead of expanding S2 literally. It is
helpful when S2 is a complex SCEV expr and S2 has no entry in
ExprValueMap, which is usually caused by the fact that S3 is
generated from S1 after const folding.
In order to do that, we represent ExprValueMap as a mapping from SCEV
to ValueOffsetPair. We will save both S1->{V1, 0} and S2->{V1, C_a}
into the ExprValueMap when we create SCEV for V1. When S3 is
expanded, it will first expand S2 to V1 - C_a because of S2->{V1,
C_a} in the map, then expand S3 to V1 - C_a + C_b.
Differential Revision: https://reviews.llvm.org/D21313
This should fix assertion failures when building OpenCV >= 3.1.
PR: 215649
MFC r312831:
Revert r312765 for now, since it causes assertions when building
lang/spidermonkey24.
Reported by: antoine
PR: 215649
MFC r316511 (by jhb):
Add an implementation of __ffssi2() derived from __ffsdi2().
Newer versions of GCC include an __ffssi2() symbol in libgcc and the
compiler can emit calls to it in generated code. This is true for at
least GCC 6.2 when compiling world for mips and mips64.
Reviewed by: jmallett, dim
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10086
MFC r318601 (by adrian):
[libcompiler-rt] add bswapdi2/bswapsi2
This is required for mips gcc 6.3 userland to build/run.
Reviewed by: emaste, dim
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D10838
MFC r318884 (by emaste):
lldb: map TRAP_CAP to a trace trap
In the absense of a more specific handler for TRAP_CAP (generated by
ENOTCAPABLE or ECAPMODE while in capability mode) treat it as a trace
trap.
Example usage (testing the bug in PR219173):
% proccontrol -m trapcap lldb usr.bin/hexdump/obj/hexdump -- -Cv -s 1 /bin/ls
...
(lldb) run
Process 12980 launching
Process 12980 launched: '.../usr.bin/hexdump/obj/hexdump' (x86_64)
Process 12980 stopped
* thread #1, stop reason = trace
frame #0: 0x0000004b80c65f1a libc.so.7`__sys_lseek + 10
...
In the future we should have LLDB control the trapcap procctl itself
(as it does with ASLR), as well as report a specific stop reason.
This change eliminates an assertion failure from LLDB for now.
MFC r319796:
Remove a few unneeded files from libllvm, libclang and liblldb.
MFC r319885 (by emaste):
lld: ELF: Fix ICF crash on absolute symbol relocations.
If two sections contained relocations to absolute symbols with the same
value we would crash when trying to access their sections. Add a check that
both symbols point to sections before accessing their sections, and treat
absolute symbols as equal if their values are equal.
Obtained from: LLD commit r292578
MFC r319918:
Revert r319796 for now, it can cause undefined references when linking
in some circumstances.
Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
MFC r319957 (by emaste):
lld: Add armelf emulation mode
Obtained from: LLD r305375
MFC r321369:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.0 (trunk r308421). Upstream has branched for the 5.0.0 release,
which should be in about a month. Please report bugs and regressions,
so we can get them into the release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
MFC r321420:
Add a few more object files to liblldb, which should solve errors when
linking the lldb executable in some cases. In particular, when the
-ffunction-sections -fdata-sections options are turned off, or
ineffective.
Reported by: Shawn Webb, Mark Millard
MFC r321433:
Cleanup stale Options.inc files from the previous libllvm build for
clang 4.0.0. Otherwise, these can get included before the two newly
generated ones (which are different) for clang 5.0.0.
Reported by: Mark Millard
MFC r321439 (by bdrewery):
Move llvm Options.inc hack from r321433 for NO_CLEAN to lib/clang/libllvm.
The files are only ever generated to .OBJDIR, not to WORLDTMP (as a
sysroot) and are only ever included from a compilation. So using
a beforebuild target here removes the file before the compilation
tries to include it.
MFC r321664:
Pull in r308891 from upstream llvm trunk (by Benjamin Kramer):
[CodeGenPrepare] Cut off FindAllMemoryUses if there are too many uses.
This avoids excessive compile time. The case I'm looking at is
Function.cpp from an old version of LLVM that still had the giant
memcmp string matcher in it. Before r308322 this compiled in about 2
minutes, after it, clang takes infinite* time to compile it. With
this patch we're at 5 min, which is still bad but this is a
pathological case.
The cut off at 20 uses was chosen by looking at other cut-offs in LLVM
for user scanning. It's probably too high, but does the job and is
very unlikely to regress anything.
Fixes PR33900.
* I'm impatient and aborted after 15 minutes, on the bug report it was
killed after 2h.
Pull in r308986 from upstream llvm trunk (by Simon Pilgrim):
[X86][CGP] Reduce memcmp() expansion to 2 load pairs (PR33914)
D35067/rL308322 attempted to support up to 4 load pairs for memcmp
inlining which resulted in regressions for some optimized libc memcmp
implementations (PR33914).
Until we can match these more optimal cases, this patch reduces the
memcmp expansion to a maximum of 2 load pairs (which matches what we
do for -Os).
This patch should be considered for the 5.0.0 release branch as well
Differential Revision: https://reviews.llvm.org/D35830
These fix a hang (or extremely long compile time) when building older
LLVM ports.
Reported by: antoine
PR: 219139
MFC r321719:
Pull in r309503 from upstream clang trunk (by Richard Smith):
PR33902: Invalidate line number cache when adding more text to
existing buffer.
This led to crashes as the line number cache would report a bogus
line number for a line of code, and we'd try to find a nonexistent
column within the line when printing diagnostics.
This fixes an assertion when building the graphics/champlain port.
Reported by: antoine, kwm
PR: 219139
MFC r321723:
Upgrade our copies of clang, llvm, lld and lldb to r309439 from the
upstream release_50 branch. This is just after upstream's 5.0.0-rc1.
MFC r322320:
Upgrade our copies of clang, llvm and libc++ to r310316 from the
upstream release_50 branch.
MFC r322326 (by emaste):
lldb: Make i386-*-freebsd expression work on JIT path
* Enable i386 ABI creation for freebsd
* Added an extra argument in ABISysV_i386::PrepareTrivialCall for mmap
syscall
* Unlike linux, the last argument of mmap is actually 64-bit(off_t).
This requires us to push an additional word for the higher order bits.
* Prior to this change, ktrace dump will show mmap failures due to
invalid argument coming from the 6th mmap argument.
Submitted by: Karnajit Wangkhem
Differential Revision: https://reviews.llvm.org/D34776
MFC r322360 (by emaste):
lldb: Report inferior signals as signals, not exceptions, on FreeBSD
This is the FreeBSD equivalent of LLVM r238549.
This serves 2 purposes:
* LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/
SIGFPE the way it is suppose to be handled. Prior to this fix these
signals will neither create a coredump, nor exit from the debugger
or work for signal handling scenario.
* eInvalidCrashReason need not report "unknown crash reason" if we have
a valid si_signo
llvm.org/pr23699
Patch by Karnajit Wangkhem
Differential Revision: https://reviews.llvm.org/D35223
Submitted by: Karnajit Wangkhem
Obtained from: LLVM r310591
MFC r322474 (by emaste):
lld: Add `-z muldefs` option.
Obtained from: LLVM r310757
MFC r322740:
Upgrade our copies of clang, llvm, lld and libc++ to r311219 from the
upstream release_50 branch.
MFC r322855:
Upgrade our copies of clang, llvm, lldb and compiler-rt to r311606 from
the upstream release_50 branch.
As of this version, lib/msun's trig test should also work correctly
again (see bug 220989 for more information).
PR: 220989
MFC r323112:
Upgrade our copies of clang, llvm, lldb and compiler-rt to r312293 from
the upstream release_50 branch. This corresponds to 5.0.0 rc4.
As of this version, the cad/stepcode port should now compile in a more
reasonable time on i386 (see bug 221836 for more information).
PR: 221836
MFC r323245:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.0 release (upstream r312559).
Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/5.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/5.0.0/tools/lld/docs/ReleaseNotes.html>
Relnotes: yes
(cherry picked from commit 12cd91cf4c6b96a24427c0de5374916f2808d263)
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Commands')
26 files changed, 824 insertions, 666 deletions
diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp index 10c1a24..fd84e1c 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandCompletions.cpp @@ -16,12 +16,12 @@ // C++ Includes // Other libraries and framework includes #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringSet.h" // Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" @@ -31,8 +31,13 @@ #include "lldb/Symbol/Variable.h" #include "lldb/Target/Target.h" #include "lldb/Utility/CleanUp.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/TildeExpressionResolver.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" using namespace lldb_private; @@ -98,181 +103,131 @@ int CommandCompletions::SourceFiles(CommandInterpreter &interpreter, return matches.GetSize(); } -typedef struct DiskFilesOrDirectoriesBaton { - const char *remainder; - char *partial_name_copy; - bool only_directories; - bool *saw_directory; - StringList *matches; - char *end_ptr; - size_t baselen; -} DiskFilesOrDirectoriesBaton; - -FileSpec::EnumerateDirectoryResult -DiskFilesOrDirectoriesCallback(void *baton, FileSpec::FileType file_type, - const FileSpec &spec) { - const char *name = spec.GetFilename().AsCString(); - - const DiskFilesOrDirectoriesBaton *parameters = - (DiskFilesOrDirectoriesBaton *)baton; - char *end_ptr = parameters->end_ptr; - char *partial_name_copy = parameters->partial_name_copy; - const char *remainder = parameters->remainder; - - // Omit ".", ".." and any . files if the match string doesn't start with . - if (name[0] == '.') { - if (name[1] == '\0') - return FileSpec::eEnumerateDirectoryResultNext; - else if (name[1] == '.' && name[2] == '\0') - return FileSpec::eEnumerateDirectoryResultNext; - else if (remainder[0] != '.') - return FileSpec::eEnumerateDirectoryResultNext; - } +static int DiskFilesOrDirectories(const llvm::Twine &partial_name, + bool only_directories, bool &saw_directory, + StringList &matches, + TildeExpressionResolver &Resolver) { + matches.Clear(); + + llvm::SmallString<256> CompletionBuffer; + llvm::SmallString<256> Storage; + partial_name.toVector(CompletionBuffer); + + if (CompletionBuffer.size() >= PATH_MAX) + return 0; + + namespace fs = llvm::sys::fs; + namespace path = llvm::sys::path; + + llvm::StringRef SearchDir; + llvm::StringRef PartialItem; + + if (CompletionBuffer.startswith("~")) { + llvm::StringRef Buffer(CompletionBuffer); + size_t FirstSep = + Buffer.find_if([](char c) { return path::is_separator(c); }); + + llvm::StringRef Username = Buffer.take_front(FirstSep); + llvm::StringRef Remainder; + if (FirstSep != llvm::StringRef::npos) + Remainder = Buffer.drop_front(FirstSep + 1); + + llvm::SmallString<PATH_MAX> Resolved; + if (!Resolver.ResolveExact(Username, Resolved)) { + // We couldn't resolve it as a full username. If there were no slashes + // then this might be a partial username. We try to resolve it as such + // but after that, we're done regardless of any matches. + if (FirstSep == llvm::StringRef::npos) { + llvm::StringSet<> MatchSet; + saw_directory = Resolver.ResolvePartial(Username, MatchSet); + for (const auto &S : MatchSet) { + Resolved = S.getKey(); + path::append(Resolved, path::get_separator()); + matches.AppendString(Resolved); + } + saw_directory = (matches.GetSize() > 0); + } + return matches.GetSize(); + } - // If we found a directory, we put a "/" at the end of the name. + // If there was no trailing slash, then we're done as soon as we resolve the + // expression to the correct directory. Otherwise we need to continue + // looking for matches within that directory. + if (FirstSep == llvm::StringRef::npos) { + // Make sure it ends with a separator. + path::append(CompletionBuffer, path::get_separator()); + saw_directory = true; + matches.AppendString(CompletionBuffer); + return 1; + } - if (remainder[0] == '\0' || strstr(name, remainder) == name) { - if (strlen(name) + parameters->baselen >= PATH_MAX) - return FileSpec::eEnumerateDirectoryResultNext; + // We want to keep the form the user typed, so we special case this to + // search in the fully resolved directory, but CompletionBuffer keeps the + // unmodified form that the user typed. + Storage = Resolved; + SearchDir = Resolved; + } else { + SearchDir = path::parent_path(CompletionBuffer); + } - strcpy(end_ptr, name); + size_t FullPrefixLen = CompletionBuffer.size(); - bool isa_directory = false; - if (file_type == FileSpec::eFileTypeDirectory) - isa_directory = true; - else if (file_type == FileSpec::eFileTypeSymbolicLink) { - if (FileSpec(partial_name_copy, false).IsDirectory()) - isa_directory = true; - } + PartialItem = path::filename(CompletionBuffer); + if (PartialItem == ".") + PartialItem = llvm::StringRef(); - if (isa_directory) { - *parameters->saw_directory = true; - size_t len = strlen(parameters->partial_name_copy); - partial_name_copy[len] = '/'; - partial_name_copy[len + 1] = '\0'; - } - if (parameters->only_directories && !isa_directory) - return FileSpec::eEnumerateDirectoryResultNext; - parameters->matches->AppendString(partial_name_copy); + if (SearchDir.empty()) { + llvm::sys::fs::current_path(Storage); + SearchDir = Storage; } + assert(!PartialItem.contains(path::get_separator())); - return FileSpec::eEnumerateDirectoryResultNext; -} + // SearchDir now contains the directory to search in, and Prefix contains the + // text we want to match against items in that directory. -static int DiskFilesOrDirectories(llvm::StringRef partial_file_name, - bool only_directories, bool &saw_directory, - StringList &matches) { - // I'm going to use the "glob" function with GLOB_TILDE for user directory - // expansion. - // If it is not defined on your host system, you'll need to implement it - // yourself... - - size_t partial_name_len = partial_file_name.size(); - - if (partial_name_len >= PATH_MAX) - return matches.GetSize(); - - // This copy of the string will be cut up into the directory part, and the - // remainder. end_ptr below will point to the place of the remainder in this - // string. Then when we've resolved the containing directory, and opened it, - // we'll read the directory contents and overwrite the partial_name_copy - // starting from end_ptr with each of the matches. Thus we will preserve the - // form the user originally typed. - - char partial_name_copy[PATH_MAX]; - memcpy(partial_name_copy, partial_file_name.data(), partial_name_len); - partial_name_copy[partial_name_len] = '\0'; - - // We'll need to save a copy of the remainder for comparison, which we do - // here. - char remainder[PATH_MAX]; - - // end_ptr will point past the last / in partial_name_copy, or if there is no - // slash to the beginning of the string. - char *end_ptr; - - end_ptr = strrchr(partial_name_copy, '/'); - - // This will store the resolved form of the containing directory - llvm::SmallString<64> containing_part; - - if (end_ptr == nullptr) { - // There's no directory. If the thing begins with a "~" then this is a bare - // user name. - if (*partial_name_copy == '~') { - // Nothing here but the user name. We could just put a slash on the end, - // but for completeness sake we'll resolve the user name and only put a - // slash - // on the end if it exists. - llvm::SmallString<64> resolved_username(partial_name_copy); - FileSpec::ResolveUsername(resolved_username); - - // Not sure how this would happen, a username longer than PATH_MAX? - // Still... - if (resolved_username.size() == 0) { - // The user name didn't resolve, let's look in the password database for - // matches. - // The user name database contains duplicates, and is not in - // alphabetical order, so - // we'll use a set to manage that for us. - FileSpec::ResolvePartialUsername(partial_name_copy, matches); - if (matches.GetSize() > 0) - saw_directory = true; - return matches.GetSize(); - } else { - // The thing exists, put a '/' on the end, and return it... - // FIXME: complete user names here: - partial_name_copy[partial_name_len] = '/'; - partial_name_copy[partial_name_len + 1] = '\0'; - matches.AppendString(partial_name_copy); - saw_directory = true; - return matches.GetSize(); - } - } else { - // The containing part is the CWD, and the whole string is the remainder. - containing_part = "."; - strcpy(remainder, partial_name_copy); - end_ptr = partial_name_copy; - } - } else { - if (end_ptr == partial_name_copy) { - // We're completing a file or directory in the root volume. - containing_part = "/"; - } else { - containing_part.append(partial_name_copy, end_ptr); - } - // Push end_ptr past the final "/" and set remainder. - end_ptr++; - strcpy(remainder, end_ptr); - } + std::error_code EC; + fs::directory_iterator Iter(SearchDir, EC, false); + fs::directory_iterator End; + for (; Iter != End && !EC; Iter.increment(EC)) { + auto &Entry = *Iter; - // Look for a user name in the containing part, and if it's there, resolve it - // and stick the - // result back into the containing_part: + auto Name = path::filename(Entry.path()); - if (*partial_name_copy == '~') { - FileSpec::ResolveUsername(containing_part); - // User name doesn't exist, we're not getting any further... - if (containing_part.empty()) - return matches.GetSize(); - } + // Omit ".", ".." + if (Name == "." || Name == ".." || !Name.startswith(PartialItem)) + continue; - // Okay, containing_part is now the directory we want to open and look for - // files: + // We have a match. - size_t baselen = end_ptr - partial_name_copy; + fs::file_status st; + if ((EC = Entry.status(st))) + continue; - DiskFilesOrDirectoriesBaton parameters; - parameters.remainder = remainder; - parameters.partial_name_copy = partial_name_copy; - parameters.only_directories = only_directories; - parameters.saw_directory = &saw_directory; - parameters.matches = &matches; - parameters.end_ptr = end_ptr; - parameters.baselen = baselen; + // If it's a symlink, then we treat it as a directory as long as the target + // is a directory. + bool is_dir = fs::is_directory(st); + if (fs::is_symlink_file(st)) { + fs::file_status target_st; + if (!fs::status(Entry.path(), target_st)) + is_dir = fs::is_directory(target_st); + } + if (only_directories && !is_dir) + continue; + + // Shrink it back down so that it just has the original prefix the user + // typed and remove the part of the name which is common to the located + // item and what the user typed. + CompletionBuffer.resize(FullPrefixLen); + Name = Name.drop_front(PartialItem.size()); + CompletionBuffer.append(Name); + + if (is_dir) { + saw_directory = true; + path::append(CompletionBuffer, path::get_separator()); + } - FileSpec::EnumerateDirectory(containing_part.c_str(), true, true, true, - DiskFilesOrDirectoriesCallback, ¶meters); + matches.AppendString(CompletionBuffer); + } return matches.GetSize(); } @@ -283,9 +238,17 @@ int CommandCompletions::DiskFiles(CommandInterpreter &interpreter, int max_return_elements, SearchFilter *searcher, bool &word_complete, StringList &matches) { - int ret_val = - DiskFilesOrDirectories(partial_file_name, false, word_complete, matches); - word_complete = !word_complete; + word_complete = false; + StandardTildeExpressionResolver Resolver; + return DiskFiles(partial_file_name, matches, Resolver); +} + +int CommandCompletions::DiskFiles(const llvm::Twine &partial_file_name, + StringList &matches, + TildeExpressionResolver &Resolver) { + bool word_complete; + int ret_val = DiskFilesOrDirectories(partial_file_name, false, word_complete, + matches, Resolver); return ret_val; } @@ -293,9 +256,17 @@ int CommandCompletions::DiskDirectories( CommandInterpreter &interpreter, llvm::StringRef partial_file_name, int match_start_point, int max_return_elements, SearchFilter *searcher, bool &word_complete, StringList &matches) { - int ret_val = - DiskFilesOrDirectories(partial_file_name, true, word_complete, matches); word_complete = false; + StandardTildeExpressionResolver Resolver; + return DiskDirectories(partial_file_name, matches, Resolver); +} + +int CommandCompletions::DiskDirectories(const llvm::Twine &partial_file_name, + StringList &matches, + TildeExpressionResolver &Resolver) { + bool word_complete; + int ret_val = DiskFilesOrDirectories(partial_file_name, true, word_complete, + matches, Resolver); return ret_val; } diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp index d98a246..92c2107 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.cpp @@ -17,6 +17,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" #include "lldb/Host/Host.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -54,10 +55,10 @@ CommandObjectArgs::CommandOptions::CommandOptions( CommandObjectArgs::CommandOptions::~CommandOptions() = default; -Error CommandObjectArgs::CommandOptions::SetOptionValue( +Status CommandObjectArgs::CommandOptions::SetOptionValue( uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) { - Error error; + Status error; const int short_option = m_getopt_table[option_idx].val; error.SetErrorStringWithFormat("invalid short option character '%c'", @@ -223,9 +224,9 @@ bool CommandObjectArgs::DoExecute(Args &args, CommandReturnObject &result) { result.GetOutputStream().Printf("Arguments : \n"); for (auto entry : llvm::enumerate(args.entries())) { - result.GetOutputStream().Printf("%" PRIu64 " (%s): ", (uint64_t)entry.Index, - entry.Value.c_str()); - value_list.GetValueAtIndex(entry.Index)->Dump(&result.GetOutputStream()); + result.GetOutputStream().Printf( + "%" PRIu64 " (%s): ", (uint64_t)entry.index(), entry.value().c_str()); + value_list.GetValueAtIndex(entry.index())->Dump(&result.GetOutputStream()); result.GetOutputStream().Printf("\n"); } diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.h index a4b3f9f..aa7d241 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.h +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectArgs.h @@ -27,8 +27,8 @@ public: ~CommandOptions() override; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override; void OptionParsingStarting(ExecutionContext *execution_context) override; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp index 941dd9a..266864d 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -18,9 +18,7 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/StreamString.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -33,6 +31,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -178,9 +178,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -662,7 +662,7 @@ protected: .get(); } break; case eSetTypeException: { - Error precond_error; + Status precond_error; bp = target ->CreateExceptionBreakpoint( m_options.m_exception_language, m_options.m_catch_bp, @@ -705,7 +705,7 @@ protected: bp->GetOptions()->SetCondition(m_options.m_condition.c_str()); if (!m_options.m_breakpoint_names.empty()) { - Error name_error; + Status name_error; for (auto name : m_options.m_breakpoint_names) { bp->AddName(name.c_str(), name_error); if (name_error.Fail()) { @@ -844,9 +844,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1305,9 +1305,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1452,9 +1452,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1611,9 +1611,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1751,9 +1751,9 @@ public: return llvm::makeArrayRef(g_breakpoint_name_options); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = g_breakpoint_name_options[option_idx].short_option; switch (short_option) { @@ -1864,8 +1864,8 @@ protected: lldb::break_id_t bp_id = valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID(); BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id); - Error error; // We don't need to check the error here, since the option - // parser checked it... + Status error; // We don't need to check the error here, since the option + // parser checked it... bp_sp->AddName(m_name_options.m_name.GetCurrentValue(), error); } } @@ -2093,9 +2093,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -2103,7 +2103,7 @@ public: m_filename.assign(option_arg); break; case 'N': { - Error name_error; + Status name_error; if (!BreakpointID::StringIsBreakpointName(llvm::StringRef(option_arg), name_error)) { error.SetErrorStringWithFormat("Invalid breakpoint name: %s", @@ -2150,8 +2150,8 @@ protected: FileSpec input_spec(m_options.m_filename, true); BreakpointIDList new_bps; - Error error = target->CreateBreakpointsFromFile(input_spec, - m_options.m_names, new_bps); + Status error = target->CreateBreakpointsFromFile( + input_spec, m_options.m_names, new_bps); if (!error.Success()) { result.AppendError(error.AsCString()); @@ -2223,9 +2223,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -2281,7 +2281,7 @@ protected: return false; } } - Error error = target->SerializeBreakpointsToFile( + Status error = target->SerializeBreakpointsToFile( FileSpec(m_options.m_filename, true), valid_bp_ids, m_options.m_append); if (!error.Success()) { result.AppendErrorWithFormat("error serializing breakpoints: %s.", diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 5e4ee0b..de49119 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -19,6 +19,7 @@ #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/State.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" @@ -280,9 +281,9 @@ are no syntax errors may indicate that a function was declared but never called. ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -510,9 +511,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp index 04050e3..7ba8ab9 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectBugreport.cpp @@ -84,7 +84,7 @@ protected: open_options |= File::eOpenOptionTruncate; StreamFileSP outfile_stream = std::make_shared<StreamFile>(); - Error error = outfile_stream->GetFile().Open(path, open_options); + Status error = outfile_stream->GetFile().Open(path, open_options); if (error.Fail()) { result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n", path, append ? "append" : "write", diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp index aa07c10..c9d71a6 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectCommands.cpp @@ -17,7 +17,7 @@ #include "CommandObjectHelp.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/StringList.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandHistory.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -28,6 +28,7 @@ #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/ScriptInterpreter.h" +#include "lldb/Utility/StringList.h" using namespace lldb; using namespace lldb_private; @@ -49,7 +50,11 @@ class CommandObjectCommandsHistory : public CommandObjectParsed { public: CommandObjectCommandsHistory(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "command history", - "Dump the history of commands in this session.", + "Dump the history of commands in this session.\n" + "Commands in the history list can be run again " + "using \"!<INDEX>\". \"!-<OFFSET>\" will re-run " + "the command that is <OFFSET> commands from the end" + " of the list (counting the current command).", nullptr), m_options() {} @@ -66,9 +71,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -256,9 +261,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -366,9 +371,9 @@ protected: return llvm::makeArrayRef(g_alias_options); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = GetDefinitions()[option_idx].short_option; std::string option_str(option_value); @@ -574,7 +579,7 @@ protected: if (!ParseOptions(args, result)) return false; - Error error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); + Status error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -1025,7 +1030,7 @@ protected: bool check_only = false; for (size_t i = 0; i < num_lines; ++i) { llvm::StringRef bytes_strref(lines[i]); - Error error = AppendRegexSubstitution(bytes_strref, check_only); + Status error = AppendRegexSubstitution(bytes_strref, check_only); if (error.Fail()) { if (!m_interpreter.GetDebugger() .GetCommandInterpreter() @@ -1053,7 +1058,7 @@ protected: return false; } - Error error; + Status error; auto name = command[0].ref; m_regex_cmd_ap = llvm::make_unique<CommandObjectRegexCommand>( m_interpreter, name, m_options.GetHelp(), m_options.GetSyntax(), 10, 0, @@ -1096,9 +1101,9 @@ protected: return result.Succeeded(); } - Error AppendRegexSubstitution(const llvm::StringRef ®ex_sed, - bool check_only) { - Error error; + Status AppendRegexSubstitution(const llvm::StringRef ®ex_sed, + bool check_only) { + Status error; if (!m_regex_cmd_ap) { error.SetErrorStringWithFormat( @@ -1210,9 +1215,9 @@ private: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1306,7 +1311,7 @@ protected: CommandReturnObject &result) override { ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); - Error error; + Status error; result.SetStatus(eReturnStatusInvalid); @@ -1395,7 +1400,7 @@ protected: CommandReturnObject &result) override { ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); - Error error; + Status error; result.SetStatus(eReturnStatusInvalid); @@ -1482,9 +1487,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1529,7 +1534,7 @@ protected: } for (auto &entry : command.entries()) { - Error error; + Status error; const bool init_session = true; // FIXME: this is necessary because CommandObject::CheckRequirements() @@ -1614,9 +1619,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp index fa3a144..5d0f241 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -16,7 +16,7 @@ #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" #include "lldb/Core/SourceManager.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -71,10 +71,10 @@ CommandObjectDisassemble::CommandOptions::CommandOptions() CommandObjectDisassemble::CommandOptions::~CommandOptions() = default; -Error CommandObjectDisassemble::CommandOptions::SetOptionValue( +Status CommandObjectDisassemble::CommandOptions::SetOptionValue( uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) { - Error error; + Status error; const int short_option = m_getopt_table[option_idx].val; @@ -224,11 +224,11 @@ void CommandObjectDisassemble::CommandOptions::OptionParsingStarting( some_location_specified = false; } -Error CommandObjectDisassemble::CommandOptions::OptionParsingFinished( +Status CommandObjectDisassemble::CommandOptions::OptionParsingFinished( ExecutionContext *execution_context) { if (!some_location_specified) current_function = true; - return Error(); + return Status(); } llvm::ArrayRef<OptionDefinition> diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.h index db89aa2..8ca3900 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.h +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectDisassemble.h @@ -32,8 +32,8 @@ public: ~CommandOptions() override; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override; void OptionParsingStarting(ExecutionContext *execution_context) override; @@ -49,7 +49,7 @@ public: return flavor_string.c_str(); } - Error OptionParsingFinished(ExecutionContext *execution_context) override; + Status OptionParsingFinished(ExecutionContext *execution_context) override; bool show_mixed; // Show mixed source/assembly bool show_bytes; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp index cfb3a6d..b6e0016 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp @@ -24,7 +24,7 @@ #include "lldb/Expression/REPL.h" #include "lldb/Expression/UserExpression.h" #include "lldb/Host/Host.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" @@ -69,10 +69,10 @@ static OptionDefinition g_expression_options[] = { // clang-format on }; -Error CommandObjectExpression::CommandOptions::SetOptionValue( +Status CommandObjectExpression::CommandOptions::SetOptionValue( uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) { - Error error; + Status error; const int short_option = GetDefinitions()[option_idx].short_option; @@ -295,15 +295,15 @@ CommandObjectExpression::~CommandObjectExpression() = default; Options *CommandObjectExpression::GetOptions() { return &m_option_group; } -static lldb_private::Error +static lldb_private::Status CanBeUsedForElementCountPrinting(ValueObject &valobj) { CompilerType type(valobj.GetCompilerType()); CompilerType pointee; if (!type.IsPointerType(&pointee)) - return Error("as it does not refer to a pointer"); + return Status("as it does not refer to a pointer"); if (pointee.IsVoidType()) - return Error("as it refers to a pointer to void"); - return Error(); + return Status("as it refers to a pointer to void"); + return Status(); } bool CommandObjectExpression::EvaluateExpression(const char *expr, @@ -384,7 +384,7 @@ bool CommandObjectExpression::EvaluateExpression(const char *expr, result_valobj_sp->SetFormat(format); if (m_varobj_options.elem_count > 0) { - Error error(CanBeUsedForElementCountPrinting(*result_valobj_sp)); + Status error(CanBeUsedForElementCountPrinting(*result_valobj_sp)); if (error.Fail()) { result->AppendErrorWithFormat( "expression cannot be used with --element-count %s\n", @@ -533,7 +533,7 @@ bool CommandObjectExpression::DoExecute(const char *command, if (!ParseOptions(args, result)) return false; - Error error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); + Status error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -564,7 +564,7 @@ bool CommandObjectExpression::DoExecute(const char *command, // interpreter, // so just push one bool initialize = false; - Error repl_error; + Status repl_error; REPLSP repl_sp(target->GetREPL( repl_error, m_command_options.language, nullptr, false)); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.h index 7c21adc..0cf2a72 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.h +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectExpression.h @@ -34,8 +34,8 @@ public: llvm::ArrayRef<OptionDefinition> GetDefinitions() override; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override; void OptionParsingStarting(ExecutionContext *execution_context) override; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp index 5a35054..0bcc350 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp @@ -17,15 +17,13 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StreamString.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/Host.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -47,6 +45,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; @@ -77,9 +77,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'r': @@ -192,14 +192,13 @@ protected: return false; } - const bool qualify_cxx_base_classes = false; - DumpValueObjectOptions::DeclPrintingHelper helper = - [&valobj_sp, qualify_cxx_base_classes]( - ConstString type, ConstString var, - const DumpValueObjectOptions &opts, Stream &stream) -> bool { + DumpValueObjectOptions::DeclPrintingHelper helper = [&valobj_sp]( + ConstString type, ConstString var, const DumpValueObjectOptions &opts, + Stream &stream) -> bool { const ValueObject::GetExpressionPathFormat format = ValueObject:: GetExpressionPathFormat::eGetExpressionPathFormatHonorPointers; + const bool qualify_cxx_base_classes = false; valobj_sp->GetExpressionPath(stream, qualify_cxx_base_classes, format); stream.PutCString(" ="); return true; @@ -264,9 +263,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'r': @@ -605,7 +604,7 @@ protected: } else // No regex, either exact variable names or variable // expressions. { - Error error; + Status error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess | @@ -656,42 +655,60 @@ protected: if (num_variables > 0) { for (size_t i = 0; i < num_variables; i++) { var_sp = variable_list->GetVariableAtIndex(i); - bool dump_variable = true; + switch (var_sp->GetScope()) { + case eValueTypeVariableGlobal: + if (!m_option_variable.show_globals) + continue; + break; + case eValueTypeVariableStatic: + if (!m_option_variable.show_globals) + continue; + break; + case eValueTypeVariableArgument: + if (!m_option_variable.show_args) + continue; + break; + case eValueTypeVariableLocal: + if (!m_option_variable.show_locals) + continue; + break; + default: + continue; + break; + } std::string scope_string; - if (dump_variable && m_option_variable.show_scope) + if (m_option_variable.show_scope) scope_string = GetScopeString(var_sp).str(); - if (dump_variable) { - // Use the variable object code to make sure we are - // using the same APIs as the public API will be - // using... - valobj_sp = frame->GetValueObjectForFrameVariable( - var_sp, m_varobj_options.use_dynamic); - if (valobj_sp) { - // When dumping all variables, don't print any variables - // that are not in scope to avoid extra unneeded output - if (valobj_sp->IsInScope()) { - if (!valobj_sp->GetTargetSP() - ->GetDisplayRuntimeSupportValues() && - valobj_sp->IsRuntimeSupportValue()) - continue; - - if (!scope_string.empty()) - s.PutCString(scope_string); - - if (m_option_variable.show_decl && - var_sp->GetDeclaration().GetFile()) { - var_sp->GetDeclaration().DumpStopContext(&s, false); - s.PutCString(": "); - } - - options.SetFormat(format); - options.SetVariableFormatDisplayLanguage( - valobj_sp->GetPreferredDisplayLanguage()); - options.SetRootValueObjectName( - var_sp ? var_sp->GetName().AsCString() : nullptr); - valobj_sp->Dump(result.GetOutputStream(), options); + // Use the variable object code to make sure we are + // using the same APIs as the public API will be + // using... + valobj_sp = frame->GetValueObjectForFrameVariable( + var_sp, m_varobj_options.use_dynamic); + if (valobj_sp) { + // When dumping all variables, don't print any variables + // that are not in scope to avoid extra unneeded output + if (valobj_sp->IsInScope()) { + if (!valobj_sp->GetTargetSP() + ->GetDisplayRuntimeSupportValues() && + valobj_sp->IsRuntimeSupportValue()) + continue; + + if (!scope_string.empty()) + s.PutCString(scope_string); + + if (m_option_variable.show_decl && + var_sp->GetDeclaration().GetFile()) { + var_sp->GetDeclaration().DumpStopContext(&s, false); + s.PutCString(": "); } + + options.SetFormat(format); + options.SetVariableFormatDisplayLanguage( + valobj_sp->GetPreferredDisplayLanguage()); + options.SetRootValueObjectName( + var_sp ? var_sp->GetName().AsCString() : nullptr); + valobj_sp->Dump(result.GetOutputStream(), options); } } } diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h b/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h index 721917a..f1f87f8 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectHelp.h @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/Options.h" @@ -45,9 +46,9 @@ public: ~CommandOptions() override {} - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp index 3fdd888..ef82d07 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectLog.cpp @@ -13,15 +13,9 @@ // Project includes #include "CommandObjectLog.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" -#include "lldb/Host/FileSpec.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -32,6 +26,11 @@ #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; @@ -41,13 +40,13 @@ static OptionDefinition g_log_options[] = { { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to." }, { LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." }, { LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." }, - { LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." }, { LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." }, { LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." }, { LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." }, { LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." }, { LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append a stack backtrace to each log line." }, { LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append to the log file instead of overwriting." }, + { LLDB_OPT_SET_1, false, "file-function",'F',OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend the names of files and function that generate the logs." }, // clang-format on }; @@ -94,9 +93,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -109,9 +108,6 @@ public: case 'v': log_options |= LLDB_LOG_OPTION_VERBOSE; break; - case 'g': - log_options |= LLDB_LOG_OPTION_DEBUG; - break; case 's': log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE; break; @@ -130,6 +126,9 @@ public: case 'a': log_options |= LLDB_LOG_OPTION_APPEND; break; + case 'F': + log_options |= LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION; + break; default: error.SetErrorStringWithFormat("unrecognized option '%c'", short_option); @@ -171,9 +170,14 @@ protected: m_options.log_file.GetPath(log_file, sizeof(log_file)); else log_file[0] = '\0'; + + std::string error; + llvm::raw_string_ostream error_stream(error); bool success = m_interpreter.GetDebugger().EnableLog( - channel.c_str(), args.GetConstArgumentVector(), log_file, - m_options.log_options, result.GetErrorStream()); + channel, args.GetArgumentArrayRef(), log_file, m_options.log_options, + error_stream); + result.GetErrorStream() << error_stream.str(); + if (success) result.SetStatus(eReturnStatusSuccessFinishNoResult); else @@ -227,25 +231,18 @@ protected: return false; } - Log::Callbacks log_callbacks; - const std::string channel = args[0].ref; args.Shift(); // Shift off the channel - if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) { - log_callbacks.disable(args.GetConstArgumentVector(), - &result.GetErrorStream()); + if (channel == "all") { + Log::DisableAllLogChannels(); result.SetStatus(eReturnStatusSuccessFinishNoResult); - } else if (channel == "all") { - Log::DisableAllLogChannels(&result.GetErrorStream()); } else { - LogChannelSP log_channel_sp(LogChannel::FindPlugin(channel.data())); - if (log_channel_sp) { - log_channel_sp->Disable(args.GetConstArgumentVector(), - &result.GetErrorStream()); + std::string error; + llvm::raw_string_ostream error_stream(error); + if (Log::DisableLogChannel(channel, args.GetArgumentArrayRef(), + error_stream)) result.SetStatus(eReturnStatusSuccessFinishNoResult); - } else - result.AppendErrorWithFormat("Invalid log channel '%s'.\n", - channel.data()); + result.GetErrorStream() << error_stream.str(); } return result.Succeeded(); } @@ -280,31 +277,20 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { + std::string output; + llvm::raw_string_ostream output_stream(output); if (args.empty()) { - Log::ListAllLogChannels(&result.GetOutputStream()); + Log::ListAllLogChannels(output_stream); result.SetStatus(eReturnStatusSuccessFinishResult); } else { - for (auto &entry : args.entries()) { - Log::Callbacks log_callbacks; - - if (Log::GetLogChannelCallbacks(ConstString(entry.ref), - log_callbacks)) { - log_callbacks.list_categories(&result.GetOutputStream()); - result.SetStatus(eReturnStatusSuccessFinishResult); - } else if (entry.ref == "all") { - Log::ListAllLogChannels(&result.GetOutputStream()); - result.SetStatus(eReturnStatusSuccessFinishResult); - } else { - LogChannelSP log_channel_sp(LogChannel::FindPlugin(entry.c_str())); - if (log_channel_sp) { - log_channel_sp->ListCategories(&result.GetOutputStream()); - result.SetStatus(eReturnStatusSuccessFinishNoResult); - } else - result.AppendErrorWithFormat("Invalid log channel '%s'.\n", - entry.c_str()); - } - } + bool success = true; + for (const auto &entry : args.entries()) + success = + success && Log::ListChannelCategories(entry.ref, output_stream); + if (success) + result.SetStatus(eReturnStatusSuccessFinishResult); } + result.GetOutputStream() << output_stream.str(); return result.Succeeded(); } }; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp index 49ae923..8f4c186 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectMemory.cpp @@ -17,15 +17,13 @@ // Project includes #include "CommandObjectMemory.h" #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataExtractor.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" -#include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -42,6 +40,9 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/StreamString.h" #include "lldb/lldb-private.h" @@ -73,9 +74,9 @@ public: return llvm::makeArrayRef(g_read_memory_options); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = g_read_memory_options[option_idx].short_option; switch (short_option) { @@ -119,8 +120,8 @@ public: m_offset.Clear(); } - Error FinalizeSettings(Target *target, OptionGroupFormat &format_options) { - Error error; + Status FinalizeSettings(Target *target, OptionGroupFormat &format_options) { + Status error; OptionValueUInt64 &byte_size_value = format_options.GetByteSizeValue(); OptionValueUInt64 &count_value = format_options.GetCountValue(); const bool byte_size_option_set = byte_size_value.OptionWasSet(); @@ -377,7 +378,7 @@ protected: } CompilerType clang_ast_type; - Error error; + Status error; const char *view_as_type_cstr = m_memory_options.m_view_as_type.GetCurrentValue(); @@ -715,7 +716,7 @@ protected: while (item_count < count) { std::string buffer; buffer.resize(item_byte_size + 1, 0); - Error error; + Status error; size_t read = target->ReadCStringFromMemory(data_addr, &buffer[0], item_byte_size + 1, error); if (error.Fail()) { @@ -861,10 +862,10 @@ protected: } assert(output_stream); - size_t bytes_dumped = - data.Dump(output_stream, 0, format, item_byte_size, item_count, - num_per_line / target->GetArchitecture().GetDataByteSize(), - addr, 0, 0, exe_scope); + size_t bytes_dumped = DumpDataExtractor( + data, output_stream, 0, format, item_byte_size, item_count, + num_per_line / target->GetArchitecture().GetDataByteSize(), addr, 0, 0, + exe_scope); m_next_addr = addr + bytes_dumped; output_stream->EOL(); return true; @@ -908,9 +909,9 @@ public: return llvm::makeArrayRef(g_memory_find_option_table); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = g_memory_find_option_table[option_idx].short_option; @@ -1007,7 +1008,7 @@ protected: return 0; uint8_t retval = 0; - Error error; + Status error; if (0 == m_process_sp->ReadMemory(m_base_addr + offset, &retval, 1, error)) { m_is_valid = false; @@ -1034,7 +1035,7 @@ protected: return false; } - Error error; + Status error; lldb::addr_t low_addr = Args::StringToAddress(&m_exe_ctx, command[0].ref, LLDB_INVALID_ADDRESS, &error); if (low_addr == LLDB_INVALID_ADDRESS || error.Fail()) { @@ -1131,10 +1132,10 @@ protected: DataExtractor data(dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), process->GetByteOrder(), process->GetAddressByteSize()); - data.Dump(&result.GetOutputStream(), 0, lldb::eFormatBytesWithASCII, 1, - dumpbuffer.GetByteSize(), 16, - found_location + m_memory_options.m_offset.GetCurrentValue(), - 0, 0); + DumpDataExtractor( + data, &result.GetOutputStream(), 0, lldb::eFormatBytesWithASCII, 1, + dumpbuffer.GetByteSize(), 16, + found_location + m_memory_options.m_offset.GetCurrentValue(), 0, 0); result.GetOutputStream().EOL(); } @@ -1201,9 +1202,9 @@ public: return llvm::makeArrayRef(g_memory_write_option_table); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = g_memory_write_option_table[option_idx].short_option; @@ -1343,7 +1344,7 @@ protected: OptionValueUInt64 &byte_size_value = m_format_options.GetByteSizeValue(); size_t item_byte_size = byte_size_value.GetCurrentValue(); - Error error; + Status error; lldb::addr_t addr = Args::StringToAddress(&m_exe_ctx, command[0].ref, LLDB_INVALID_ADDRESS, &error); @@ -1358,12 +1359,13 @@ protected: size_t length = SIZE_MAX; if (item_byte_size > 1) length = item_byte_size; - lldb::DataBufferSP data_sp(m_memory_options.m_infile.ReadFileContents( - m_memory_options.m_infile_offset, length)); + auto data_sp = DataBufferLLVM::CreateSliceFromPath( + m_memory_options.m_infile.GetPath(), length, + m_memory_options.m_infile_offset); if (data_sp) { length = data_sp->GetByteSize(); if (length > 0) { - Error error; + Status error; size_t bytes_written = process->WriteMemory(addr, data_sp->GetBytes(), length, error); @@ -1441,8 +1443,16 @@ protected: case eFormatHex: case eFormatHexUppercase: case eFormatPointer: + { // Decode hex bytes - if (entry.ref.getAsInteger(16, uval64)) { + // Be careful, getAsInteger with a radix of 16 rejects "0xab" so we + // have to special case that: + bool success = false; + if (entry.ref.startswith("0x")) + success = !entry.ref.getAsInteger(0, uval64); + if (!success) + success = !entry.ref.getAsInteger(16, uval64); + if (!success) { result.AppendErrorWithFormat( "'%s' is not a valid hex string value.\n", entry.c_str()); result.SetStatus(eReturnStatusFailed); @@ -1457,7 +1467,7 @@ protected: } buffer.PutMaxHex64(uval64, item_byte_size); break; - + } case eFormatBoolean: uval64 = Args::StringToBoolean(entry.ref, false, &success); if (!success) { @@ -1496,7 +1506,7 @@ protected: // Include the NULL for C strings... if (m_format_options.GetFormat() == eFormatCString) ++len; - Error error; + Status error; if (process->WriteMemory(addr, entry.c_str(), len, error) == len) { addr += len; } else { @@ -1564,7 +1574,7 @@ protected: } if (!buffer.GetString().empty()) { - Error error; + Status error; if (process->WriteMemory(addr, buffer.GetString().data(), buffer.GetString().size(), error) == buffer.GetString().size()) @@ -1631,7 +1641,7 @@ protected: return false; } - Error error; + Status error; lldb::addr_t addr = Args::StringToAddress(&m_exe_ctx, command[0].ref, LLDB_INVALID_ADDRESS, &error); @@ -1689,7 +1699,7 @@ protected: bool DoExecute(Args &command, CommandReturnObject &result) override { ProcessSP process_sp = m_exe_ctx.GetProcessSP(); if (process_sp) { - Error error; + Status error; lldb::addr_t load_addr = m_prev_end_addr; m_prev_end_addr = LLDB_INVALID_ADDRESS; diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp index 562572b..5fa851f 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlatform.cpp @@ -13,10 +13,10 @@ // Other libraries and framework includes // Project includes #include "CommandObjectPlatform.h" -#include "lldb/Core/DataExtractor.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -27,9 +27,10 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/Utils.h" +#include "lldb/Utility/DataExtractor.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/Threading.h" using namespace lldb; using namespace lldb_private; @@ -84,10 +85,10 @@ public: ~OptionPermissions() override = default; - lldb_private::Error + lldb_private::Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { - Error error; + Status error; char short_option = (char)GetDefinitions()[option_idx].short_option; switch (short_option) { case 'v': { @@ -199,7 +200,7 @@ protected: if (platform_name && platform_name[0]) { const bool select = true; m_platform_options.SetPlatformName(platform_name); - Error error; + Status error; ArchSpec platform_arch; PlatformSP platform_sp(m_platform_options.CreatePlatformWithOptions( m_interpreter, ArchSpec(), select, error, platform_arch)); @@ -328,7 +329,7 @@ protected: PlatformSP platform_sp( m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { - Error error(platform_sp->ConnectRemote(args)); + Status error(platform_sp->ConnectRemote(args)); if (error.Success()) { platform_sp->GetStatus(ostrm); result.SetStatus(eReturnStatusSuccessFinishResult); @@ -381,7 +382,7 @@ protected: m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { if (args.GetArgumentCount() == 0) { - Error error; + Status error; if (platform_sp->IsConnected()) { // Cache the instance name if there is one since we are @@ -497,7 +498,8 @@ public: else mode = lldb::eFilePermissionsUserRWX | lldb::eFilePermissionsGroupRWX | lldb::eFilePermissionsWorldRX; - Error error = platform_sp->MakeDirectory(FileSpec{cmd_line, false}, mode); + Status error = + platform_sp->MakeDirectory(FileSpec{cmd_line, false}, mode); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -538,7 +540,7 @@ public: PlatformSP platform_sp( m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { - Error error; + Status error; std::string cmd_line; args.GetCommandString(cmd_line); mode_t perms; @@ -598,7 +600,7 @@ public: args.GetCommandString(cmd_line); const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX); - Error error; + Status error; bool success = platform_sp->CloseFile(fd, error); if (success) { result.AppendMessageWithFormat("file %" PRIu64 " closed.\n", fd); @@ -645,7 +647,7 @@ public: const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX); std::string buffer(m_options.m_count, 0); - Error error; + Status error; uint32_t retcode = platform_sp->ReadFile( fd, m_options.m_offset, &buffer[0], m_options.m_count, error); result.AppendMessageWithFormat("Return = %d\n", retcode); @@ -667,9 +669,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; char short_option = (char)m_getopt_table[option_idx].val; switch (short_option) { @@ -737,7 +739,7 @@ public: if (platform_sp) { std::string cmd_line; args.GetCommandString(cmd_line); - Error error; + Status error; const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX); uint32_t retcode = @@ -761,9 +763,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; char short_option = (char)m_getopt_table[option_idx].val; switch (short_option) { @@ -888,8 +890,8 @@ public: if (platform_sp) { const char *remote_file_path = args.GetArgumentAtIndex(0); const char *local_file_path = args.GetArgumentAtIndex(1); - Error error = platform_sp->GetFile(FileSpec(remote_file_path, false), - FileSpec(local_file_path, false)); + Status error = platform_sp->GetFile(FileSpec(remote_file_path, false), + FileSpec(local_file_path, false)); if (error.Success()) { result.AppendMessageWithFormat( "successfully get-file from %s (remote) to %s (host)\n", @@ -998,7 +1000,7 @@ public: PlatformSP platform_sp( m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { - Error error(platform_sp->PutFile(src_fs, dst_fs)); + Status error(platform_sp->PutFile(src_fs, dst_fs)); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishNoResult); } else { @@ -1042,7 +1044,7 @@ protected: } if (platform_sp) { - Error error; + Status error; const size_t argc = args.GetArgumentCount(); Target *target = m_exe_ctx.GetTargetPtr(); Module *exe_module = target->GetExecutableModulePointer(); @@ -1152,7 +1154,7 @@ protected: } if (platform_sp) { - Error error; + Status error; if (args.GetArgumentCount() == 0) { if (platform_sp) { Stream &ostrm = result.GetOutputStream(); @@ -1182,21 +1184,21 @@ protected: m_options.match_info.GetProcessInfo().GetName(); if (match_name && match_name[0]) { switch (m_options.match_info.GetNameMatchType()) { - case eNameMatchIgnore: + case NameMatch::Ignore: break; - case eNameMatchEquals: + case NameMatch::Equals: match_desc = "matched"; break; - case eNameMatchContains: + case NameMatch::Contains: match_desc = "contained"; break; - case eNameMatchStartsWith: + case NameMatch::StartsWith: match_desc = "started with"; break; - case eNameMatchEndsWith: + case NameMatch::EndsWith: match_desc = "ended with"; break; - case eNameMatchRegularExpression: + case NameMatch::RegularExpression: match_desc = "matched the regular expression"; break; } @@ -1249,8 +1251,8 @@ protected: public: CommandOptions() : Options(), match_info(), show_args(false), verbose(false) { - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { PosixPlatformCommandOptionValidator *posix_validator = new PosixPlatformCommandOptionValidator(); for (auto &Option : g_platform_process_list_options) { @@ -1270,9 +1272,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; bool success = false; @@ -1342,31 +1344,31 @@ protected: case 'n': match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg, false); - match_info.SetNameMatchType(eNameMatchEquals); + match_info.SetNameMatchType(NameMatch::Equals); break; case 'e': match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg, false); - match_info.SetNameMatchType(eNameMatchEndsWith); + match_info.SetNameMatchType(NameMatch::EndsWith); break; case 's': match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg, false); - match_info.SetNameMatchType(eNameMatchStartsWith); + match_info.SetNameMatchType(NameMatch::StartsWith); break; case 'c': match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg, false); - match_info.SetNameMatchType(eNameMatchContains); + match_info.SetNameMatchType(NameMatch::Contains); break; case 'r': match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg, false); - match_info.SetNameMatchType(eNameMatchRegularExpression); + match_info.SetNameMatchType(NameMatch::RegularExpression); break; case 'A': @@ -1448,7 +1450,7 @@ protected: if (platform_sp) { const size_t argc = args.GetArgumentCount(); if (argc > 0) { - Error error; + Status error; if (platform_sp->IsConnected()) { Stream &ostrm = result.GetOutputStream(); @@ -1514,9 +1516,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; char short_option = (char)m_getopt_table[option_idx].val; switch (short_option) { case 'p': { @@ -1585,7 +1587,7 @@ public: if (partial_name) { match_info.GetProcessInfo().GetExecutableFile().SetFile( partial_name, false); - match_info.SetNameMatchType(eNameMatchStartsWith); + match_info.SetNameMatchType(NameMatch::StartsWith); } platform_sp->FindProcesses(match_info, process_infos); const uint32_t num_matches = process_infos.GetSize(); @@ -1623,7 +1625,7 @@ public: PlatformSP platform_sp( m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { - Error err; + Status err; ProcessSP remote_process_sp = platform_sp->Attach( m_options.attach_info, m_interpreter.GetDebugger(), nullptr, err); if (err.Fail()) { @@ -1699,9 +1701,9 @@ public: return llvm::makeArrayRef(g_platform_shell_options); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const char short_option = (char)GetDefinitions()[option_idx].short_option; @@ -1781,7 +1783,7 @@ public: PlatformSP platform_sp( m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); - Error error; + Status error; if (platform_sp) { FileSpec working_dir{}; std::string output; @@ -1860,7 +1862,7 @@ public: return false; } - Error error = platform_sp->Install(src, dst); + Status error = platform_sp->Install(src, dst); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishNoResult); } else { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp index 7ae968b..7e1b7f6 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectPlugin.cpp @@ -68,7 +68,7 @@ protected: return false; } - Error error; + Status error; FileSpec dylib_fspec(command[0].ref, true); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp index 5b7f134..9fbdd76 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp @@ -19,6 +19,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Host/Host.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -73,7 +74,7 @@ protected: } else { if (process->GetShouldDetach()) { bool keep_stopped = false; - Error detach_error(process->Detach(keep_stopped)); + Status detach_error(process->Detach(keep_stopped)); if (detach_error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); process = nullptr; @@ -84,7 +85,7 @@ protected: result.SetStatus(eReturnStatusFailed); } } else { - Error destroy_error(process->Destroy(false)); + Status destroy_error(process->Destroy(false)); if (destroy_error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); process = nullptr; @@ -230,7 +231,7 @@ protected: } StreamString stream; - Error error = target->Launch(m_options.launch_info, &stream); + Status error = target->Launch(m_options.launch_info, &stream); if (error.Success()) { ProcessSP process_sp(target->GetProcessSP()); @@ -337,9 +338,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'c': @@ -416,7 +417,7 @@ public: if (partial_name) { match_info.GetProcessInfo().GetExecutableFile().SetFile( partial_name, false); - match_info.SetNameMatchType(eNameMatchStartsWith); + match_info.SetNameMatchType(NameMatch::StartsWith); } platform_sp->FindProcesses(match_info, process_infos); const size_t num_matches = process_infos.GetSize(); @@ -469,7 +470,7 @@ protected: if (target == nullptr) { // If there isn't a current target create one. TargetSP new_target_sp; - Error error; + Status error; error = m_interpreter.GetDebugger().GetTargetList().CreateTarget( m_interpreter.GetDebugger(), "", "", false, @@ -602,9 +603,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'i': @@ -686,7 +687,7 @@ protected: const uint32_t iohandler_id = process->GetIOHandlerID(); StreamString stream; - Error error; + Status error; if (synchronous_execution) error = process->ResumeSynchronous(&stream); else @@ -750,9 +751,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -815,7 +816,7 @@ protected: else keep_stopped = false; - Error error(process->Detach(keep_stopped)); + Status error(process->Detach(keep_stopped)); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -853,9 +854,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -918,7 +919,7 @@ protected: if (!m_options.plugin_name.empty()) plugin_name = m_options.plugin_name.c_str(); - Error error; + Status error; Debugger &debugger = m_interpreter.GetDebugger(); PlatformSP platform_sp = m_interpreter.GetPlatform(true); ProcessSP process_sp = platform_sp->ConnectProcess( @@ -982,9 +983,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'i': @@ -1032,7 +1033,7 @@ protected: Process *process = m_exe_ctx.GetProcessPtr(); for (auto &entry : command.entries()) { - Error error; + Status error; PlatformSP platform = process->GetTarget().GetPlatform(); llvm::StringRef image_path = entry.ref; uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN; @@ -1102,7 +1103,7 @@ protected: result.SetStatus(eReturnStatusFailed); break; } else { - Error error(process->GetTarget().GetPlatform()->UnloadImage( + Status error(process->GetTarget().GetPlatform()->UnloadImage( process, image_token)); if (error.Success()) { result.AppendMessageWithFormat( @@ -1168,7 +1169,7 @@ protected: command.GetArgumentAtIndex(0)); result.SetStatus(eReturnStatusFailed); } else { - Error error(process->Signal(signo)); + Status error(process->Signal(signo)); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -1214,7 +1215,7 @@ protected: if (command.GetArgumentCount() == 0) { bool clear_thread_plans = true; - Error error(process->Halt(clear_thread_plans)); + Status error(process->Halt(clear_thread_plans)); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -1257,7 +1258,7 @@ protected: } if (command.GetArgumentCount() == 0) { - Error error(process->Destroy(true)); + Status error(process->Destroy(true)); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -1297,7 +1298,7 @@ protected: if (process_sp) { if (command.GetArgumentCount() == 1) { FileSpec output_file(command.GetArgumentAtIndex(0), false); - Error error = PluginManager::SaveCore(process_sp, output_file); + Status error = PluginManager::SaveCore(process_sp, output_file); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -1376,9 +1377,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp index 0ba6526..d535742 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectRegister.cpp @@ -7,17 +7,11 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "llvm/ADT/STLExtras.h" - -// Project includes #include "CommandObjectRegister.h" -#include "lldb/Core/DataExtractor.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -31,6 +25,8 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/DataExtractor.h" +#include "llvm/Support/Errno.h" using namespace lldb; using namespace lldb_private; @@ -177,8 +173,8 @@ protected: if (set_idx < reg_ctx->GetRegisterSetCount()) { if (!DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx)) { if (errno) - result.AppendErrorWithFormat("register read failed: %s\n", - strerror(errno)); + result.AppendErrorWithFormatv("register read failed: {0}\n", + llvm::sys::StrError()); else result.AppendError("unknown error while reading registers.\n"); result.SetStatus(eReturnStatusFailed); @@ -256,9 +252,9 @@ protected: alternate_name.Clear(); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = GetDefinitions()[option_idx].short_option; switch (short_option) { case 's': { @@ -366,7 +362,7 @@ protected: if (reg_info) { RegisterValue reg_value; - Error error(reg_value.SetValueFromString(reg_info, value_str)); + Status error(reg_value.SetValueFromString(reg_info, value_str)); if (error.Success()) { if (reg_ctx->WriteRegister(reg_info, reg_value)) { // Toss all frames and anything else in the thread diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp index 23fdcb9..d42466c 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSettings.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/StringRef.h" // Project includes +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -101,9 +102,9 @@ insert-before or insert-after."); ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -166,7 +167,7 @@ insert-before or insert-after."); // Complete setting value const char *setting_var_name = input.GetArgumentAtIndex(setting_var_idx); - Error error; + Status error; lldb::OptionValueSP value_sp( m_interpreter.GetDebugger().GetPropertyValue( &m_exe_ctx, setting_var_name, false, error)); @@ -210,7 +211,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, false, false); - Error error; + Status error; if (m_options.m_global) { error = m_interpreter.GetDebugger().SetPropertyValue( nullptr, eVarSetOperationAssign, var_name, var_value_cstr); @@ -295,7 +296,7 @@ protected: if (!args.empty()) { for (const auto &arg : args) { - Error error(m_interpreter.GetDebugger().DumpPropertyValue( + Status error(m_interpreter.GetDebugger().DumpPropertyValue( &m_exe_ctx, result.GetOutputStream(), arg.ref, OptionValue::eDumpGroupValue)); if (error.Success()) { @@ -493,7 +494,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Error error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(m_interpreter.GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationRemove, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -601,7 +602,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Error error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(m_interpreter.GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationReplace, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -715,7 +716,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Error error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(m_interpreter.GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationInsertBefore, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -826,7 +827,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Error error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(m_interpreter.GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationInsertAfter, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -928,7 +929,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Error error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(m_interpreter.GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationAppend, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -1005,7 +1006,7 @@ protected: return false; } - Error error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(m_interpreter.GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef())); if (error.Fail()) { result.AppendError(error.AsCString()); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp index 6ff3208..f3c92b9 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp @@ -18,8 +18,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/SourceManager.h" -#include "lldb/Host/FileSpec.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -31,6 +30,7 @@ #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/TargetList.h" +#include "lldb/Utility/FileSpec.h" using namespace lldb; using namespace lldb_private; @@ -59,9 +59,9 @@ class CommandObjectSourceInfo : public CommandObjectParsed { ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = GetDefinitions()[option_idx].short_option; switch (short_option) { case 'l': @@ -683,9 +683,9 @@ class CommandObjectSourceList : public CommandObjectParsed { ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = GetDefinitions()[option_idx].short_option; switch (short_option) { case 'l': diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp index d2e53aa..a80acf1 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp @@ -16,9 +16,9 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Section.h" #include "lldb/Core/State.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" #include "lldb/Host/Symbols.h" #include "lldb/Interpreter/Args.h" @@ -49,6 +49,9 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/Timer.h" + +#include "llvm/Support/FileSystem.h" // C Includes // C++ Includes @@ -266,8 +269,8 @@ protected: } const char *file_path = command.GetArgumentAtIndex(0); - Timer scoped_timer(LLVM_PRETTY_FUNCTION, "(lldb) target create '%s'", - file_path); + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); + Timer scoped_timer(func_cat, "(lldb) target create '%s'", file_path); FileSpec file_spec; if (file_path) @@ -281,7 +284,7 @@ protected: llvm::StringRef arch_cstr = m_arch_option.GetArchitectureName(); const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue(); - Error error(debugger.GetTargetList().CreateTarget( + Status error(debugger.GetTargetList().CreateTarget( debugger, file_path, arch_cstr, get_dependent_files, nullptr, target_sp)); @@ -300,7 +303,7 @@ protected: if (file_spec && file_spec.Exists()) { // if the remote file does not exist, push it there if (!platform_sp->GetFileExists(remote_file)) { - Error err = platform_sp->PutFile(file_spec, remote_file); + Status err = platform_sp->PutFile(file_spec, remote_file); if (err.Fail()) { result.AppendError(err.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -321,7 +324,7 @@ protected: } if (file_path) { // copy the remote file to the local file - Error err = platform_sp->GetFile(remote_file, file_spec); + Status err = platform_sp->GetFile(remote_file, file_spec); if (err.Fail()) { result.AppendError(err.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -836,7 +839,7 @@ protected: matches = target->GetImages().FindGlobalVariables( regex, true, UINT32_MAX, variable_list); } else { - Error error(Variable::GetValuesForVariableExpressionPath( + Status error(Variable::GetValuesForVariableExpressionPath( arg, m_exe_ctx.GetBestExecutionContextScope(), GetVariableCallback, target, variable_list, valobj_list)); matches = variable_list.GetSize(); @@ -1990,9 +1993,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -2512,7 +2515,7 @@ protected: m_symbol_file.GetOptionValue().GetCurrentValue(); if (!module_spec.GetArchitecture().IsValid()) module_spec.GetArchitecture() = target->GetArchitecture(); - Error error; + Status error; ModuleSP module_sp(target->GetSharedModule(module_spec, &error)); if (!module_sp) { const char *error_cstr = error.AsCString(); @@ -2567,6 +2570,12 @@ public: m_option_group(), m_file_option(LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeName, "Fullpath or basename for module to load.", ""), + m_load_option(LLDB_OPT_SET_1, false, "load", 'l', + "Write file contents to the memory.", false, true), + m_pc_option(LLDB_OPT_SET_1, false, "--set-pc-to-entry", 'p', + "Set PC to the entry point." + " Only applicable with '--load' option.", + false, true), m_slide_option(LLDB_OPT_SET_1, false, "slide", 's', 0, eArgTypeOffset, "Set the load address for all sections to be the " "virtual address in the file plus the offset.", @@ -2574,6 +2583,8 @@ public: m_option_group.Append(&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append(&m_file_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Append(&m_load_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Append(&m_pc_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append(&m_slide_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Finalize(); } @@ -2585,6 +2596,8 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + const bool load = m_load_option.GetOptionValue().GetCurrentValue(); + const bool set_pc = m_pc_option.GetOptionValue().GetCurrentValue(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -2594,6 +2607,21 @@ protected: const size_t argc = args.GetArgumentCount(); ModuleSpec module_spec; bool search_using_module_spec = false; + + // Allow "load" option to work without --file or --uuid + // option. + if (load) { + if (!m_file_option.GetOptionValue().OptionWasSet() && + !m_uuid_option_group.GetOptionValue().OptionWasSet()) { + ModuleList &module_list = target->GetImages(); + if (module_list.GetSize() == 1) { + search_using_module_spec = true; + module_spec.GetFileSpec() = + module_list.GetModuleAtIndex(0)->GetFileSpec(); + } + } + } + if (m_file_option.GetOptionValue().OptionWasSet()) { search_using_module_spec = true; const char *arg_cstr = m_file_option.GetOptionValue().GetCurrentValue(); @@ -2721,6 +2749,13 @@ protected: if (process) process->Flush(); } + if (load) { + Status error = module->LoadInMemory(*target, set_pc); + if (error.Fail()) { + result.AppendError(error.AsCString()); + return false; + } + } } else { module->GetFileSpec().GetPath(path, sizeof(path)); result.AppendErrorWithFormat( @@ -2783,6 +2818,8 @@ protected: OptionGroupOptions m_option_group; OptionGroupUUID m_uuid_option_group; OptionGroupString m_file_option; + OptionGroupBoolean m_load_option; + OptionGroupBoolean m_pc_option; OptionGroupUInt64 m_slide_option; }; @@ -2820,9 +2857,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; if (short_option == 'g') { @@ -3183,9 +3220,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; @@ -3389,6 +3426,23 @@ protected: result.GetOutputStream().Printf("\n"); } + if (UnwindPlanSP plan_sp = + func_unwinders_sp->GetDebugFrameUnwindPlan(*target, 0)) { + result.GetOutputStream().Printf("debug_frame UnwindPlan:\n"); + plan_sp->Dump(result.GetOutputStream(), thread.get(), + LLDB_INVALID_ADDRESS); + result.GetOutputStream().Printf("\n"); + } + + if (UnwindPlanSP plan_sp = + func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target, + *thread, 0)) { + result.GetOutputStream().Printf("debug_frame augmented UnwindPlan:\n"); + plan_sp->Dump(result.GetOutputStream(), thread.get(), + LLDB_INVALID_ADDRESS); + result.GetOutputStream().Printf("\n"); + } + UnwindPlanSP arm_unwind_sp = func_unwinders_sp->GetArmUnwindUnwindPlan(*target, 0); if (arm_unwind_sp) { @@ -3483,9 +3537,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; @@ -4077,7 +4131,7 @@ protected: // Make sure we load any scripting resources that may be embedded // in the debug info files in case the platform supports that. - Error error; + Status error; StreamString feedback_stream; module_sp->LoadScriptingResourceInTarget(target, error, &feedback_stream); @@ -4102,20 +4156,21 @@ protected: module_sp->SetSymbolFileFileSpec(FileSpec()); } + namespace fs = llvm::sys::fs; if (module_spec.GetUUID().IsValid()) { StreamString ss_symfile_uuid; module_spec.GetUUID().Dump(&ss_symfile_uuid); result.AppendErrorWithFormat( "symbol file '%s' (%s) does not match any existing module%s\n", symfile_path, ss_symfile_uuid.GetData(), - (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular) + !fs::is_regular_file(symbol_fspec.GetPath()) ? "\n please specify the full path to the symbol file" : ""); } else { result.AppendErrorWithFormat( "symbol file '%s' does not match any existing module%s\n", symfile_path, - (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular) + !fs::is_regular_file(symbol_fspec.GetPath()) ? "\n please specify the full path to the symbol file" : ""); } @@ -4360,9 +4415,9 @@ public: return llvm::makeArrayRef(g_target_stop_hook_add_options); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp index 0c4072b..6a933df 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectThread.cpp @@ -17,6 +17,7 @@ #include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -41,10 +42,44 @@ using namespace lldb; using namespace lldb_private; //------------------------------------------------------------------------- -// CommandObjectThreadBacktrace +// CommandObjectIterateOverThreads //------------------------------------------------------------------------- class CommandObjectIterateOverThreads : public CommandObjectParsed { + + class UniqueStack { + + public: + UniqueStack(std::stack<lldb::addr_t> stack_frames, uint32_t thread_index_id) + : m_stack_frames(stack_frames) { + m_thread_index_ids.push_back(thread_index_id); + } + + void AddThread(uint32_t thread_index_id) const { + m_thread_index_ids.push_back(thread_index_id); + } + + const std::vector<uint32_t> &GetUniqueThreadIndexIDs() const { + return m_thread_index_ids; + } + + lldb::tid_t GetRepresentativeThread() const { + return m_thread_index_ids.front(); + } + + friend bool inline operator<(const UniqueStack &lhs, + const UniqueStack &rhs) { + return lhs.m_stack_frames < rhs.m_stack_frames; + } + + protected: + // Mark the thread index as mutable, as we don't care about it from a const + // perspective, we only care about m_stack_frames so we keep our std::set + // sorted. + mutable std::vector<uint32_t> m_thread_index_ids; + std::stack<lldb::addr_t> m_stack_frames; + }; + public: CommandObjectIterateOverThreads(CommandInterpreter &interpreter, const char *name, const char *help, @@ -56,11 +91,15 @@ public: bool DoExecute(Args &command, CommandReturnObject &result) override { result.SetStatus(m_success_return); + bool all_threads = false; if (command.GetArgumentCount() == 0) { Thread *thread = m_exe_ctx.GetThreadPtr(); if (!HandleOneThread(thread->GetID(), result)) return false; return result.Succeeded(); + } else if (command.GetArgumentCount() == 1) { + all_threads = ::strcmp(command.GetArgumentAtIndex(0), "all") == 0; + m_unique_stacks = ::strcmp(command.GetArgumentAtIndex(0), "unique") == 0; } // Use tids instead of ThreadSPs to prevent deadlocking problems which @@ -68,8 +107,7 @@ public: // code while iterating over the (locked) ThreadSP list. std::vector<lldb::tid_t> tids; - if (command.GetArgumentCount() == 1 && - ::strcmp(command.GetArgumentAtIndex(0), "all") == 0) { + if (all_threads || m_unique_stacks) { Process *process = m_exe_ctx.GetProcessPtr(); for (ThreadSP thread_sp : process->Threads()) @@ -107,15 +145,47 @@ public: } } - uint32_t idx = 0; - for (const lldb::tid_t &tid : tids) { - if (idx != 0 && m_add_return) - result.AppendMessage(""); + if (m_unique_stacks) { + // Iterate over threads, finding unique stack buckets. + std::set<UniqueStack> unique_stacks; + for (const lldb::tid_t &tid : tids) { + if (!BucketThread(tid, unique_stacks, result)) { + return false; + } + } - if (!HandleOneThread(tid, result)) - return false; + // Write the thread id's and unique call stacks to the output stream + Stream &strm = result.GetOutputStream(); + Process *process = m_exe_ctx.GetProcessPtr(); + for (const UniqueStack &stack : unique_stacks) { + // List the common thread ID's + const std::vector<uint32_t> &thread_index_ids = + stack.GetUniqueThreadIndexIDs(); + strm.Format("{0} thread(s) ", thread_index_ids.size()); + for (const uint32_t &thread_index_id : thread_index_ids) { + strm.Format("#{0} ", thread_index_id); + } + strm.EOL(); - ++idx; + // List the shared call stack for this set of threads + uint32_t representative_thread_id = stack.GetRepresentativeThread(); + ThreadSP thread = process->GetThreadList().FindThreadByIndexID( + representative_thread_id); + if (!HandleOneThread(thread->GetID(), result)) { + return false; + } + } + } else { + uint32_t idx = 0; + for (const lldb::tid_t &tid : tids) { + if (idx != 0 && m_add_return) + result.AppendMessage(""); + + if (!HandleOneThread(tid, result)) + return false; + + ++idx; + } } return result.Succeeded(); } @@ -133,7 +203,43 @@ protected: virtual bool HandleOneThread(lldb::tid_t, CommandReturnObject &result) = 0; + bool BucketThread(lldb::tid_t tid, std::set<UniqueStack> &unique_stacks, + CommandReturnObject &result) { + // Grab the corresponding thread for the given thread id. + Process *process = m_exe_ctx.GetProcessPtr(); + Thread *thread = process->GetThreadList().FindThreadByID(tid).get(); + if (thread == nullptr) { + result.AppendErrorWithFormatv("Failed to process thread #{0}.\n", tid); + result.SetStatus(eReturnStatusFailed); + return false; + } + + // Collect the each frame's address for this call-stack + std::stack<lldb::addr_t> stack_frames; + const uint32_t frame_count = thread->GetStackFrameCount(); + for (uint32_t frame_index = 0; frame_index < frame_count; frame_index++) { + const lldb::StackFrameSP frame_sp = + thread->GetStackFrameAtIndex(frame_index); + const lldb::addr_t pc = frame_sp->GetStackID().GetPC(); + stack_frames.push(pc); + } + + uint32_t thread_index_id = thread->GetIndexID(); + UniqueStack new_unique_stack(stack_frames, thread_index_id); + + // Try to match the threads stack to and existing entry. + std::set<UniqueStack>::iterator matching_stack = + unique_stacks.find(new_unique_stack); + if (matching_stack != unique_stacks.end()) { + matching_stack->AddThread(thread_index_id); + } else { + unique_stacks.insert(new_unique_stack); + } + return true; + } + ReturnStatus m_success_return = eReturnStatusSuccessFinishResult; + bool m_unique_stacks = false; bool m_add_return = true; }; @@ -161,9 +267,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -217,9 +323,10 @@ public: : CommandObjectIterateOverThreads( interpreter, "thread backtrace", "Show thread call stacks. Defaults to the current thread, thread " - "indexes can be specified as arguments. Use the thread-index " - "\"all\" " - "to see all threads.", + "indexes can be specified as arguments.\n" + "Use the thread-index \"all\" to see all threads.\n" + "Use the thread-index \"unique\" to see threads grouped by unique " + "call stacks.", nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | @@ -269,11 +376,14 @@ protected: Stream &strm = result.GetOutputStream(); + // Only dump stack info if we processing unique stacks. + const bool only_stacks = m_unique_stacks; + // Don't show source context when doing backtraces. const uint32_t num_frames_with_source = 0; const bool stop_format = true; if (!thread->GetStatus(strm, m_options.m_start, m_options.m_count, - num_frames_with_source, stop_format)) { + num_frames_with_source, stop_format, only_stacks)) { result.AppendErrorWithFormat( "error displaying backtrace for thread: \"0x%4.4x\"\n", thread->GetIndexID()); @@ -329,9 +439,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -555,7 +665,7 @@ protected: AddressRange range; SymbolContext sc = frame->GetSymbolContext(eSymbolContextEverything); if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER) { - Error error; + Status error; if (!sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range, error)) { result.AppendErrorWithFormat("invalid end-line option: %s.", @@ -564,7 +674,7 @@ protected: return false; } } else if (m_options.m_end_line_is_block_end) { - Error error; + Status error; Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; if (!block) { result.AppendErrorWithFormat("Could not find the current block."); @@ -648,7 +758,7 @@ protected: new_plan_sp->SetOkayToDiscard(false); if (m_options.m_step_count > 1) { - if (new_plan_sp->SetIterationCount(m_options.m_step_count)) { + if (!new_plan_sp->SetIterationCount(m_options.m_step_count)) { result.AppendWarning( "step operation does not support iteration count."); } @@ -659,7 +769,7 @@ protected: const uint32_t iohandler_id = process->GetIOHandlerID(); StreamString stream; - Error error; + Status error; if (synchronous_execution) error = process->ResumeSynchronous(&stream); else @@ -840,7 +950,7 @@ public: } StreamString stream; - Error error; + Status error; if (synchronous_execution) error = process->ResumeSynchronous(&stream); else @@ -907,9 +1017,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1173,7 +1283,7 @@ protected: process->GetThreadList().SetSelectedThreadByID(m_options.m_thread_idx); StreamString stream; - Error error; + Status error; if (synchronous_execution) error = process->ResumeSynchronous(&stream); else @@ -1324,10 +1434,10 @@ public: m_json_stopinfo = false; } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { const int short_option = m_getopt_table[option_idx].val; - Error error; + Status error; switch (short_option) { case 'j': @@ -1339,7 +1449,7 @@ public: break; default: - return Error("invalid short option character '%c'", short_option); + return Status("invalid short option character '%c'", short_option); } return error; } @@ -1417,9 +1527,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1497,7 +1607,7 @@ protected: "called expressions"); Thread *thread = m_exe_ctx.GetThreadPtr(); - Error error; + Status error; error = thread->UnwindInnermostExpression(); if (!error.Success()) { result.AppendErrorWithFormat("Unwinding expression failed - %s.", @@ -1552,7 +1662,7 @@ protected: } } - Error error; + Status error; ThreadSP thread_sp = m_exe_ctx.GetThreadSP(); const bool broadcast = true; error = thread_sp->ReturnFromFrame(frame_sp, return_valobj_sp, broadcast); @@ -1601,24 +1711,24 @@ public: m_force = false; } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { const int short_option = m_getopt_table[option_idx].val; - Error error; + Status error; switch (short_option) { case 'f': m_filenames.AppendIfUnique(FileSpec(option_arg, false)); if (m_filenames.GetSize() > 1) - return Error("only one source file expected."); + return Status("only one source file expected."); break; case 'l': if (option_arg.getAsInteger(0, m_line_num)) - return Error("invalid line number: '%s'.", option_arg.str().c_str()); + return Status("invalid line number: '%s'.", option_arg.str().c_str()); break; case 'b': if (option_arg.getAsInteger(0, m_line_offset)) - return Error("invalid line offset: '%s'.", option_arg.str().c_str()); + return Status("invalid line offset: '%s'.", option_arg.str().c_str()); break; case 'a': m_load_addr = Args::StringToAddress(execution_context, option_arg, @@ -1628,7 +1738,7 @@ public: m_force = true; break; default: - return Error("invalid short option character '%c'", short_option); + return Status("invalid short option character '%c'", short_option); } return error; } @@ -1701,7 +1811,7 @@ protected: } std::string warnings; - Error err = thread->JumpToLine(file, line, m_options.m_force, &warnings); + Status err = thread->JumpToLine(file, line, m_options.m_force, &warnings); if (err.Fail()) { result.SetError(err); @@ -1746,9 +1856,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp index 621ef58..2d4271c 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp @@ -16,13 +16,11 @@ #include <functional> // Project includes -#include "lldb/Core/ConstString.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/RegularExpression.h" #include "lldb/Core/State.h" -#include "lldb/Core/StringList.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -38,6 +36,9 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadList.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/StringList.h" // Other libraries and framework includes #include "llvm/ADT/STLExtras.h" @@ -82,9 +83,9 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command, return false; for (auto entry : llvm::enumerate(command.entries().drop_back())) { - if (entry.Value.ref != "unsigned") + if (entry.value().ref != "unsigned") continue; - auto next = command.entries()[entry.Index + 1].ref; + auto next = command.entries()[entry.index() + 1].ref; if (next == "int" || next == "short" || next == "char" || next == "long") { result.AppendWarningWithFormat( "unsigned %s being treated as two types. if you meant the combined " @@ -126,8 +127,8 @@ private: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override; void OptionParsingStarting(ExecutionContext *execution_context) override; @@ -212,7 +213,7 @@ public: options->m_flags, funct_name_str.c_str(), lines.CopyList(" ").c_str())); - Error error; + Status error; for (size_t i = 0; i < options->m_target_types.GetSize(); i++) { const char *type_name = @@ -282,7 +283,7 @@ public: static bool AddSummary(ConstString type_name, lldb::TypeSummaryImplSP entry, SummaryFormatType type, std::string category, - Error *error = nullptr); + Status *error = nullptr); protected: bool DoExecute(Args &command, CommandReturnObject &result) override; @@ -320,9 +321,9 @@ private: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; bool success; @@ -463,7 +464,7 @@ protected: DataVisualization::Categories::GetCategory( ConstString(options->m_category.c_str()), category); - Error error; + Status error; for (size_t i = 0; i < options->m_target_types.GetSize(); i++) { const char *type_name = @@ -522,7 +523,7 @@ public: static bool AddSynth(ConstString type_name, lldb::SyntheticChildrenSP entry, SynthFormatType type, std::string category_name, - Error *error); + Status *error); }; //------------------------------------------------------------------------- @@ -561,9 +562,9 @@ private: m_custom_type_name.clear(); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = g_type_format_add_options[option_idx].short_option; bool success; @@ -768,9 +769,9 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -908,9 +909,9 @@ private: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1024,9 +1025,9 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed { ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'w': @@ -1188,8 +1189,7 @@ protected: category_closure(category_sp); } else { DataVisualization::Categories::ForEach( - [this, &command, &result, &category_regex, &formatter_regex, - &category_closure]( + [&category_regex, &category_closure]( const lldb::TypeCategoryImplSP &category) -> bool { if (category_regex) { bool escape = true; @@ -1243,10 +1243,10 @@ public: #endif // LLDB_DISABLE_PYTHON -Error CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue( +Status CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue( uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) { - Error error; + Status error; const int short_option = m_getopt_table[option_idx].val; bool success; @@ -1423,7 +1423,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary( // if I am here, script_format must point to something good, so I can add that // as a script summary to all interested parties - Error error; + Status error; for (auto &entry : command.entries()) { CommandObjectTypeSummaryAdd::AddSummary( @@ -1498,7 +1498,7 @@ bool CommandObjectTypeSummaryAdd::Execute_StringSummary( lldb::TypeSummaryImplSP entry(string_format.release()); // now I have a valid format, let's add it to every type - Error error; + Status error; for (auto &arg_entry : command.entries()) { if (arg_entry.ref.empty()) { result.AppendError("empty typenames not allowed"); @@ -1681,7 +1681,7 @@ bool CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name, TypeSummaryImplSP entry, SummaryFormatType type, std::string category_name, - Error *error) { + Status *error) { lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); @@ -1799,9 +1799,9 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed { ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -1903,9 +1903,9 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed { ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -2080,9 +2080,9 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed { ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -2407,7 +2407,7 @@ bool CommandObjectTypeSynthAdd::Execute_PythonClass( DataVisualization::Categories::GetCategory( ConstString(m_options.m_category.c_str()), category); - Error error; + Status error; for (auto &arg_entry : command.entries()) { if (arg_entry.ref.empty()) { @@ -2450,7 +2450,7 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name, SyntheticChildrenSP entry, SynthFormatType type, std::string category_name, - Error *error) { + Status *error) { lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); @@ -2512,9 +2512,9 @@ private: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; bool success; @@ -2586,7 +2586,7 @@ private: bool AddFilter(ConstString type_name, TypeFilterImplSP entry, FilterFormatType type, std::string category_name, - Error *error) { + Status *error) { lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory( ConstString(category_name.c_str()), category); @@ -2717,7 +2717,7 @@ protected: DataVisualization::Categories::GetCategory( ConstString(m_options.m_category.c_str()), category); - Error error; + Status error; WarnOnPotentialUnquotedUnsignedType(command, result); @@ -2787,9 +2787,9 @@ protected: return llvm::makeArrayRef(g_type_lookup_options); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, + ExecutionContext *execution_context) override { + Status error; const int short_option = g_type_lookup_options[option_idx].short_option; @@ -2899,7 +2899,7 @@ public: if (!ParseOptions(args, result)) return false; - Error error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); + Status error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp index baa9f41..9c84c99 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -20,10 +20,9 @@ // Project includes #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Breakpoint/WatchpointList.h" -#include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -31,6 +30,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -197,9 +197,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -245,7 +245,7 @@ protected: if (target->GetProcessSP() && target->GetProcessSP()->IsAlive()) { uint32_t num_supported_hardware_watchpoints; - Error error = target->GetProcessSP()->GetWatchpointSupportInfo( + Status error = target->GetProcessSP()->GetWatchpointSupportInfo( num_supported_hardware_watchpoints); if (error.Success()) result.AppendMessageWithFormat( @@ -561,9 +561,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -689,9 +689,9 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -881,7 +881,7 @@ protected: } // Things have checked out ok... - Error error; + Status error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess; @@ -895,7 +895,7 @@ protected: VariableList variable_list; ValueObjectList valobj_list; - Error error(Variable::GetValuesForVariableExpressionPath( + Status error(Variable::GetValuesForVariableExpressionPath( command.GetArgumentAtIndex(0), m_exe_ctx.GetBestExecutionContextScope(), GetVariableCallback, target, variable_list, valobj_list)); @@ -1060,7 +1060,7 @@ protected: if (!ParseOptions(args, result)) return false; - Error error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); + Status error(m_option_group.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -1135,7 +1135,7 @@ protected: /// of the expression, so convert to that if we found a valid type. CompilerType compiler_type(valobj_sp->GetCompilerType()); - Error error; + Status error; Watchpoint *wp = target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error) .get(); diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 1860d4c..ec7e4a1 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -19,6 +19,7 @@ #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/State.h" +#include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" @@ -318,9 +319,9 @@ are no syntax errors may indicate that a function was declared but never called. ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { |