[Lldb-commits] [PATCH] D49685: LLDB does not respect platform sysroot when loading core on Linux
labath added a comment. In https://reviews.llvm.org/D49685#1178730, @EugeneBi wrote: > I looked at the tests - is it all in Python? Not sure I have time to learn a > new language... Is there anything in C++? We have unit tests in c++, but it's going to be quite hard to tickle this code path from there. FWIW, I don't think you really need to *know* python to write a test like this. You should be able to fudge it by cargo-culting some code from existing tests and some basic python examples. I expect the test should be something like: # copy core file an .exe into an appropriate directory tree self.runCmd("platform select remote-linux --sysroot '%s'" % sysroot) target = self.dbg.CreateTarget(None) process = target.LoadCode(core) self.assertEquals(1, target.GetNumModules()) self.assertEquals(exe, target.GetModuleAtIndex(0).GetFileSpec()) https://reviews.llvm.org/D49685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49271: Adding libc++ formattors for std::optional
labath added a comment. Thanks for looking out for the bots. I am afraid the compiler check will not be enough here. After that, you'll run into the issue of the system libc++ not being recent enough to contain std::optional. I suppose this could be handled by including some other header first (to make sure `__config` is evaluated) and then checking the `_LIBCPP_VERSION` macro. I am sorry that this is so annoying. It's surprising that this is the first time we're running into this, but I guess this is the first data formatter for something that hasn't been implemented in libc++ since forever. Repository: rL LLVM https://reviews.llvm.org/D49271 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49980: [PDB] Parse UDT symbols and pointers to members (combined patch)
aleksandr.urakov created this revision. aleksandr.urakov added reviewers: asmith, zturner, rnk, labath, clayborg, lldb-commits. Herald added a subscriber: JDevlieghere. In this patch I've tried to combine the best ideas from https://reviews.llvm.org/D49368 and https://reviews.llvm.org/D49410, so it implements following: - Completion of UDTs from a PDB with a filling of a layout info; - Pointers to members; - Fixes the bug relating to a virtual base offset reading from `vbtable`. The offset was treated as an unsigned, but it can be a negative sometimes. https://reviews.llvm.org/D49980 Files: include/lldb/Symbol/ClangASTContext.h lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp lit/SymbolFile/PDB/Inputs/PointerTypeTest.cpp lit/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp lit/SymbolFile/PDB/Inputs/UdtLayoutTest.script lit/SymbolFile/PDB/class-layout.test lit/SymbolFile/PDB/pointers.test lit/SymbolFile/PDB/udt-layout.test source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp source/Plugins/SymbolFile/PDB/PDBASTParser.cpp source/Plugins/SymbolFile/PDB/PDBASTParser.h source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp source/Symbol/ClangASTContext.cpp Index: source/Symbol/ClangASTContext.cpp === --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -124,6 +124,84 @@ // Use Clang for D until there is a proper language plugin for it language == eLanguageTypeD; } + +// Checks whether m1 is an overload of m2 (as opposed to an override). This is +// called by addOverridesForMethod to distinguish overrides (which share a +// vtable entry) from overloads (which require distinct entries). +bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) { + // FIXME: This should detect covariant return types, but currently doesn't. + lldbassert(&m1->getASTContext() == &m2->getASTContext() && + "Methods should have the same AST context"); + clang::ASTContext &context = m1->getASTContext(); + + const auto *m1Type = llvm::cast( + context.getCanonicalType(m1->getType())); + + const auto *m2Type = llvm::cast( + context.getCanonicalType(m2->getType())); + + auto compareArgTypes = [&context](const clang::QualType &m1p, +const clang::QualType &m2p) { +return context.hasSameType(m1p.getUnqualifiedType(), + m2p.getUnqualifiedType()); + }; + + // FIXME: In C++14 and later, we can just pass m2Type->param_type_end() + //as a fourth parameter to std::equal(). + return (m1->getNumParams() != m2->getNumParams()) || + !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(), + m2Type->param_type_begin(), compareArgTypes); +} + +// If decl is a virtual method, walk the base classes looking for methods that +// decl overrides. This table of overridden methods is used by IRGen to +// determine the vtable layout for decl's parent class. +void addOverridesForMethod(clang::CXXMethodDecl *decl) { + if (!decl->isVirtual()) +return; + + clang::CXXBasePaths paths; + + auto find_overridden_methods = + [decl](const clang::CXXBaseSpecifier *specifier, + clang::CXXBasePath &path) { +if (auto *base_record = llvm::dyn_cast( +specifier->getType()->getAs()->getDecl())) { + + clang::DeclarationName name = decl->getDeclName(); + + // If this is a destructor, check whether the base class destructor is + // virtual. + if (name.getNameKind() == clang::DeclarationName::CXXDestructorName) +if (auto *baseDtorDecl = base_record->getDestructor()) { + if (baseDtorDecl->isVirtual()) { +path.Decls = baseDtorDecl; +return true; + } else +return false; +} + + // Otherwise, search for name in the base class. + for (path.Decls = base_record->lookup(name); !path.Decls.empty(); + path.Decls = path.Decls.slice(1)) { +if (auto *method_decl = +llvm::dyn_cast(path.Decls.front())) + if (method_decl->isVirtual() && !isOverload(decl, method_decl)) { +path.Decls = method_decl; +return true; + } + } +} + +return false; + }; + + if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) { +for (auto *overridden_decl : paths.found_decls()) + decl->addOverriddenMethod( + llvm::cast(overridden_decl)); + } +} } typedef lldb_private::ThreadSafeDenseMap @@ -6373,7 +6451,7 @@ language_flags = 0; const bool idx_is_valid = idx < GetNumChildren(type, omit_empty_base_classes); - uint32_t bit_offset; + int32_t bit_offset; switch (parent_type_class) { case clang::Type::Builtin: if (idx_is_valid) { @@ -6465,8 +6543,8 @@
[Lldb-commits] [PATCH] D49980: [PDB] Parse UDT symbols and pointers to members (combined patch)
aleksandr.urakov added inline comments. Comment at: lit/SymbolFile/PDB/udt-layout.test:1-51 +REQUIRES: windows +RUN: clang-cl /Zi %S/Inputs/UdtLayoutTest.cpp /o %t.exe +RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s + +CHECK:(int) int C::abc = 123 +CHECK:(List [16]) ls = { +CHECK: [15] = { I've preserved this Windows-only test (but also have included other non-execution tests, which may become cross-platform some later, as Pavel has mentioned at D49410), but if you'll find it unnecessary I'll remove it. https://reviews.llvm.org/D49980 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz created this revision. sgraenitz added reviewers: labath, jingham, JDevlieghere, erik.pilkington. This review is about getting your feedback for the patch. If it doesn't make it in this form, I can adjust everything that's necessary and open a new review once I am done. So please don't hesitate to share your honest opinions. In preparation for this review, there were two earlier ones: - https://reviews.llvm.org/D49612 introduced the ItaniumPartialDemangler to LLDB demangling without conceptual changes - https://reviews.llvm.org/D49909 added a unit test that covers all relevant code paths in the InitNameIndexes() function Primary goals for this patch are: (1) Use ItaniumPartialDemangler's rich mangling info for building LLDB's name index. (2) Make a uniform interface so that Symtab doesn't get involved with mangling details too much. (3) Improve indexing performance. In order to achive (1) and (2) I added two classes: - RichManglingInfo offers a uniform interface to query symbol properties like getFunctionDeclContextName() or isCtorOrDtor(). It can switch between different providers internally. At the moment it supports llvm::ItaniumPartialDemangler and lldb_private::CPlusPlusLanguage::MethodName (legacy/fallback implementation). - RichManglingSpec handles configuration and lifetime of RichManglingInfos. It is likely stack-allocated and can be reused for multiple queries during batch processing. These classes are used for wrapping the input and output of DemangleWithRichManglingInfo(), our new function for explicit demangling. It will return a properly initialized RichManglingInfo on success, or otherwise null: RichManglingInfo *Mangled::DemangleWithRichManglingInfo(RichManglingSpec, SkipMangledNameFn) Thus the RichManglingInfo class does not need to support a None-state (it's not accessible in this state). In order to avoid an extra heap allocation per invocation for storing the result of DemangleWithRichManglingInfo(), the actual instance is owned by RichManglingSpec. This aids (3) and we want to use a single RichManglingSpec instance for the entire index anyway (it also owns the IPD). An efficient filtering function SkipMangledNameFn contributes here too and helps to mimic the original behavior of InitNameIndexes. The old implementation only parsed and indexed Itanium mangled names. The new RichManglingInfo can be easily extended for various mangling schemes and languages. One problem with the implementation of RichManglingInfo is the inaccessibility of class CPlusPlusLanguage::MethodName (defined in source/Plugins/Language/..), from within any header in the Core components of LLDB. The rather hacky solution is to store a type erased pointer and cast it to the correct type on access in the cpp - see RichManglingInfo::get(). Not sure if there's a better way to do it. IMHO CPlusPlusLanguage::MethodName should be a top-level class in order to enable forward delcarations (but that is a rather big change I guess). I also found a few minor bugs/smells, which I will mark with inline comments. First simple profiling shows a good speedup. target create clang now takes 0.64s on average (over 5 runs). Before the change I observed runtimes between 0.76s an 1.01s. This is still no bulletproof data (I only ran it on one machine!), but it's a promising indicator I think. What do you think? Is this too unconventional? Do you have ideas for improvements? https://reviews.llvm.org/D49990 Files: include/lldb/Core/Mangled.h include/lldb/Symbol/Symtab.h include/lldb/Utility/ConstString.h source/Core/Mangled.cpp source/Symbol/Symtab.cpp Index: source/Symbol/Symtab.cpp === --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -22,6 +22,7 @@ #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" +#include "llvm/Demangle/Demangle.h" using namespace lldb; using namespace lldb_private; @@ -212,9 +213,120 @@ return nullptr; } +//-- +// RichManglingInfo +//-- + +void RichManglingInfo::ResetProvider() { + // If we want to support parsers for other languages some day, we need a + // switch here to delete the correct parser type. + if (m_legacy_parser) { +assert(m_provider == RichManglingInfo::PluginCxxLanguage); +delete get(); +m_legacy_parser = nullptr; + } +} + +RichManglingInfo *RichManglingSpec::CreateItaniumInfo() { + m_info.ResetProvider(); + m_info.m_provider = RichManglingInfo::ItaniumPartialDemangler; + m_info.m_IPD = &m_IPD; + return &m_info; +} + +RichManglingInfo * +RichManglingSpec::CreateLegacyCxxParserInfo(const ConstString &mangled) { + m_info.ResetProvider(); + m_info.m_provider = RichManglingInfo::PluginCxxLanguage; + m_info.m_legacy_parser = new CPlusPlusL
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz added inline comments. Comment at: include/lldb/Symbol/Symtab.h:43 +private: + enum InfoProvider { ItaniumPartialDemangler, PluginCxxLanguage }; + We don't need a None-case here. Comment at: include/lldb/Symbol/Symtab.h:58 + /// dependency. Keep a void* here instead and cast it on-demand on the cpp. + void *m_legacy_parser = nullptr; + This is the hackiest point I guess. Comment at: include/lldb/Symbol/Symtab.h:106 +//-- + class Symtab { ^ May have its own header & cpp Comment at: include/lldb/Utility/ConstString.h:357 + //-- /// Set the C string value. Fixing a related issue: There is no way to determine whether or not the internal string is null or empty. In fact, `operator!` does the same as the above `IsEmpty()`. The `Mangled::GetDemangledName()` function, however, thinks there would be a difference and wants to benefit from it. The fixed version should be correct now. Comment at: source/Core/Mangled.cpp:198 a.GetName(lldb::eLanguageTypeUnknown, ePreferMangled), - a.GetName(lldb::eLanguageTypeUnknown, ePreferMangled)); + b.GetName(lldb::eLanguageTypeUnknown, ePreferMangled)); } Fixing bug: This is no dead code, but well, maybe in a rare branch. Comment at: source/Core/Mangled.cpp:366 // already decoded our mangled name. - if (m_mangled && !m_demangled) { + if (m_mangled && m_demangled.IsNull()) { // We need to generate and cache the demangled name. Using the difference between null and empty. Comment at: source/Core/Mangled.cpp:397 } -if (!m_demangled) { +if (m_demangled.IsNull()) { // Set the demangled string to the empty string to indicate we tried to Using the difference between null and empty. Comment at: source/Symbol/Symtab.cpp:295 +namespace { +bool lldb_skip_name(const char *mangled_cstr, Mangled::ManglingScheme scheme) { + switch (scheme) { This uses a raw C-string instead of `llvm::StringRef` in order to achieve `O(1)` runtime. https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
labath added a comment. I haven't read through this in detail yet, but I think this is a good start! The part I'm not sure about is whether the RichManglingInfo vs. RichManglingSpec distinction brings any value. I mean, the lifetime of the first is tied to the lifetime of the second, and the Spec class can only have one active Info instance at any given moment. So you might as well just have one class, pass that to `DemangleWithRichManglingInfo`, and then query the same object when the call returns. The current interface with `createItaniumInfo` et al. makes it seem like one could call it multiple times in sequence, stashing the results, and then doing some post-processing on them. I'll have to think about the C++::MethodName issue a bit more, but in general, I don't think moving that class to a separate file is a too disruptive change. If it means we don't have to mess with untyped pointers, then we should just do it. (Ideally, I wouldn't want the common code to reference that plugin at all, but that ship has already sailed, so I don't think this patch should be predicated on fixing that.) Comment at: include/lldb/Symbol/Symtab.h:81-83 + // No move + RichManglingInfo(RichManglingInfo &&) = delete; + RichManglingInfo &operator=(RichManglingInfo &&) = delete; This is implied by the deleted copy operations. Comment at: source/Symbol/Symtab.cpp:271-289 +const char *RichManglingInfo::getFunctionBaseName() const { + switch (m_provider) { + case ItaniumPartialDemangler: +m_IPD_buf = m_IPD->getFunctionBaseName(m_IPD_buf, &m_IPD_size); +return m_IPD_buf; + case PluginCxxLanguage: +return get()->GetBasename().data(); Could these return StringRef instead of C strings? Comment at: source/Symbol/Symtab.cpp:295 +namespace { +bool lldb_skip_name(const char *mangled_cstr, Mangled::ManglingScheme scheme) { + switch (scheme) { sgraenitz wrote: > This uses a raw C-string instead of `llvm::StringRef` in order to achieve > `O(1)` runtime. If you changed the caller to use StringRef too (it seems possible at a first glance) then this would still be O(1) https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
zturner added inline comments. Comment at: include/lldb/Symbol/Symtab.h:58 + /// dependency. Keep a void* here instead and cast it on-demand on the cpp. + void *m_legacy_parser = nullptr; + sgraenitz wrote: > This is the hackiest point I guess. We have `llvm::Any`. Perhaps you want to use that here instead of `void*`? https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz added inline comments. Comment at: source/Symbol/Symtab.cpp:274 + case ItaniumPartialDemangler: +m_IPD_buf = m_IPD->getFunctionBaseName(m_IPD_buf, &m_IPD_size); +return m_IPD_buf; @erik.pilkington Is it acceptable/good practice to pass `(nullptr, 0)` here? At the moment this safes some lines of initialization checks for `m_IPD_buf` and `m_IPD_size`. https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
clayborg added inline comments. Comment at: include/lldb/Core/Mangled.h:25-34 +namespace lldb_private { +class RichManglingInfo; +class RichManglingSpec; +} namespace lldb_private { class RegularExpression; } move any forward decls to lldb-forward.h and remove all manual forward declarations in lldb_private from here. Comment at: include/lldb/Symbol/Symtab.h:26 +/// providers. See Mangled::DemangleWithRichManglingInfo() +class RichManglingInfo { +public: move to separate files RichManglingInfo.h and RichManglingInfo.cpp Comment at: include/lldb/Symbol/Symtab.h:93 +/// Unique owner of RichManglingInfo. Handles initialization and lifetime. +class RichManglingSpec { +public: move to separate files RichManglingInfo.h and RichManglingInfo.cpp https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz added a comment. Thanks or the quick reviews! Follow-ups inline. Comment at: include/lldb/Symbol/Symtab.h:58 + /// dependency. Keep a void* here instead and cast it on-demand on the cpp. + void *m_legacy_parser = nullptr; + zturner wrote: > sgraenitz wrote: > > This is the hackiest point I guess. > We have `llvm::Any`. Perhaps you want to use that here instead of `void*`? Thanks. I will check that. Comment at: include/lldb/Symbol/Symtab.h:81-83 + // No move + RichManglingInfo(RichManglingInfo &&) = delete; + RichManglingInfo &operator=(RichManglingInfo &&) = delete; labath wrote: > This is implied by the deleted copy operations. Which are implicitly deleted too, due to the existence of the destructor right? Does LLVM/LLDB have some kind of convention for it? I like to be explicit on ctors&assignment ("rule of 5"), because it aids error messages, but I would be fine with following the existing convention here. Comment at: source/Symbol/Symtab.cpp:271-289 +const char *RichManglingInfo::getFunctionBaseName() const { + switch (m_provider) { + case ItaniumPartialDemangler: +m_IPD_buf = m_IPD->getFunctionBaseName(m_IPD_buf, &m_IPD_size); +return m_IPD_buf; + case PluginCxxLanguage: +return get()->GetBasename().data(); labath wrote: > Could these return StringRef instead of C strings? Yes. So far it's simply the closest superset of the two interfaces, but I will try using `StringRef` where possible. Comment at: source/Symbol/Symtab.cpp:295 +namespace { +bool lldb_skip_name(const char *mangled_cstr, Mangled::ManglingScheme scheme) { + switch (scheme) { labath wrote: > sgraenitz wrote: > > This uses a raw C-string instead of `llvm::StringRef` in order to achieve > > `O(1)` runtime. > If you changed the caller to use StringRef too (it seems possible at a first > glance) then this would still be O(1) Right, thanks there's a `ConstString::GetStringRef()`. Perfect. https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
erik.pilkington added inline comments. Comment at: source/Symbol/Symtab.cpp:274 + case ItaniumPartialDemangler: +m_IPD_buf = m_IPD->getFunctionBaseName(m_IPD_buf, &m_IPD_size); +return m_IPD_buf; sgraenitz wrote: > @erik.pilkington Is it acceptable/good practice to pass `(nullptr, 0)` here? > At the moment this safes some lines of initialization checks for `m_IPD_buf` > and `m_IPD_size`. Sure, thats fine! Those parameters act the same way as `buf` and `size` in __cxa_demangle. `getFunctionBaseName` will return nullptr if the mangled name isn't a function. Is it a precondition of this function that m_IPD stores a function? If not, it looks like you'll leak the buffer. https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49632: [lldb-mi] Re-implement MI HandleProcessEventStateSuspended.
clayborg added a comment. I still don't get why we are printing process stopped information to STDOUT. MI is a machine interface for a IDE. The IDE should be showing the process state in the GUI. https://reviews.llvm.org/D49632 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz added inline comments. Comment at: include/lldb/Symbol/Symtab.h:58 + /// dependency. Keep a void* here instead and cast it on-demand on the cpp. + void *m_legacy_parser = nullptr; + sgraenitz wrote: > zturner wrote: > > sgraenitz wrote: > > > This is the hackiest point I guess. > > We have `llvm::Any`. Perhaps you want to use that here instead of `void*`? > Thanks. I will check that. @zturner Where is `llvm::Any`? Expected it in ADT or Support, but can't find it. IIUC `llvm::Optional` does something similar, but uses its own `optional_detail::OptionalStorage`. Same for `llvm::Expected`. Or is it a very recent addition? https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
zturner added inline comments. Comment at: include/lldb/Symbol/Symtab.h:58 + /// dependency. Keep a void* here instead and cast it on-demand on the cpp. + void *m_legacy_parser = nullptr; + sgraenitz wrote: > sgraenitz wrote: > > zturner wrote: > > > sgraenitz wrote: > > > > This is the hackiest point I guess. > > > We have `llvm::Any`. Perhaps you want to use that here instead of > > > `void*`? > > Thanks. I will check that. > @zturner Where is `llvm::Any`? Expected it in ADT or Support, but can't find > it. IIUC `llvm::Optional` does something similar, but uses its own > `optional_detail::OptionalStorage`. Same for `llvm::Expected`. Or is it a > very recent addition? It's pretty recent. I was actually the one who added it, about maybe 2 weeks ago. It's in `include/llvm/ADT/Any.h` https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz added inline comments. Comment at: source/Symbol/Symtab.cpp:274 + case ItaniumPartialDemangler: +m_IPD_buf = m_IPD->getFunctionBaseName(m_IPD_buf, &m_IPD_size); +return m_IPD_buf; erik.pilkington wrote: > sgraenitz wrote: > > @erik.pilkington Is it acceptable/good practice to pass `(nullptr, 0)` > > here? At the moment this safes some lines of initialization checks for > > `m_IPD_buf` and `m_IPD_size`. > Sure, thats fine! Those parameters act the same way as `buf` and `size` in > __cxa_demangle. > > `getFunctionBaseName` will return nullptr if the mangled name isn't a > function. Is it a precondition of this function that m_IPD stores a function? > If not, it looks like you'll leak the buffer. Oh that is a very good note. I had it as a precondition in the client function in Symtab. When I removed that and started to just check the result for `nullptr`, I didn't think about the buffer. Gonna fix it, the generalized interface shouldn't have that precondition anyway. Thanks! https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49632: [lldb-mi] Re-implement MI HandleProcessEventStateSuspended.
apolyakov added a comment. In https://reviews.llvm.org/D49632#1180465, @clayborg wrote: > I still don't get why we are printing process stopped information to STDOUT. > MI is a machine interface for a IDE. The IDE should be showing the process > state in the GUI. AFAIK, all lldb-mi commands print their final result records to stdout. All lldb-mi commands are inherited from `CMICmdInvoker` which has `CmdExecuteFinished(...)` method that is invoked when a command is finished, this method then call `CmdToStdout(...)` method which prints command's result to stdout. So, I guess, it's ok, isn't it? https://reviews.llvm.org/D49632 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz updated this revision to Diff 158041. sgraenitz added a comment. Herald added a subscriber: mgorny. Simple fixes https://reviews.llvm.org/D49990 Files: include/lldb/Core/Mangled.h include/lldb/Symbol/Symtab.h include/lldb/Utility/ConstString.h include/lldb/lldb-forward.h source/Core/Mangled.cpp source/Symbol/Symtab.cpp unittests/Core/CMakeLists.txt unittests/Core/Inputs/mangled-function-names.yaml unittests/Core/MangledTest.cpp Index: unittests/Core/MangledTest.cpp === --- unittests/Core/MangledTest.cpp +++ unittests/Core/MangledTest.cpp @@ -7,9 +7,21 @@ // //===--===// -#include "gtest/gtest.h" +#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" +#include "TestingSupport/TestUtilities.h" #include "lldb/Core/Mangled.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/SymbolContext.h" + +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" + +#include "gtest/gtest.h" using namespace lldb; using namespace lldb_private; @@ -36,3 +48,123 @@ EXPECT_STREQ("", TheDemangled.GetCString()); } + +#define ASSERT_NO_ERROR(x) \ + if (std::error_code ASSERT_NO_ERROR_ec = x) {\ +llvm::SmallString<128> MessageStorage; \ +llvm::raw_svector_ostream Message(MessageStorage); \ +Message << #x ": did not return errc::success.\n" \ +<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \ +<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \ +GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \ + } else { \ + } + +TEST(MangledTest, NameIndexes_FindFunctionSymbols) { + HostInfo::Initialize(); + ObjectFileELF::Initialize(); + SymbolVendorELF::Initialize(); + + std::string Yaml = GetInputFilePath("mangled-function-names.yaml"); + llvm::SmallString<128> Obj; + ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( + "mangled-function-names-%%", "obj", Obj)); + + llvm::FileRemover Deleter(Obj); + llvm::StringRef Args[] = {YAML2OBJ, Yaml}; + llvm::StringRef ObjRef = Obj; + const llvm::Optional redirects[] = {llvm::None, ObjRef, + llvm::None}; + ASSERT_EQ(0, +llvm::sys::ExecuteAndWait(YAML2OBJ, Args, llvm::None, redirects)); + uint64_t Size; + ASSERT_NO_ERROR(llvm::sys::fs::file_size(Obj, Size)); + ASSERT_GT(Size, 0u); + + ModuleSpec Spec{FileSpec(Obj, false)}; + Spec.GetSymbolFileSpec().SetFile(Obj, false, FileSpec::Style::native); + auto M = std::make_shared(Spec); + + auto Count = [M](const char *Name, FunctionNameType Type) -> int { +SymbolContextList SymList; +return M->FindFunctionSymbols(ConstString(Name), Type, SymList); + }; + + // Unmangled + EXPECT_EQ(1, Count("main", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("main", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("main", eFunctionNameTypeMethod)); + + // Itanium mangled + EXPECT_EQ(1, Count("_Z3foov", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_Z3foov", eFunctionNameTypeBase)); + EXPECT_EQ(1, Count("foo", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("foo", eFunctionNameTypeMethod)); + + // Unmangled with linker annotation + EXPECT_EQ(1, Count("puts@GLIBC_2.5", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("puts@GLIBC_2.6", eFunctionNameTypeFull)); + EXPECT_EQ(2, Count("puts", eFunctionNameTypeFull)); + EXPECT_EQ(2, Count("puts", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("puts", eFunctionNameTypeMethod)); + + // Itanium mangled with linker annotation + EXPECT_EQ(1, Count("_Z5annotv@VERSION3", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_Z5annotv", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_Z5annotv", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("annot", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("annot", eFunctionNameTypeMethod)); + + // Itanium mangled ctor A::A() + EXPECT_EQ(1, Count("_ZN1AC2Ev", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_ZN1AC2Ev", eFunctionNameTypeBase)); + EXPECT_EQ(1, Count("A", eFunctionNameTypeMethod)); + EXPECT_EQ(0, Count("A", eFunctionNameTypeBase)); + + // Itanium mangled dtor A::~A() + EXPECT_EQ(1, Count("_ZN1AD2Ev", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_ZN1AD2Ev", eFunctionNameTypeBase)); + EXPECT_EQ(1, Count("~A", eFunctionNameTypeMethod)); + EXPECT_EQ(0, Count("~A", eFunctionNameTypeBase)); + + // Itanium mangled method A::bar() + EXPECT_EQ(1, Count("_ZN1A3barEv", eFunctionNameTypeFull)); + EXP
Re: [Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
FYI, Breakpad & Crashpad will start generating the Microsoft flavor of ARM minidumps soon. On Wed, Jul 25, 2018 at 9:44 AM, Leonard Mosescu via Phabricator < revi...@reviews.llvm.org> wrote: > lemo added inline comments. > > > > Comment at: source/Plugins/Process/minidump/RegisterContextMinidump_ARM. > cpp:51 > + reg_fpscr, > + reg_d0, reg_d1, reg_d2, reg_d3, reg_d4, reg_d5, reg_d6, reg_d7, > + reg_d8, reg_d9, reg_d10, reg_d11, reg_d12, reg_d13, reg_d14, reg_d15, > > Pavel's comment reminded me: what about the S registers (32bit fp) and Q > registers (128bit Neon)? > > > https://reviews.llvm.org/D49750 > > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
lemo added subscribers: clayborg, labath, markmentovai, t.p.northover, zturner. lemo added a comment. FYI, Breakpad & Crashpad will start generating the Microsoft flavor of ARM minidumps soon. https://reviews.llvm.org/D49750 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz updated this revision to Diff 158044. sgraenitz added a comment. Moved forward decls https://reviews.llvm.org/D49990 Files: include/lldb/Core/Mangled.h include/lldb/Symbol/Symtab.h include/lldb/Utility/ConstString.h include/lldb/lldb-forward.h source/Core/Mangled.cpp source/Symbol/Symtab.cpp unittests/Core/CMakeLists.txt unittests/Core/Inputs/mangled-function-names.yaml unittests/Core/MangledTest.cpp Index: unittests/Core/MangledTest.cpp === --- unittests/Core/MangledTest.cpp +++ unittests/Core/MangledTest.cpp @@ -7,9 +7,21 @@ // //===--===// -#include "gtest/gtest.h" +#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" +#include "TestingSupport/TestUtilities.h" #include "lldb/Core/Mangled.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/SymbolContext.h" + +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" + +#include "gtest/gtest.h" using namespace lldb; using namespace lldb_private; @@ -36,3 +48,123 @@ EXPECT_STREQ("", TheDemangled.GetCString()); } + +#define ASSERT_NO_ERROR(x) \ + if (std::error_code ASSERT_NO_ERROR_ec = x) {\ +llvm::SmallString<128> MessageStorage; \ +llvm::raw_svector_ostream Message(MessageStorage); \ +Message << #x ": did not return errc::success.\n" \ +<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \ +<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \ +GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \ + } else { \ + } + +TEST(MangledTest, NameIndexes_FindFunctionSymbols) { + HostInfo::Initialize(); + ObjectFileELF::Initialize(); + SymbolVendorELF::Initialize(); + + std::string Yaml = GetInputFilePath("mangled-function-names.yaml"); + llvm::SmallString<128> Obj; + ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( + "mangled-function-names-%%", "obj", Obj)); + + llvm::FileRemover Deleter(Obj); + llvm::StringRef Args[] = {YAML2OBJ, Yaml}; + llvm::StringRef ObjRef = Obj; + const llvm::Optional redirects[] = {llvm::None, ObjRef, + llvm::None}; + ASSERT_EQ(0, +llvm::sys::ExecuteAndWait(YAML2OBJ, Args, llvm::None, redirects)); + uint64_t Size; + ASSERT_NO_ERROR(llvm::sys::fs::file_size(Obj, Size)); + ASSERT_GT(Size, 0u); + + ModuleSpec Spec{FileSpec(Obj, false)}; + Spec.GetSymbolFileSpec().SetFile(Obj, false, FileSpec::Style::native); + auto M = std::make_shared(Spec); + + auto Count = [M](const char *Name, FunctionNameType Type) -> int { +SymbolContextList SymList; +return M->FindFunctionSymbols(ConstString(Name), Type, SymList); + }; + + // Unmangled + EXPECT_EQ(1, Count("main", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("main", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("main", eFunctionNameTypeMethod)); + + // Itanium mangled + EXPECT_EQ(1, Count("_Z3foov", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_Z3foov", eFunctionNameTypeBase)); + EXPECT_EQ(1, Count("foo", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("foo", eFunctionNameTypeMethod)); + + // Unmangled with linker annotation + EXPECT_EQ(1, Count("puts@GLIBC_2.5", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("puts@GLIBC_2.6", eFunctionNameTypeFull)); + EXPECT_EQ(2, Count("puts", eFunctionNameTypeFull)); + EXPECT_EQ(2, Count("puts", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("puts", eFunctionNameTypeMethod)); + + // Itanium mangled with linker annotation + EXPECT_EQ(1, Count("_Z5annotv@VERSION3", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_Z5annotv", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_Z5annotv", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("annot", eFunctionNameTypeBase)); + EXPECT_EQ(0, Count("annot", eFunctionNameTypeMethod)); + + // Itanium mangled ctor A::A() + EXPECT_EQ(1, Count("_ZN1AC2Ev", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_ZN1AC2Ev", eFunctionNameTypeBase)); + EXPECT_EQ(1, Count("A", eFunctionNameTypeMethod)); + EXPECT_EQ(0, Count("A", eFunctionNameTypeBase)); + + // Itanium mangled dtor A::~A() + EXPECT_EQ(1, Count("_ZN1AD2Ev", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_ZN1AD2Ev", eFunctionNameTypeBase)); + EXPECT_EQ(1, Count("~A", eFunctionNameTypeMethod)); + EXPECT_EQ(0, Count("~A", eFunctionNameTypeBase)); + + // Itanium mangled method A::bar() + EXPECT_EQ(1, Count("_ZN1A3barEv", eFunctionNameTypeFull)); + EXPECT_EQ(1, Count("_ZN1A3barEv
[Lldb-commits] [PATCH] D49990: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz marked 3 inline comments as done. sgraenitz added a comment. Sorry, I accidentally added the tests from https://reviews.llvm.org/D49909 also to this review. I will clean this up tomorrow. https://reviews.llvm.org/D49990 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49685: LLDB does not respect platform sysroot when loading core on Linux
EugeneBi added a comment. In https://reviews.llvm.org/D49685#1179837, @labath wrote: > In https://reviews.llvm.org/D49685#1178730, @EugeneBi wrote: > > > I looked at the tests - is it all in Python? Not sure I have time to learn > > a new language... Is there anything in C++? > > > We have unit tests in c++, but it's going to be quite hard to tickle this > code path from there. > > FWIW, I don't think you really need to *know* python to write a test like > this. You should be able to fudge it by cargo-culting some code from existing > tests and some basic python examples. I expect the test should be something > like: > > # copy core file an .exe into an appropriate directory tree > self.runCmd("platform select remote-linux --sysroot '%s'" % sysroot) > target = self.dbg.CreateTarget(None) > process = target.LoadCode(core) > self.assertEquals(1, target.GetNumModules()) > self.assertEquals(exe, target.GetModuleAtIndex(0).GetFileSpec()) > I am going on vacation till the end of August and I still have something to do at work. Most likely I will not have a chance to look at it until I am back. https://reviews.llvm.org/D49685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50015: Remove unnecessary newlines from break command help text.
teemperor created this revision. We usually don't have trailing newlines in the short help strings. This just adds unnecessary extra lines when printing the help text of these commands. https://reviews.llvm.org/D50015 Files: source/Interpreter/CommandInterpreter.cpp Index: source/Interpreter/CommandInterpreter.cpp === --- source/Interpreter/CommandInterpreter.cpp +++ source/Interpreter/CommandInterpreter.cpp @@ -478,7 +478,7 @@ std::unique_ptr break_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-break", - "Set a breakpoint using one of several shorthand formats.\n", + "Set a breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " @@ -527,7 +527,7 @@ std::unique_ptr tbreak_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-tbreak", - "Set a one-shot breakpoint using one of several shorthand formats.\n", + "Set a one-shot breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " Index: source/Interpreter/CommandInterpreter.cpp === --- source/Interpreter/CommandInterpreter.cpp +++ source/Interpreter/CommandInterpreter.cpp @@ -478,7 +478,7 @@ std::unique_ptr break_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-break", - "Set a breakpoint using one of several shorthand formats.\n", + "Set a breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " @@ -527,7 +527,7 @@ std::unique_ptr tbreak_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-tbreak", - "Set a one-shot breakpoint using one of several shorthand formats.\n", + "Set a one-shot breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338311 - Remove unnecessary newlines from break command help text.
Author: teemperor Date: Mon Jul 30 14:41:13 2018 New Revision: 338311 URL: http://llvm.org/viewvc/llvm-project?rev=338311&view=rev Log: Remove unnecessary newlines from break command help text. Summary: We usually don't have trailing newlines in the short help strings. This just adds unnecessary extra lines when printing the help text of these commands. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D50015 Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=338311&r1=338310&r2=338311&view=diff == --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Jul 30 14:41:13 2018 @@ -478,7 +478,7 @@ void CommandInterpreter::LoadCommandDict std::unique_ptr break_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-break", - "Set a breakpoint using one of several shorthand formats.\n", + "Set a breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " @@ -527,7 +527,7 @@ void CommandInterpreter::LoadCommandDict std::unique_ptr tbreak_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-tbreak", - "Set a one-shot breakpoint using one of several shorthand formats.\n", + "Set a one-shot breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50015: Remove unnecessary newlines from break command help text.
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rL338311: Remove unnecessary newlines from break command help text. (authored by teemperor, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50015?vs=158076&id=158081#toc Repository: rL LLVM https://reviews.llvm.org/D50015 Files: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp === --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp @@ -478,7 +478,7 @@ std::unique_ptr break_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-break", - "Set a breakpoint using one of several shorthand formats.\n", + "Set a breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " @@ -527,7 +527,7 @@ std::unique_ptr tbreak_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-tbreak", - "Set a one-shot breakpoint using one of several shorthand formats.\n", + "Set a one-shot breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp === --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp @@ -478,7 +478,7 @@ std::unique_ptr break_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-break", - "Set a breakpoint using one of several shorthand formats.\n", + "Set a breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " @@ -527,7 +527,7 @@ std::unique_ptr tbreak_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-tbreak", - "Set a one-shot breakpoint using one of several shorthand formats.\n", + "Set a one-shot breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64
teemperor created this revision. Note: We don't have a unittest for Stream yet, so the regression test for this will be added with the upcoming Stream unit test. https://reviews.llvm.org/D50025 Files: source/Utility/Stream.cpp Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -427,11 +427,11 @@ case 1: return PutHex8((uint8_t)uvalue); case 2: -return PutHex16((uint16_t)uvalue); +return PutHex16((uint16_t)uvalue, byte_order); case 4: -return PutHex32((uint32_t)uvalue); +return PutHex32((uint32_t)uvalue, byte_order); case 8: -return PutHex64(uvalue); +return PutHex64(uvalue, byte_order); } return 0; } Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -427,11 +427,11 @@ case 1: return PutHex8((uint8_t)uvalue); case 2: -return PutHex16((uint16_t)uvalue); +return PutHex16((uint16_t)uvalue, byte_order); case 4: -return PutHex32((uint32_t)uvalue); +return PutHex32((uint32_t)uvalue, byte_order); case 8: -return PutHex64(uvalue); +return PutHex64(uvalue, byte_order); } return 0; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50026: Remove Stream::UnitTest
teemperor created this revision. No one is using this method, and it also doesn't really make a lot of sense to have it around. https://reviews.llvm.org/D50026 Files: include/lldb/Utility/Stream.h source/Utility/Stream.cpp Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -526,48 +526,3 @@ m_flags.Set(eBinary); return bytes_written; } - -void Stream::UnitTest(Stream *s) { - s->PutHex8(0x12); - - s->PutChar(' '); - s->PutHex16(0x3456, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderBig); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex32(0x789abcde, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderBig); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderBig); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderLittle); - - const char *hola = "Hello World!!!"; - s->PutChar(' '); - s->PutCString(hola); - - s->PutChar(' '); - s->Write(hola, 5); - - s->PutChar(' '); - s->PutCStringAsRawHex8(hola); - - s->PutChar(' '); - s->PutCStringAsRawHex8("01234"); - - s->PutChar(' '); - s->Printf("pid=%i", 12733); - - s->PutChar(' '); - s->PrintfAsRawHex8("pid=%i", 12733); - s->PutChar('\n'); -} Index: include/lldb/Utility/Stream.h === --- include/lldb/Utility/Stream.h +++ include/lldb/Utility/Stream.h @@ -524,8 +524,6 @@ //-- size_t PutULEB128(uint64_t uval); - static void UnitTest(Stream *s); - protected: //-- // Member variables Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -526,48 +526,3 @@ m_flags.Set(eBinary); return bytes_written; } - -void Stream::UnitTest(Stream *s) { - s->PutHex8(0x12); - - s->PutChar(' '); - s->PutHex16(0x3456, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderBig); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex32(0x789abcde, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderBig); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderBig); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderLittle); - - const char *hola = "Hello World!!!"; - s->PutChar(' '); - s->PutCString(hola); - - s->PutChar(' '); - s->Write(hola, 5); - - s->PutChar(' '); - s->PutCStringAsRawHex8(hola); - - s->PutChar(' '); - s->PutCStringAsRawHex8("01234"); - - s->PutChar(' '); - s->Printf("pid=%i", 12733); - - s->PutChar(' '); - s->PrintfAsRawHex8("pid=%i", 12733); - s->PutChar('\n'); -} Index: include/lldb/Utility/Stream.h === --- include/lldb/Utility/Stream.h +++ include/lldb/Utility/Stream.h @@ -524,8 +524,6 @@ //-- size_t PutULEB128(uint64_t uval); - static void UnitTest(Stream *s); - protected: //-- // Member variables ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49271: Adding libc++ formattors for std::optional
shafik updated this revision to Diff 158121. shafik added a comment. Adjust test to filter on clang version and libc++ version to precent build bots from failing due to lack of C++17 or lack of optional support https://reviews.llvm.org/D49271 Files: lldb.xcodeproj/project.pbxproj packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp source/Plugins/Language/CPlusPlus/CMakeLists.txt source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/CPlusPlus/LibCxx.cpp source/Plugins/Language/CPlusPlus/LibCxx.h source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp Index: source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp === --- /dev/null +++ source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp @@ -0,0 +1,85 @@ +//===-- LibCxxOptional.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "LibCxx.h" +#include "lldb/DataFormatters/FormattersHelpers.h" + +using namespace lldb; +using namespace lldb_private; + +namespace { + +class OptionalFrontEnd : public SyntheticChildrenFrontEnd { +public: + OptionalFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) { +Update(); + } + + size_t GetIndexOfChildWithName(const ConstString &name) override { +return formatters::ExtractIndexFromString(name.GetCString()); + } + + bool MightHaveChildren() override { return true; } + bool Update() override; + size_t CalculateNumChildren() override { return m_size; } + ValueObjectSP GetChildAtIndex(size_t idx) override; + +private: + size_t m_size = 0; + ValueObjectSP m_base_sp; +}; +} // namespace + +bool OptionalFrontEnd::Update() { + ValueObjectSP engaged_sp( + m_backend.GetChildMemberWithName(ConstString("__engaged_"), true)); + + if (!engaged_sp) +return false; + + // __engaged_ is a bool flag and is true if the optional contains a value. + // Converting it to unsigned gives us a size of 1 if it contains a value + // and 0 if not. + m_size = engaged_sp->GetValueAsUnsigned(0); + + return false; +} + +ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) { + if (idx >= m_size) +return ValueObjectSP(); + + // __val_ contains the underlying value of an optional if it has one. + // Currently because it is part of an anonymous union GetChildMemberWithName() + // does not peer through and find it unless we are at the parent itself. + // We can obtain the parent through __engaged_. + ValueObjectSP val_sp( + m_backend.GetChildMemberWithName(ConstString("__engaged_"), true) + ->GetParent() + ->GetChildAtIndex(0, true) + ->GetChildMemberWithName(ConstString("__val_"), true)); + + if (!val_sp) +return ValueObjectSP(); + + CompilerType holder_type = val_sp->GetCompilerType(); + + if (!holder_type) +return ValueObjectSP(); + + return val_sp->Clone(ConstString(llvm::formatv("Value").str())); +} + +SyntheticChildrenFrontEnd * +formatters::LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *, + lldb::ValueObjectSP valobj_sp) { + if (valobj_sp) +return new OptionalFrontEnd(*valobj_sp); + return nullptr; +} Index: source/Plugins/Language/CPlusPlus/LibCxx.h === --- source/Plugins/Language/CPlusPlus/LibCxx.h +++ source/Plugins/Language/CPlusPlus/LibCxx.h @@ -27,6 +27,10 @@ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); // libc++ std::wstring +bool LibcxxOptionalSummaryProvider( +ValueObject &valobj, Stream &stream, +const TypeSummaryOptions &options); // libc++ std::optional<> + bool LibcxxSmartPointerSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions @@ -133,6 +137,10 @@ SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP); +SyntheticChildrenFrontEnd * +LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *, + lldb::ValueObjectSP valobj_sp); + } // namespace formatters } // namespace lldb_private Index: source/Plugins/Language/CPlusPlus/LibCxx.cpp === --- source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -33,6 +33,28 @@ using namespace lldb_pri
[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64
zturner added a comment. When is the Stream unit test coming? Maybe we should just add it first, then add this? https://reviews.llvm.org/D50025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49271: Adding libc++ formattors for std::optional
shafik added a comment. @davide @labath I believe I have addressed both the C++17 filter and the libc++ filter. Please let me know if you have further comments. https://reviews.llvm.org/D49271 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50027: Added initial unit test for LLDB's Stream class.
teemperor created this revision. Herald added a subscriber: mgorny. This adds an initial small unit test for LLDB's Stream class, which should at least cover most of the functions in the Stream class. StreamString is always in big endian mode, so that's the only stream byte order path this test covers as of now. Also, the binary mode still needs to be tested for all print methods. Also adds some FIXMEs for wrong/strange result values of the Stream class that we hit while testing those functions. https://reviews.llvm.org/D50027 Files: unittests/Utility/CMakeLists.txt unittests/Utility/StreamTest.cpp Index: unittests/Utility/StreamTest.cpp === --- /dev/null +++ unittests/Utility/StreamTest.cpp @@ -0,0 +1,504 @@ +//===-- StreamTest.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/StreamString.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +namespace { +struct StreamTest : ::testing::Test { + // Note: Stream is an abstract class, so we use StreamString to test it. To + // make it easier to change this later, only methods in this class explicitly + // refer to the StringStream class. + StreamString s; + // We return here a std::string because that way gtest can print better + // assertion messages. + std::string Value() const { +return s.GetString().str(); + } +}; +} + +namespace { +// A StreamTest where we expect the Stream output to be binary. +struct BinaryStreamTest : StreamTest { + void SetUp() override { +s.GetFlags().Set(Stream::eBinary); + } +}; +} + +TEST_F(StreamTest, ChangingByteOrder) { + s.SetByteOrder(lldb::eByteOrderPDP); + EXPECT_EQ(lldb::eByteOrderPDP, s.GetByteOrder()); +} + +TEST_F(StreamTest, PutChar) { + s.PutChar('a'); + EXPECT_EQ("a", Value()); + + s.PutChar('1'); + EXPECT_EQ("a1", Value()); +} + +TEST_F(StreamTest, PutCharWhitespace) { + s.PutChar(' '); + EXPECT_EQ(" ", Value()); + + s.PutChar('\n'); + EXPECT_EQ(" \n", Value()); + + s.PutChar('\r'); + EXPECT_EQ(" \n\r", Value()); + + s.PutChar('\t'); + EXPECT_EQ(" \n\r\t", Value()); +} + +TEST_F(StreamTest, PutCString) { + s.PutCString(""); + EXPECT_EQ("", Value()); + + s.PutCString("foobar"); + EXPECT_EQ("foobar", Value()); + + s.PutCString(" "); + EXPECT_EQ("foobar ", Value()); +} + +TEST_F(StreamTest, PutCStringWithStringRef) { + s.PutCString(llvm::StringRef("")); + EXPECT_EQ("", Value()); + + s.PutCString(llvm::StringRef("foobar")); + EXPECT_EQ("foobar", Value()); + + s.PutCString(llvm::StringRef(" ")); + EXPECT_EQ("foobar ", Value()); +} + +TEST_F(StreamTest, QuotedCString) { + s.QuotedCString("foo"); + EXPECT_EQ("\"foo\"", Value()); + + s.QuotedCString("bar"); + EXPECT_EQ("\"foo\"\"bar\"", Value()); + + s.QuotedCString(" "); + EXPECT_EQ("\"foo\"\"bar\"\" \"", Value()); +} + +TEST_F(StreamTest, PutCharNull) { + s.PutChar('\0'); + EXPECT_EQ(std::string("\0", 1), Value()); + + s.PutChar('a'); + EXPECT_EQ(std::string("\0a", 2), Value()); +} + +TEST_F(StreamTest, PutCStringAsRawHex8) { + s.PutCStringAsRawHex8(""); + // FIXME: Check that printing 00 on an empty string is the intended behavior. + // It seems kind of unexpected that we print the trailing 0 byte for empty + // strings, but not for non-empty strings. + EXPECT_EQ("00", Value()); + + s.PutCStringAsRawHex8("foobar"); + EXPECT_EQ("00666f6f626172", Value()); + + s.PutCStringAsRawHex8(" "); + EXPECT_EQ("00666f6f62617220", Value()); +} + +TEST_F(StreamTest, PutHex8) { + s.PutHex8((uint8_t)55); + EXPECT_EQ("37", Value()); + s.PutHex8(std::numeric_limits::max()); + EXPECT_EQ("37ff", Value()); + s.PutHex8((uint8_t)0); + EXPECT_EQ("37ff00", Value()); +} + +TEST_F(StreamTest, PutNHex8) { + s.PutNHex8(0, (uint8_t)55); + EXPECT_EQ("", Value()); + s.PutNHex8(1, (uint8_t)55); + EXPECT_EQ("37", Value()); + s.PutNHex8(2, (uint8_t)55); + EXPECT_EQ("373737", Value()); + s.PutNHex8(1, (uint8_t)56); + EXPECT_EQ("37373738", Value()); +} + +TEST_F(StreamTest, PutHex16ByteOrderLittle) { + s.PutHex16(0x1234U, lldb::eByteOrderLittle); + EXPECT_EQ("3412", Value()); + s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderLittle); + EXPECT_EQ("3412", Value()); + s.PutHex16(0U, lldb::eByteOrderLittle); + EXPECT_EQ("3412", Value()); +} + +TEST_F(StreamTest, PutHex16ByteOrderBig) { + s.PutHex16(0x1234U, lldb::eByteOrderBig); + EXPECT_EQ("1234", Value()); + s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderBig); + EXPECT_EQ("1234", Value()); + s.PutHex16(0U, lldb::eByteOrderBig); + EXPECT_EQ("1234", Value()); +} + +TEST_F(StreamTest, PutHex32ByteOrderLittle) { + s.PutHex32(0x12345678U, lldb::eByte
[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64
teemperor added a comment. Yeah, on a second thought I should just strip out the parts of the unit test that found this bug and commit them alongside this. https://reviews.llvm.org/D50025 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64
teemperor updated this revision to Diff 158126. teemperor edited the summary of this revision. teemperor added a comment. - Reverse patch dependencies that we can add the unit test here (but also means this has to wait until the StreamTest is in). https://reviews.llvm.org/D50025 Files: source/Utility/Stream.cpp unittests/Utility/StreamTest.cpp Index: unittests/Utility/StreamTest.cpp === --- unittests/Utility/StreamTest.cpp +++ unittests/Utility/StreamTest.cpp @@ -191,6 +191,32 @@ EXPECT_EQ("1234567890abcdef", Value()); } +TEST_F(StreamTest, PutMaxHex64ByteOrderBig) { + std::size_t bytes; + bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig); + EXPECT_EQ(2U, bytes); + bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig); + EXPECT_EQ(4U, bytes); + bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig); + EXPECT_EQ(8U, bytes); + bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig); + EXPECT_EQ(16U, bytes); + EXPECT_EQ("121234123456781234567890abcdef", Value()); +} + +TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) { + std::size_t bytes; + bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle); + EXPECT_EQ(2U, bytes); + bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle); + EXPECT_EQ(4U, bytes); + bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle); + EXPECT_EQ(8U, bytes); + bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle); + EXPECT_EQ(16U, bytes); + EXPECT_EQ("12341278563412efcdab9078563412", Value()); +} + //-- // Shift operator tests. //-- Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -427,11 +427,11 @@ case 1: return PutHex8((uint8_t)uvalue); case 2: -return PutHex16((uint16_t)uvalue); +return PutHex16((uint16_t)uvalue, byte_order); case 4: -return PutHex32((uint32_t)uvalue); +return PutHex32((uint32_t)uvalue, byte_order); case 8: -return PutHex64(uvalue); +return PutHex64(uvalue, byte_order); } return 0; } Index: unittests/Utility/StreamTest.cpp === --- unittests/Utility/StreamTest.cpp +++ unittests/Utility/StreamTest.cpp @@ -191,6 +191,32 @@ EXPECT_EQ("1234567890abcdef", Value()); } +TEST_F(StreamTest, PutMaxHex64ByteOrderBig) { + std::size_t bytes; + bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig); + EXPECT_EQ(2U, bytes); + bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig); + EXPECT_EQ(4U, bytes); + bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig); + EXPECT_EQ(8U, bytes); + bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig); + EXPECT_EQ(16U, bytes); + EXPECT_EQ("121234123456781234567890abcdef", Value()); +} + +TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) { + std::size_t bytes; + bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle); + EXPECT_EQ(2U, bytes); + bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle); + EXPECT_EQ(4U, bytes); + bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle); + EXPECT_EQ(8U, bytes); + bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle); + EXPECT_EQ(16U, bytes); + EXPECT_EQ("12341278563412efcdab9078563412", Value()); +} + //-- // Shift operator tests. //-- Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -427,11 +427,11 @@ case 1: return PutHex8((uint8_t)uvalue); case 2: -return PutHex16((uint16_t)uvalue); +return PutHex16((uint16_t)uvalue, byte_order); case 4: -return PutHex32((uint32_t)uvalue); +return PutHex32((uint32_t)uvalue, byte_order); case 8: -return PutHex64(uvalue); +return PutHex64(uvalue, byte_order); } return 0; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50027: Added initial unit test for LLDB's Stream class.
teemperor updated this revision to Diff 158127. teemperor added a comment. - Removed MaxHex64 test (which moved to the child revision to be in the same commit as the related bug). https://reviews.llvm.org/D50027 Files: unittests/Utility/CMakeLists.txt unittests/Utility/StreamTest.cpp Index: unittests/Utility/StreamTest.cpp === --- /dev/null +++ unittests/Utility/StreamTest.cpp @@ -0,0 +1,478 @@ +//===-- StreamTest.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/StreamString.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +namespace { +struct StreamTest : ::testing::Test { + // Note: Stream is an abstract class, so we use StreamString to test it. To + // make it easier to change this later, only methods in this class explicitly + // refer to the StringStream class. + StreamString s; + // We return here a std::string because that way gtest can print better + // assertion messages. + std::string Value() const { +return s.GetString().str(); + } +}; +} + +namespace { +// A StreamTest where we expect the Stream output to be binary. +struct BinaryStreamTest : StreamTest { + void SetUp() override { +s.GetFlags().Set(Stream::eBinary); + } +}; +} + +TEST_F(StreamTest, ChangingByteOrder) { + s.SetByteOrder(lldb::eByteOrderPDP); + EXPECT_EQ(lldb::eByteOrderPDP, s.GetByteOrder()); +} + +TEST_F(StreamTest, PutChar) { + s.PutChar('a'); + EXPECT_EQ("a", Value()); + + s.PutChar('1'); + EXPECT_EQ("a1", Value()); +} + +TEST_F(StreamTest, PutCharWhitespace) { + s.PutChar(' '); + EXPECT_EQ(" ", Value()); + + s.PutChar('\n'); + EXPECT_EQ(" \n", Value()); + + s.PutChar('\r'); + EXPECT_EQ(" \n\r", Value()); + + s.PutChar('\t'); + EXPECT_EQ(" \n\r\t", Value()); +} + +TEST_F(StreamTest, PutCString) { + s.PutCString(""); + EXPECT_EQ("", Value()); + + s.PutCString("foobar"); + EXPECT_EQ("foobar", Value()); + + s.PutCString(" "); + EXPECT_EQ("foobar ", Value()); +} + +TEST_F(StreamTest, PutCStringWithStringRef) { + s.PutCString(llvm::StringRef("")); + EXPECT_EQ("", Value()); + + s.PutCString(llvm::StringRef("foobar")); + EXPECT_EQ("foobar", Value()); + + s.PutCString(llvm::StringRef(" ")); + EXPECT_EQ("foobar ", Value()); +} + +TEST_F(StreamTest, QuotedCString) { + s.QuotedCString("foo"); + EXPECT_EQ("\"foo\"", Value()); + + s.QuotedCString("bar"); + EXPECT_EQ("\"foo\"\"bar\"", Value()); + + s.QuotedCString(" "); + EXPECT_EQ("\"foo\"\"bar\"\" \"", Value()); +} + +TEST_F(StreamTest, PutCharNull) { + s.PutChar('\0'); + EXPECT_EQ(std::string("\0", 1), Value()); + + s.PutChar('a'); + EXPECT_EQ(std::string("\0a", 2), Value()); +} + +TEST_F(StreamTest, PutCStringAsRawHex8) { + s.PutCStringAsRawHex8(""); + // FIXME: Check that printing 00 on an empty string is the intended behavior. + // It seems kind of unexpected that we print the trailing 0 byte for empty + // strings, but not for non-empty strings. + EXPECT_EQ("00", Value()); + + s.PutCStringAsRawHex8("foobar"); + EXPECT_EQ("00666f6f626172", Value()); + + s.PutCStringAsRawHex8(" "); + EXPECT_EQ("00666f6f62617220", Value()); +} + +TEST_F(StreamTest, PutHex8) { + s.PutHex8((uint8_t)55); + EXPECT_EQ("37", Value()); + s.PutHex8(std::numeric_limits::max()); + EXPECT_EQ("37ff", Value()); + s.PutHex8((uint8_t)0); + EXPECT_EQ("37ff00", Value()); +} + +TEST_F(StreamTest, PutNHex8) { + s.PutNHex8(0, (uint8_t)55); + EXPECT_EQ("", Value()); + s.PutNHex8(1, (uint8_t)55); + EXPECT_EQ("37", Value()); + s.PutNHex8(2, (uint8_t)55); + EXPECT_EQ("373737", Value()); + s.PutNHex8(1, (uint8_t)56); + EXPECT_EQ("37373738", Value()); +} + +TEST_F(StreamTest, PutHex16ByteOrderLittle) { + s.PutHex16(0x1234U, lldb::eByteOrderLittle); + EXPECT_EQ("3412", Value()); + s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderLittle); + EXPECT_EQ("3412", Value()); + s.PutHex16(0U, lldb::eByteOrderLittle); + EXPECT_EQ("3412", Value()); +} + +TEST_F(StreamTest, PutHex16ByteOrderBig) { + s.PutHex16(0x1234U, lldb::eByteOrderBig); + EXPECT_EQ("1234", Value()); + s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderBig); + EXPECT_EQ("1234", Value()); + s.PutHex16(0U, lldb::eByteOrderBig); + EXPECT_EQ("1234", Value()); +} + +TEST_F(StreamTest, PutHex32ByteOrderLittle) { + s.PutHex32(0x12345678U, lldb::eByteOrderLittle); + EXPECT_EQ("78563412", Value()); + s.PutHex32(std::numeric_limits::max(), lldb::eByteOrderLittle); + EXPECT_EQ("78563412", Value()); + s.PutHex32(0U, lldb::eByteOrderLittle); + EXPECT_EQ("78563412", Value()); +} + +TEST_F(StreamTest, PutHex32ByteOrderBig) { + s.PutHex32(0x123456
[Lldb-commits] [PATCH] D50026: Remove Stream::UnitTest
davide accepted this revision. davide added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D50026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338345 - Remove Stream::UnitTest
Author: teemperor Date: Mon Jul 30 18:21:36 2018 New Revision: 338345 URL: http://llvm.org/viewvc/llvm-project?rev=338345&view=rev Log: Remove Stream::UnitTest Summary: No one is using this method, and it also doesn't really make a lot of sense to have it around. Reviewers: davide Reviewed By: davide Subscribers: davide, lldb-commits Differential Revision: https://reviews.llvm.org/D50026 Modified: lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/source/Utility/Stream.cpp Modified: lldb/trunk/include/lldb/Utility/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Stream.h?rev=338345&r1=338344&r2=338345&view=diff == --- lldb/trunk/include/lldb/Utility/Stream.h (original) +++ lldb/trunk/include/lldb/Utility/Stream.h Mon Jul 30 18:21:36 2018 @@ -524,8 +524,6 @@ public: //-- size_t PutULEB128(uint64_t uval); - static void UnitTest(Stream *s); - protected: //-- // Member variables Modified: lldb/trunk/source/Utility/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338345&r1=338344&r2=338345&view=diff == --- lldb/trunk/source/Utility/Stream.cpp (original) +++ lldb/trunk/source/Utility/Stream.cpp Mon Jul 30 18:21:36 2018 @@ -526,48 +526,3 @@ size_t Stream::PutCStringAsRawHex8(const m_flags.Set(eBinary); return bytes_written; } - -void Stream::UnitTest(Stream *s) { - s->PutHex8(0x12); - - s->PutChar(' '); - s->PutHex16(0x3456, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderBig); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex32(0x789abcde, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderBig); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderBig); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderLittle); - - const char *hola = "Hello World!!!"; - s->PutChar(' '); - s->PutCString(hola); - - s->PutChar(' '); - s->Write(hola, 5); - - s->PutChar(' '); - s->PutCStringAsRawHex8(hola); - - s->PutChar(' '); - s->PutCStringAsRawHex8("01234"); - - s->PutChar(' '); - s->Printf("pid=%i", 12733); - - s->PutChar(' '); - s->PrintfAsRawHex8("pid=%i", 12733); - s->PutChar('\n'); -} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50026: Remove Stream::UnitTest
This revision was automatically updated to reflect the committed changes. Closed by commit rL338345: Remove Stream::UnitTest (authored by teemperor, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50026?vs=158120&id=158151#toc Repository: rL LLVM https://reviews.llvm.org/D50026 Files: lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/source/Utility/Stream.cpp Index: lldb/trunk/source/Utility/Stream.cpp === --- lldb/trunk/source/Utility/Stream.cpp +++ lldb/trunk/source/Utility/Stream.cpp @@ -526,48 +526,3 @@ m_flags.Set(eBinary); return bytes_written; } - -void Stream::UnitTest(Stream *s) { - s->PutHex8(0x12); - - s->PutChar(' '); - s->PutHex16(0x3456, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderBig); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex32(0x789abcde, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderBig); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderBig); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderLittle); - - const char *hola = "Hello World!!!"; - s->PutChar(' '); - s->PutCString(hola); - - s->PutChar(' '); - s->Write(hola, 5); - - s->PutChar(' '); - s->PutCStringAsRawHex8(hola); - - s->PutChar(' '); - s->PutCStringAsRawHex8("01234"); - - s->PutChar(' '); - s->Printf("pid=%i", 12733); - - s->PutChar(' '); - s->PrintfAsRawHex8("pid=%i", 12733); - s->PutChar('\n'); -} Index: lldb/trunk/include/lldb/Utility/Stream.h === --- lldb/trunk/include/lldb/Utility/Stream.h +++ lldb/trunk/include/lldb/Utility/Stream.h @@ -524,8 +524,6 @@ //-- size_t PutULEB128(uint64_t uval); - static void UnitTest(Stream *s); - protected: //-- // Member variables Index: lldb/trunk/source/Utility/Stream.cpp === --- lldb/trunk/source/Utility/Stream.cpp +++ lldb/trunk/source/Utility/Stream.cpp @@ -526,48 +526,3 @@ m_flags.Set(eBinary); return bytes_written; } - -void Stream::UnitTest(Stream *s) { - s->PutHex8(0x12); - - s->PutChar(' '); - s->PutHex16(0x3456, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderBig); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex32(0x789abcde, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderBig); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderBig); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderLittle); - - const char *hola = "Hello World!!!"; - s->PutChar(' '); - s->PutCString(hola); - - s->PutChar(' '); - s->Write(hola, 5); - - s->PutChar(' '); - s->PutCStringAsRawHex8(hola); - - s->PutChar(' '); - s->PutCStringAsRawHex8("01234"); - - s->PutChar(' '); - s->Printf("pid=%i", 12733); - - s->PutChar(' '); - s->PrintfAsRawHex8("pid=%i", 12733); - s->PutChar('\n'); -} Index: lldb/trunk/include/lldb/Utility/Stream.h === --- lldb/trunk/include/lldb/Utility/Stream.h +++ lldb/trunk/include/lldb/Utility/Stream.h @@ -524,8 +524,6 @@ //-- size_t PutULEB128(uint64_t uval); - static void UnitTest(Stream *s); - protected: //-- // Member variables ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50038: Introduce install-lldb-framework target
xiaobai created this revision. xiaobai added reviewers: labath, sas. Herald added a subscriber: mgorny. Previously, I thought that install-liblldb would fail because CMake had a bug related to installing frameworks. In actuality, I misunderstood the semantics of `add_custom_target`: the DEPENDS option refers to specific files, not targets. Therefore `install-liblldb` should rely on the actual liblldb getting generated rather than the target. This means that the previous patch I committed (to stop relying on CMake's framework support) is no longer needed and has been reverted. Using CMake's framework support greatly simplifies the implementation. `install-lldb-framework` (and the stripped variant) is as simple as depending on `install-liblldb` because CMake knows that liblldb was built as a framework and will install the whole framework for you. The stripped variant will depend on the stripped variants of individual tools only to ensure they actually are stripped as well. https://reviews.llvm.org/D50038 Files: CMakeLists.txt cmake/modules/AddLLDB.cmake cmake/modules/LLDBFramework.cmake source/API/CMakeLists.txt Index: source/API/CMakeLists.txt === --- source/API/CMakeLists.txt +++ source/API/CMakeLists.txt @@ -143,6 +143,17 @@ ) endif() +if (LLDB_BUILD_FRAMEWORK) + set_target_properties(liblldb +PROPERTIES +OUTPUT_NAME LLDB +FRAMEWORK On +FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} +MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist +LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_DIR} + ) +endif() + if (LLDB_WRAP_PYTHON) add_dependencies(liblldb swig_wrapper) endif() Index: cmake/modules/LLDBFramework.cmake === --- cmake/modules/LLDBFramework.cmake +++ cmake/modules/LLDBFramework.cmake @@ -31,14 +31,9 @@ ) endif() -set_target_properties(liblldb PROPERTIES - OUTPUT_NAME LLDB - FRAMEWORK On - FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} - MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR} - PUBLIC_HEADER "${framework_headers}") - add_dependencies(lldb-framework lldb-framework-headers lldb-suite) + +add_custom_target(install-lldb-framework) +add_custom_target(install-lldb-framework-stripped) Index: cmake/modules/AddLLDB.cmake === --- cmake/modules/AddLLDB.cmake +++ cmake/modules/AddLLDB.cmake @@ -53,6 +53,11 @@ set(out_dir lib${LLVM_LIBDIR_SUFFIX}) if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK) set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) + # The framework that is generated will install with install-liblldb + # because we enable CMake's framework support. CMake will copy all the + # headers and resources for us. + add_dependencies(install-lldb-framework install-${name}) + add_dependencies(install-lldb-framework-stripped install-${name}-stripped) endif() install(TARGETS ${name} COMPONENT ${name} @@ -67,12 +72,19 @@ endif() if (NOT CMAKE_CONFIGURATION_TYPES) add_llvm_install_targets(install-${name} - DEPENDS ${name} + DEPENDS $ COMPONENT ${name}) endif() endif() endif() + # install-liblldb{,-stripped} is the actual target that will install the + # framework, so it must rely on the framework being fully built first. + if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb") +add_dependencies(install-${name} lldb-framework) +add_dependencies(install-lldb-framework-stripped lldb-framework) + endif() + # Hack: only some LLDB libraries depend on the clang autogenerated headers, # but it is simple enough to make all of LLDB depend on some of those # headers without negatively impacting much of anything. @@ -124,6 +136,10 @@ set(out_dir "bin") if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE) set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}) + # While install-liblldb-stripped will handle copying the tools, it will + # not strip them. We depend on this target to guarantee a stripped version + # will get installed in the framework. + add_dependencies(install-lldb-framework-stripped install-${name}-stripped) endif() install(TARGETS ${name} COMPONENT ${name} Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -51,6 +51,7 @@ message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms") endif() + add_custom_target(lldb-framework) # These are used to fill out LLDB-Info.plist. These are rele
[Lldb-commits] [PATCH] D50038: Introduce install-lldb-framework target
xiaobai added a comment. Using this patch, I was able to build the lldb framework and install it. I configured with: cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLDB_CODESIGN_IDENTITY="" -DLLDB_BUILD_FRAMEWORK=1 -DLLDB_USE_SYSTEM_SIX=1 -DCMAKE_INSTALL_PREFIX="" -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" -DSKIP_DEBUGSERVER=1 -DLLVM_DISTRIBUTION_COMPONENTS="lldb;lldb-framework" and built with: DESTDIR=/Users/apl/code/llvm/build/tmp ninja install-distribution This built and installed lldb at DESTDIR. I used the installed lldb to debug a small test binary. https://reviews.llvm.org/D50038 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49969: DWZ 04/06: ManualDWARFIndex::GetGlobalVariables for DIEs in PUs
jankratochvil updated this revision to Diff 158176. https://reviews.llvm.org/D49969 Files: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h source/Plugins/SymbolFile/DWARF/NameToDIE.cpp source/Plugins/SymbolFile/DWARF/NameToDIE.h Index: source/Plugins/SymbolFile/DWARF/NameToDIE.h === --- source/Plugins/SymbolFile/DWARF/NameToDIE.h +++ source/Plugins/SymbolFile/DWARF/NameToDIE.h @@ -11,6 +11,7 @@ #define SymbolFileDWARF_NameToDIE_h_ #include +#include #include "DIERef.h" #include "lldb/Core/UniqueCStringMap.h" @@ -39,9 +40,16 @@ size_t Find(const lldb_private::RegularExpression ®ex, DIEArray &info_array) const; + size_t FindAllEntriesForCompileUnit( + std::function compare, DIEArray &info_array) const; + size_t FindAllEntriesForCompileUnit(dw_offset_t cu_offset, DIEArray &info_array) const; + size_t FindAllEntriesForCompileUnit( + const std::unordered_set &cu_offsets, + DIEArray &info_array) const; + void ForEach(std::function const Index: source/Plugins/SymbolFile/DWARF/NameToDIE.cpp === --- source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -39,18 +39,33 @@ return m_map.GetValues(regex, info_array); } -size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset, - DIEArray &info_array) const { +size_t NameToDIE::FindAllEntriesForCompileUnit( +std::function compare, DIEArray &info_array) const { const size_t initial_size = info_array.size(); const uint32_t size = m_map.GetSize(); for (uint32_t i = 0; i < size; ++i) { const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i); -if (cu_offset == die_ref.cu_offset) +if (compare(die_ref.cu_offset)) info_array.push_back(die_ref); } return info_array.size() - initial_size; } +size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset, + DIEArray &info_array) const { + return FindAllEntriesForCompileUnit([cu_offset](dw_offset_t offset) { +return offset == cu_offset; + }, info_array); +} + +size_t NameToDIE::FindAllEntriesForCompileUnit( +const std::unordered_set &cu_offsets, +DIEArray &info_array) const { + return FindAllEntriesForCompileUnit([&cu_offsets](dw_offset_t offset) { +return cu_offsets.count(offset) != 0; + }, info_array); +} + void NameToDIE::Dump(Stream *s) { const uint32_t size = m_map.GetSize(); for (uint32_t i = 0; i < size; ++i) { Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h === --- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h +++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h @@ -11,8 +11,12 @@ #define LLDB_MANUALDWARFINDEX_H #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" +#include "Plugins/SymbolFile/DWARF/DWARFUnit.h" #include "Plugins/SymbolFile/DWARF/NameToDIE.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/Support/RWMutex.h" + +#include namespace lldb_private { class ManualDWARFIndex : public DWARFIndex { @@ -22,6 +26,8 @@ : DWARFIndex(module), m_debug_info(debug_info), m_units_to_avoid(std::move(units_to_avoid)) {} + ~ManualDWARFIndex() override; + void Preload() override { Index(); } void GetGlobalVariables(ConstString basename, DIEArray &offsets) override; @@ -68,7 +74,19 @@ /// Which dwarf units should we skip while building the index. llvm::DenseSet m_units_to_avoid; + void AddExtractedPU(DWARFUnit &importer, DWARFUnit &importee); + IndexSet m_set; + + // All DW_TAG_partial_unit's extracted for Index-ing this DW_TAG_compile_unit. + struct ExtractedForUnit { +// FIXME: The pointer is already contained in the value; but we wound need +// a combination of DenseSet::insert_as and DenseSet::try_emplace. +std::unordered_map m_map; +llvm::sys::RWMutex m_mutex; + }; + std::unordered_map m_extracted_pu; + llvm::sys::RWMutex m_extracted_pu_mutex; }; } // namespace lldb_private Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp === --- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -409,6 +409,7 @@ break; } import_cu->SetMainCU(&main_unit); +AddExtractedPU(unit, *import_cu); IndexUnit(*import_cu,set); } break; @@ -433,7 +434,35 @@ void ManualDWARFIndex::GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) { Index(); - m_set.globals.FindAllEntriesForCompileUnit(cu.GetOffset(), offsets); + if (m_extracted_pu.empty()) { +