[Lldb-commits] [lldb] bbea361 - [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB
Author: Raphael Isemann Date: 2021-05-18T09:41:20+02:00 New Revision: bbea361039c11dc2e6e281c80fa8aa569f1c7c2d URL: https://github.com/llvm/llvm-project/commit/bbea361039c11dc2e6e281c80fa8aa569f1c7c2d DIFF: https://github.com/llvm/llvm-project/commit/bbea361039c11dc2e6e281c80fa8aa569f1c7c2d.diff LOG: [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB A long time ago LLDB wanted to start using StringRef instead of C-Strings/ConstString but was blocked by the fact that the StringRef constructor that takes a C-string was asserting that the C-string isn't a nullptr. To workaround this, D24697 introduced a special function called `withNullAsEmpty` and that's what LLDB (and only LLDB) started to use to build StringRefs from C-strings. A bit later it seems that `withNullAsEmpty` was declared too awkward to use and instead the assert in the StringRef constructor got removed (see D24904). The rest of LLDB was then converted to StringRef by just calling the now perfectly usable implicit constructor. However, all the calls to `withNullAsEmpty` just remained and are now just strange artefacts in the code base that just look out of place. It's also curiously a LLDB-exclusive function and no other project ever called it since it's introduction half a decade ago. This patch removes all uses of `withNullAsEmpty`. The follow up will be to remove the function from StringRef. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D102597 Added: Modified: lldb/include/lldb/Interpreter/OptionValueRegex.h lldb/include/lldb/Interpreter/OptionValueString.h lldb/source/API/SBDebugger.cpp lldb/source/API/SBLanguageRuntime.cpp lldb/source/API/SBPlatform.cpp lldb/source/API/SBTypeCategory.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValue.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/source/Target/ThreadPlanStepInRange.cpp Removed: diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h b/lldb/include/lldb/Interpreter/OptionValueRegex.h index 9eb0247e0405f..129987484f195 100644 --- a/lldb/include/lldb/Interpreter/OptionValueRegex.h +++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h @@ -17,8 +17,7 @@ namespace lldb_private { class OptionValueRegex : public Cloneable { public: OptionValueRegex(const char *value = nullptr) - : m_regex(llvm::StringRef::withNullAsEmpty(value)), -m_default_regex_str(llvm::StringRef::withNullAsEmpty(value).str()) {} + : m_regex(value), m_default_regex_str(value) {} ~OptionValueRegex() override = default; diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h b/lldb/include/lldb/Interpreter/OptionValueString.h index 5611b58490971..be42deb80da77 100644 --- a/lldb/include/lldb/Interpreter/OptionValueString.h +++ b/lldb/include/lldb/Interpreter/OptionValueString.h @@ -85,7 +85,7 @@ class OptionValueString : public Cloneable { const Flags &GetOptions() const { return m_options; } const char *operator=(const char *value) { -SetCurrentValue(llvm::StringRef::withNullAsEmpty(value)); +SetCurrentValue(value); return m_current_value.c_str(); } diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 8bbb89516a0a9..8c84c5ffe9a2c 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1387,7 +1387,7 @@ void SBDebugger::SetPrompt(const char *prompt) { LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); if (m_opaque_sp) -m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); +m_opaque_sp->SetPrompt(llvm::StringRef(prompt)); } const char *SBDebugger::GetReproducerPath() const { diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index 33c900d20c31a..e65b58270517d 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -18,8 +18,7 @@ SBLanguageRuntime::GetLanguageTypeFromString(const char *string) { LLDB_RECORD_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, GetLanguageTypeFromString, (const char *), string); - return Language::GetLanguageTypeFromString( - llvm::StringRef::withNullAsEmpty(string)); + return Language::GetLanguageTypeFromString(llvm::StringRef(string)); } const char * diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index f118048156b96..7043367b13438 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -413,8 +413,7 @@ SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions
[Lldb-commits] [PATCH] D102597: [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGbbea361039c1: [lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB (authored by teemperor). Herald added a subscriber: lldb-commits. Changed prior to commit: https://reviews.llvm.org/D102597?vs=345772&id=346064#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102597/new/ https://reviews.llvm.org/D102597 Files: lldb/include/lldb/Interpreter/OptionValueRegex.h lldb/include/lldb/Interpreter/OptionValueString.h lldb/source/API/SBDebugger.cpp lldb/source/API/SBLanguageRuntime.cpp lldb/source/API/SBPlatform.cpp lldb/source/API/SBTypeCategory.cpp lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/OptionValue.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/source/Target/ThreadPlanStepInRange.cpp Index: lldb/source/Target/ThreadPlanStepInRange.cpp === --- lldb/source/Target/ThreadPlanStepInRange.cpp +++ lldb/source/Target/ThreadPlanStepInRange.cpp @@ -291,11 +291,10 @@ } void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) { - auto name_ref = llvm::StringRef::withNullAsEmpty(name); if (m_avoid_regexp_up) -*m_avoid_regexp_up = RegularExpression(name_ref); +*m_avoid_regexp_up = RegularExpression(name); else -m_avoid_regexp_up = std::make_unique(name_ref); +m_avoid_regexp_up = std::make_unique(name); } void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) { Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp === --- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -663,8 +663,8 @@ case 0: break; case 1: { - regex_up = std::make_unique( - llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0))); + regex_up = + std::make_unique(command.GetArgumentAtIndex(0)); if (!regex_up->IsValid()) { result.AppendError( "invalid argument - please provide a valid regular expression"); Index: lldb/source/Interpreter/OptionValue.cpp === --- lldb/source/Interpreter/OptionValue.cpp +++ lldb/source/Interpreter/OptionValue.cpp @@ -543,8 +543,7 @@ } if (value_sp) -error = value_sp->SetValueFromString( -llvm::StringRef::withNullAsEmpty(value_cstr), eVarSetOperationAssign); +error = value_sp->SetValueFromString(value_cstr, eVarSetOperationAssign); else error.SetErrorString("unsupported type mask"); return value_sp; Index: lldb/source/Interpreter/CommandInterpreter.cpp === --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -2986,9 +2986,9 @@ IOHandlerSP io_handler_sp( new IOHandlerEditline(debugger, IOHandler::Type::CommandList, "lldb", // Name of input reader for history -llvm::StringRef::withNullAsEmpty(prompt), // Prompt -llvm::StringRef(), // Continuation prompt -true, // Get multiple lines +llvm::StringRef(prompt), // Prompt +llvm::StringRef(), // Continuation prompt +true,// Get multiple lines debugger.GetUseColor(), 0, // Don't show line numbers delegate, // IOHandlerDelegate @@ -3006,9 +3006,9 @@ IOHandlerSP io_handler_sp( new IOHandlerEditline(debugger, IOHandler::Type::PythonCode, "lldb-python", // Name of input reader for history -llvm::StringRef::withNullAsEmpty(prompt), // Prompt -llvm::StringRef(), // Continuation prompt -true, // Get multiple lines +llvm::StringRef(prompt), // Prompt +llvm::StringRef(), // Continuation prompt +true,// Get multiple lines debugger.GetUseColor(), 0, // Don't show line numbers delegate, // IOHandlerDelegate Index: lldb/sourc
[Lldb-commits] [PATCH] D102428: [StopInfoMachException] Summarize arm64e BLRAx/LDRAx auth failures
DavidSpickett added inline comments. Comment at: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:126 +Address brk_address; +if (!target.ResolveLoadAddress(fixed_bad_address, brk_address)) + return false; vsk wrote: > DavidSpickett wrote: > > vsk wrote: > > > DavidSpickett wrote: > > > > What does it mean here that the address failed to resolve? > > > It's possible that lldb doesn't know about the image the fixed address > > > points to (it could be a garbage value). In this case we conservatively > > > don't hint that there's a ptrauth issue. > > So in that case we would report stopped due to a breakpoint, that's a > > special pac breakpoint but no pointer authentication issue? Isn't that > > confusing for the user? > > > > Maybe not because it's hinting at accidental corruption vs. deliberate > > misdirection, you probably have the experiences to inform that. > > > > This is an improvement as is so no need to change it I'm just curious. > > > > Can you add a test for this situation? Assuming you can find an address you > > know would never be valid. > The image containing the fixed address from x16 is usually loaded. If it's > not, that's indeed a very confusing situation (& would more likely than not > implicate an AppleClang bug). I don't believe the situation is made *more* > confusing because lldb declines to print a ptrauth hint. I've added a test > for this (it just sets x16 = 0xbad). Thanks, reading the test I see what you mean. You convert to `EXC_BAD_ACCESS` even if the x16 address isn't loaded, so I'm not seeing `EXC_BREAKPOINT` and wondering why I hit this breakpoint that I didn't add. (didn't add manually at least) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102428/new/ https://reviews.llvm.org/D102428 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d017d12 - [lldb][NFC] Cleanup IRForTarget member initializers
Author: Raphael Isemann Date: 2021-05-18T10:49:11+02:00 New Revision: d017d12f126ee9045f58f9300078d805e3bcc763 URL: https://github.com/llvm/llvm-project/commit/d017d12f126ee9045f58f9300078d805e3bcc763 DIFF: https://github.com/llvm/llvm-project/commit/d017d12f126ee9045f58f9300078d805e3bcc763.diff LOG: [lldb][NFC] Cleanup IRForTarget member initializers Note that the FunctionCallee members aren't pointer, so the nullptr was just an alternative way to call the default constructor. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index b35bf07034bdc..0173c8f263a5b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -73,12 +73,8 @@ IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, lldb_private::Stream &error_stream, const char *func_name) : ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name), - m_module(nullptr), m_decl_map(decl_map), - m_CFStringCreateWithBytes(nullptr), m_sel_registerName(nullptr), - m_objc_getClass(nullptr), m_intptr_ty(nullptr), - m_error_stream(error_stream), m_execution_unit(execution_unit), - m_result_store(nullptr), m_result_is_pointer(false), - m_reloc_placeholder(nullptr), + m_decl_map(decl_map), m_error_stream(error_stream), + m_execution_unit(execution_unit), m_entry_instruction_finder(FindEntryInstruction) {} /* Handy utility functions used at several places in the code */ diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h index ebfc0cae626cb..6ff50ec5f645c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h @@ -419,51 +419,46 @@ class IRForTarget : public llvm::ModulePass { /// True on success; false otherwise bool ReplaceVariables(llvm::Function &llvm_function); - /// Flags - bool m_resolve_vars; ///< True if external variable references and persistent - ///variable references should be resolved - lldb_private::ConstString - m_func_name; ///< The name of the function to translate - lldb_private::ConstString - m_result_name; ///< The name of the result variable ($0, $1, ...) - lldb_private::TypeFromParser - m_result_type; ///< The type of the result variable. - llvm::Module *m_module; ///< The module being processed, or NULL if that has - ///not been determined yet. - std::unique_ptr m_target_data; ///< The target data for the - ///module being processed, or - ///NULL if there is no - ///module. - lldb_private::ClangExpressionDeclMap - *m_decl_map; ///< The DeclMap containing the Decls - llvm::FunctionCallee - m_CFStringCreateWithBytes; ///< The address of the function - /// CFStringCreateWithBytes, cast to the - /// appropriate function pointer type - llvm::FunctionCallee m_sel_registerName; ///< The address of the function - /// sel_registerName, cast to the - /// appropriate function pointer type - llvm::FunctionCallee m_objc_getClass; ///< The address of the function -/// objc_getClass, cast to the -/// appropriate function pointer type - llvm::IntegerType - *m_intptr_ty; ///< The type of an integer large enough to hold a pointer. - lldb_private::Stream - &m_error_stream; ///< The stream on which errors should be printed - lldb_private::IRExecutionUnit & - m_execution_unit; ///< The execution unit containing the IR being created. - - llvm::StoreInst *m_result_store; ///< If non-NULL, the store instruction that - ///writes to the result variable. If - /// m_has_side_effects is true, this is - /// NULL. - bool m_result_is_pointer; ///< True if the function's result in the AST is a -///pointer (see comments in -/// ASTResultSynthesizer::SynthesizeBodyResult) - + /// True if external variable references and persistent variable references + /// should be resolved + bool m_resolve_vars; + /// The name of th
[Lldb-commits] [lldb] a1e6565 - [lit] Stop using PATH to lookup clang/lld/lldb unless requested
Author: James Henderson Date: 2021-05-18T10:43:33+01:00 New Revision: a1e6565855784988aa6302d6672705baf2a84ff2 URL: https://github.com/llvm/llvm-project/commit/a1e6565855784988aa6302d6672705baf2a84ff2 DIFF: https://github.com/llvm/llvm-project/commit/a1e6565855784988aa6302d6672705baf2a84ff2.diff LOG: [lit] Stop using PATH to lookup clang/lld/lldb unless requested This patch stops lit from looking on the PATH for clang, lld and other users of use_llvm_tool (currently only the debuginfo-tests) unless the call explicitly requests to opt into using the PATH. When not opting in, tests will only look in the build directory. See the mailing list thread starting from https://lists.llvm.org/pipermail/llvm-dev/2021-May/150421.html. See the review for details of why decisions were made about when still to use the PATH. Reviewed by: thopre Differential Revision: https://reviews.llvm.org/D102630 Added: Modified: lldb/test/Shell/helper/toolchain.py llvm/utils/lit/lit/llvm/config.py Removed: diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py index 6e564f31dbd37..6ccb529e89852 100644 --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -147,14 +147,14 @@ def use_support_substitutions(config): llvm_config.use_clang(additional_flags=['--target=specify-a-target-or-use-a-_host-substitution'], additional_tool_dirs=additional_tool_dirs, - required=True) + required=True, use_installed=True) if sys.platform == 'win32': _use_msvc_substitutions(config) have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs, - required=False) + required=False, use_installed=True) if have_lld: config.available_features.add('lld') diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py index 6ff3cba00f3e0..94824cd34773a 100644 --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -401,10 +401,11 @@ def use_default_substitutions(self): self.add_err_msg_substitutions() -def use_llvm_tool(self, name, search_env=None, required=False, quiet=False): +def use_llvm_tool(self, name, search_env=None, required=False, quiet=False, + use_installed=False): """Find the executable program 'name', optionally using the specified -environment variable as an override before searching the -configuration's PATH.""" +environment variable as an override before searching the build directory +and then optionally the configuration's PATH.""" # If the override is specified in the environment, use it without # validation. tool = None @@ -412,7 +413,11 @@ def use_llvm_tool(self, name, search_env=None, required=False, quiet=False): tool = self.config.environment.get(search_env) if not tool: -# Otherwise look in the path. +# Use the build directory version. +tool = lit.util.which(name, self.config.llvm_tools_dir) + +if not tool and use_installed: +# Otherwise look in the path, if enabled. tool = lit.util.which(name, self.config.environment['PATH']) if required and not tool: @@ -429,11 +434,11 @@ def use_llvm_tool(self, name, search_env=None, required=False, quiet=False): return tool def use_clang(self, additional_tool_dirs=[], additional_flags=[], - required=True): + required=True, use_installed=False): """Configure the test suite to be able to invoke clang. Sets up some environment variables important to clang, locates a -just-built or installed clang, and add a set of standard +just-built or optionally an installed clang, and add a set of standard substitutions useful to any test suite that makes use of clang. """ @@ -497,7 +502,8 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], # Discover the 'clang' and 'clangcc' to use. self.config.clang = self.use_llvm_tool( -'clang', search_env='CLANG', required=required) +'clang', search_env='CLANG', required=required, +use_installed=use_installed) if self.config.clang: self.config.available_features.add('clang') builtin_include_dir = self.get_clang_builtin_include_dir( @@ -569,11 +575,12 @@ def prefer(this, to): (' %clang-cl ', '''\"*** invalid substitution, use '%clang_cl'. ***\"''')) -def use_lld(self, additional_tool_dirs=[], required=True): +def use_lld(self, additional_tool_dirs=[], required=True, +use_instal
[Lldb-commits] [PATCH] D102685: [lldb] Encode `bool` as unsigned int
werat created this revision. werat added a reviewer: teemperor. werat requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. `bool` is considered to be unsigned according to `std::is_unsigned::value` (and `Type::GetTypeInfo`). Encoding it as signed int works fine for normal variables and fields, but breaks when reading the values of boolean bitfields. If the field is declared as `bool b : 1` and has a value of `0b1`, the call to `SBValue::GetValueAsSigned()` will return `-1`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D102685 Files: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py lldb/test/API/lang/cpp/bitfields/main.cpp Index: lldb/test/API/lang/cpp/bitfields/main.cpp === --- lldb/test/API/lang/cpp/bitfields/main.cpp +++ lldb/test/API/lang/cpp/bitfields/main.cpp @@ -104,5 +104,17 @@ uwbf.x = 0x; uwubf.x = 0x; + struct BoolBits { +bool a : 1; +bool b : 1; +bool c : 2; +bool d : 2; + } bb; + + bb.a = 0b1; + bb.b = 0b0; + bb.c = 0b11; + bb.d = 0b01; + return 0; // Set break point at this line. } Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py === --- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py +++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py @@ -16,9 +16,6 @@ # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') -# BitFields exhibit crashes in record layout on Windows -# (http://llvm.org/pr21800) -@skipIfWindows def test_and_run_command(self): """Test 'frame variable ...' on a variable with bitfields.""" self.build() @@ -120,3 +117,30 @@ '(uint32_t) b_a = 2', '(uint32_t:1) d_a = 1', ]) + +self.expect( +"frame variable --show-types bb", +VARIABLES_DISPLAYED_CORRECTLY, +substrs=[ +'(bool:1) a = true', +'(bool:1) b = false', +'(bool:2) c = true', +'(bool:2) d = true', +]) + +bb = self.frame().FindVariable('bb') +bb_a = bb.GetChildAtIndex(0) +self.assertEqual(bb_a.GetValueAsUnsigned(), 1) +self.assertEqual(bb_a.GetValueAsSigned(), 1) + +bb_b = bb.GetChildAtIndex(1) +self.assertEqual(bb_b.GetValueAsUnsigned(), 0) +self.assertEqual(bb_b.GetValueAsSigned(), 0) + +bb_c = bb.GetChildAtIndex(2) +self.assertEqual(bb_c.GetValueAsUnsigned(), 1) +self.assertEqual(bb_c.GetValueAsSigned(), 1) + +bb_d = bb.GetChildAtIndex(3) +self.assertEqual(bb_d.GetValueAsUnsigned(), 1) +self.assertEqual(bb_d.GetValueAsSigned(), 1) Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp === --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -4698,7 +4698,6 @@ case clang::BuiltinType::Void: break; -case clang::BuiltinType::Bool: case clang::BuiltinType::Char_S: case clang::BuiltinType::SChar: case clang::BuiltinType::WChar_S: @@ -4709,6 +4708,7 @@ case clang::BuiltinType::Int128: return lldb::eEncodingSint; +case clang::BuiltinType::Bool: case clang::BuiltinType::Char_U: case clang::BuiltinType::UChar: case clang::BuiltinType::WChar_U: Index: lldb/test/API/lang/cpp/bitfields/main.cpp === --- lldb/test/API/lang/cpp/bitfields/main.cpp +++ lldb/test/API/lang/cpp/bitfields/main.cpp @@ -104,5 +104,17 @@ uwbf.x = 0x; uwubf.x = 0x; + struct BoolBits { +bool a : 1; +bool b : 1; +bool c : 2; +bool d : 2; + } bb; + + bb.a = 0b1; + bb.b = 0b0; + bb.c = 0b11; + bb.d = 0b01; + return 0; // Set break point at this line. } Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py === --- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py +++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py @@ -16,9 +16,6 @@ # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') -# BitFields exhibit crashes in record layout on Windows -# (http://llvm.org/pr21800) -@skipIfWindows def test_and_run_command(self): """Test 'frame variable ...' on a variable with bitfields.""" self.build() @@ -120,3 +117,30 @@ '(uint32_t) b_a = 2', '(uint32_t:1) d_a = 1', ]) + +self.exp
[Lldb-commits] [PATCH] D102685: [lldb] Encode `bool` as unsigned int
teemperor accepted this revision. teemperor added a comment. This revision is now accepted and ready to land. Herald added a subscriber: JDevlieghere. Nice, and it's not even my birthday. Just some nits that don't need another round of review. Comment at: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py:21 -# (http://llvm.org/pr21800) -@skipIfWindows def test_and_run_command(self): Please land that as it's own commit (from what I understand from the bug report this worked before and you just remove the skipIf here) Comment at: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py:131 + +bb = self.frame().FindVariable('bb') +bb_a = bb.GetChildAtIndex(0) You might want to assert that `bb.IsValid()` after this call (otherwise the `GetValueAs*` calls just return 0 and that's a confusing error). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102685/new/ https://reviews.llvm.org/D102685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D102685: [lldb] Encode `bool` as unsigned int
werat updated this revision to Diff 346161. werat added a comment. Keep @skipIfWindows for now Add mroe checks in tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102685/new/ https://reviews.llvm.org/D102685 Files: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py lldb/test/API/lang/cpp/bitfields/main.cpp Index: lldb/test/API/lang/cpp/bitfields/main.cpp === --- lldb/test/API/lang/cpp/bitfields/main.cpp +++ lldb/test/API/lang/cpp/bitfields/main.cpp @@ -104,5 +104,17 @@ uwbf.x = 0x; uwubf.x = 0x; + struct BoolBits { +bool a : 1; +bool b : 1; +bool c : 2; +bool d : 2; + } bb; + + bb.a = 0b1; + bb.b = 0b0; + bb.c = 0b11; + bb.d = 0b01; + return 0; // Set break point at this line. } Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py === --- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py +++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py @@ -120,3 +120,36 @@ '(uint32_t) b_a = 2', '(uint32_t:1) d_a = 1', ]) + +self.expect( +"frame variable --show-types bb", +VARIABLES_DISPLAYED_CORRECTLY, +substrs=[ +'(bool:1) a = true', +'(bool:1) b = false', +'(bool:2) c = true', +'(bool:2) d = true', +]) + +bb = self.frame().FindVariable('bb') +self.assertTrue(bb.IsValid()) + +bb_a = bb.GetChildAtIndex(0) +self.assertTrue(bb_a.IsValid()) +self.assertEqual(bb_a.GetValueAsUnsigned(), 1) +self.assertEqual(bb_a.GetValueAsSigned(), 1) + +bb_b = bb.GetChildAtIndex(1) +self.assertTrue(bb_b.IsValid()) +self.assertEqual(bb_b.GetValueAsUnsigned(), 0) +self.assertEqual(bb_b.GetValueAsSigned(), 0) + +bb_c = bb.GetChildAtIndex(2) +self.assertTrue(bb_c.IsValid()) +self.assertEqual(bb_c.GetValueAsUnsigned(), 1) +self.assertEqual(bb_c.GetValueAsSigned(), 1) + +bb_d = bb.GetChildAtIndex(3) +self.assertTrue(bb_d.IsValid()) +self.assertEqual(bb_d.GetValueAsUnsigned(), 1) +self.assertEqual(bb_d.GetValueAsSigned(), 1) Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp === --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -4698,7 +4698,6 @@ case clang::BuiltinType::Void: break; -case clang::BuiltinType::Bool: case clang::BuiltinType::Char_S: case clang::BuiltinType::SChar: case clang::BuiltinType::WChar_S: @@ -4709,6 +4708,7 @@ case clang::BuiltinType::Int128: return lldb::eEncodingSint; +case clang::BuiltinType::Bool: case clang::BuiltinType::Char_U: case clang::BuiltinType::UChar: case clang::BuiltinType::WChar_U: Index: lldb/test/API/lang/cpp/bitfields/main.cpp === --- lldb/test/API/lang/cpp/bitfields/main.cpp +++ lldb/test/API/lang/cpp/bitfields/main.cpp @@ -104,5 +104,17 @@ uwbf.x = 0x; uwubf.x = 0x; + struct BoolBits { +bool a : 1; +bool b : 1; +bool c : 2; +bool d : 2; + } bb; + + bb.a = 0b1; + bb.b = 0b0; + bb.c = 0b11; + bb.d = 0b01; + return 0; // Set break point at this line. } Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py === --- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py +++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py @@ -120,3 +120,36 @@ '(uint32_t) b_a = 2', '(uint32_t:1) d_a = 1', ]) + +self.expect( +"frame variable --show-types bb", +VARIABLES_DISPLAYED_CORRECTLY, +substrs=[ +'(bool:1) a = true', +'(bool:1) b = false', +'(bool:2) c = true', +'(bool:2) d = true', +]) + +bb = self.frame().FindVariable('bb') +self.assertTrue(bb.IsValid()) + +bb_a = bb.GetChildAtIndex(0) +self.assertTrue(bb_a.IsValid()) +self.assertEqual(bb_a.GetValueAsUnsigned(), 1) +self.assertEqual(bb_a.GetValueAsSigned(), 1) + +bb_b = bb.GetChildAtIndex(1) +self.assertTrue(bb_b.IsValid()) +self.assertEqual(bb_b.GetValueAsUnsigned(), 0) +self.assertEqual(bb_b.GetValueAsSigned(), 0) + +bb_c = bb.GetChildAtIndex(2) +self.assertTrue(bb_c.IsValid()) +self.assertEqual(bb_c.GetValueAsUnsigned(), 1) +self.assertEqual(bb_c.GetValueAsSigned()
[Lldb-commits] [PATCH] D102685: [lldb] Encode `bool` as unsigned int
werat marked 2 inline comments as done. werat added a comment. Thanks for a quick review! Comment at: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py:21 -# (http://llvm.org/pr21800) -@skipIfWindows def test_and_run_command(self): teemperor wrote: > Please land that as it's own commit (from what I understand from the bug > report this worked before and you just remove the skipIf here) Okay, will submit this in a follow up commit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D102685/new/ https://reviews.llvm.org/D102685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] d017d12 - [lldb][NFC] Cleanup IRForTarget member initializers
If you are doing further clean-up here, it almost looks like those two reference members could actually be owned by IRForTarget i.e. m_execution_unit m_error_stream Which would be cleaner. > On May 18, 2021, at 1:49 AM, Raphael Isemann via lldb-commits > wrote: > > > Author: Raphael Isemann > Date: 2021-05-18T10:49:11+02:00 > New Revision: d017d12f126ee9045f58f9300078d805e3bcc763 > > URL: > https://github.com/llvm/llvm-project/commit/d017d12f126ee9045f58f9300078d805e3bcc763 > DIFF: > https://github.com/llvm/llvm-project/commit/d017d12f126ee9045f58f9300078d805e3bcc763.diff > > LOG: [lldb][NFC] Cleanup IRForTarget member initializers > > Note that the FunctionCallee members aren't pointer, so the nullptr was just > an alternative way to call the default constructor. > > Added: > > > Modified: >lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp >lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h > > Removed: > > > > > diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp > b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp > index b35bf07034bdc..0173c8f263a5b 100644 > --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp > +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp > @@ -73,12 +73,8 @@ > IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, > lldb_private::Stream &error_stream, > const char *func_name) > : ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name), > - m_module(nullptr), m_decl_map(decl_map), > - m_CFStringCreateWithBytes(nullptr), m_sel_registerName(nullptr), > - m_objc_getClass(nullptr), m_intptr_ty(nullptr), > - m_error_stream(error_stream), m_execution_unit(execution_unit), > - m_result_store(nullptr), m_result_is_pointer(false), > - m_reloc_placeholder(nullptr), > + m_decl_map(decl_map), m_error_stream(error_stream), > + m_execution_unit(execution_unit), > m_entry_instruction_finder(FindEntryInstruction) {} > > /* Handy utility functions used at several places in the code */ > > diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h > b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h > index ebfc0cae626cb..6ff50ec5f645c 100644 > --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h > +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h > @@ -419,51 +419,46 @@ class IRForTarget : public llvm::ModulePass { > /// True on success; false otherwise > bool ReplaceVariables(llvm::Function &llvm_function); > > - /// Flags > - bool m_resolve_vars; ///< True if external variable references and > persistent > - ///variable references should be resolved > - lldb_private::ConstString > - m_func_name; ///< The name of the function to translate > - lldb_private::ConstString > - m_result_name; ///< The name of the result variable ($0, $1, ...) > - lldb_private::TypeFromParser > - m_result_type; ///< The type of the result variable. > - llvm::Module *m_module; ///< The module being processed, or NULL if that > has > - ///not been determined yet. > - std::unique_ptr m_target_data; ///< The target data for > the > - ///module being > processed, or > - ///NULL if there is no > - ///module. > - lldb_private::ClangExpressionDeclMap > - *m_decl_map; ///< The DeclMap containing the Decls > - llvm::FunctionCallee > - m_CFStringCreateWithBytes; ///< The address of the function > - /// CFStringCreateWithBytes, cast to the > - /// appropriate function pointer type > - llvm::FunctionCallee m_sel_registerName; ///< The address of the function > - /// sel_registerName, cast to the > - /// appropriate function pointer > type > - llvm::FunctionCallee m_objc_getClass; ///< The address of the function > -/// objc_getClass, cast to the > -/// appropriate function pointer type > - llvm::IntegerType > - *m_intptr_ty; ///< The type of an integer large enough to hold a > pointer. > - lldb_private::Stream > - &m_error_stream; ///< The stream on which errors should be printed > - lldb_private::IRExecutionUnit & > - m_execution_unit; ///< The execution unit containing the IR being > created. > - > - llvm::StoreInst *m_result_store; ///< If non-NULL, the store instruction > that > - ///writes to the result variable. If > -
[Lldb-commits] [PATCH] D101128: [lldb-vscode] only report long running progress events
wallace added inline comments. Comment at: lldb/tools/lldb-vscode/ProgressEvent.h:32 + ProgressEvent(uint64_t progress_id, llvm::StringRef message, +llvm::Optional percentage); clayborg wrote: > Why is there an optional percentage for a start event? if total is INT_MAX, there's nothing to report Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101128/new/ https://reviews.llvm.org/D101128 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D101128: [lldb-vscode] only report long running progress events
wallace updated this revision to Diff 346335. wallace added a comment. Simplified the constructors Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101128/new/ https://reviews.llvm.org/D101128 Files: lldb/tools/lldb-vscode/ProgressEvent.cpp lldb/tools/lldb-vscode/ProgressEvent.h lldb/tools/lldb-vscode/VSCode.cpp lldb/tools/lldb-vscode/VSCode.h lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -376,8 +376,7 @@ const char *message = lldb::SBDebugger::GetProgressFromEvent( event, progress_id, completed, total, is_debugger_specific); if (message) - g_vsc.SendProgressEvent( - ProgressEvent(progress_id, message, completed, total)); + g_vsc.SendProgressEvent(progress_id, message, completed, total); } } } Index: lldb/tools/lldb-vscode/VSCode.h === --- lldb/tools/lldb-vscode/VSCode.h +++ lldb/tools/lldb-vscode/VSCode.h @@ -114,7 +114,7 @@ uint32_t reverse_request_seq; std::map request_handlers; bool waiting_for_run_in_terminal; - ProgressEventFilterQueue progress_event_queue; + ProgressEventReporter progress_event_reporter; // Keep track of the last stop thread index IDs as threads won't go away // unless we send a "thread" event to indicate the thread exited. llvm::DenseSet thread_ids; @@ -125,10 +125,6 @@ int64_t GetLineForPC(int64_t sourceReference, lldb::addr_t pc) const; ExceptionBreakpoint *GetExceptionBreakpoint(const std::string &filter); ExceptionBreakpoint *GetExceptionBreakpoint(const lldb::break_id_t bp_id); - // Send the JSON in "json_str" to the "out" stream. Correctly send the - // "Content-Length:" field followed by the length, followed by the raw - // JSON bytes. - void SendJSON(const std::string &json_str); // Serialize the JSON value into a string and send the JSON packet to // the "out" stream. @@ -138,7 +134,8 @@ void SendOutput(OutputType o, const llvm::StringRef output); - void SendProgressEvent(const ProgressEvent &event); + void SendProgressEvent(uint64_t progress_id, const char *message, + uint64_t completed, uint64_t total); void __attribute__((format(printf, 3, 4))) SendFormattedOutput(OutputType o, const char *format, ...); @@ -208,6 +205,12 @@ /// The callback to execute when the given request is triggered by the /// IDE. void RegisterRequestCallback(std::string request, RequestCallback callback); + +private: + // Send the JSON in "json_str" to the "out" stream. Correctly send the + // "Content-Length:" field followed by the length, followed by the raw + // JSON bytes. + void SendJSON(const std::string &json_str); }; extern VSCode g_vsc; Index: lldb/tools/lldb-vscode/VSCode.cpp === --- lldb/tools/lldb-vscode/VSCode.cpp +++ lldb/tools/lldb-vscode/VSCode.cpp @@ -42,7 +42,7 @@ focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false), stop_at_entry(false), is_attach(false), reverse_request_seq(0), waiting_for_run_in_terminal(false), - progress_event_queue( + progress_event_reporter( [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }) { const char *log_file_path = getenv("LLDBVSCODE_LOG"); #if defined(_WIN32) @@ -322,8 +322,9 @@ // }; // } -void VSCode::SendProgressEvent(const ProgressEvent &event) { - progress_event_queue.Push(event); +void VSCode::SendProgressEvent(uint64_t progress_id, const char *message, + uint64_t completed, uint64_t total) { + progress_event_reporter.Push(progress_id, message, completed, total); } void __attribute__((format(printf, 3, 4))) Index: lldb/tools/lldb-vscode/ProgressEvent.h === --- lldb/tools/lldb-vscode/ProgressEvent.h +++ lldb/tools/lldb-vscode/ProgressEvent.h @@ -6,6 +6,10 @@ // //===--===// +#include +#include +#include + #include "VSCodeForward.h" #include "llvm/Support/JSON.h" @@ -13,50 +17,142 @@ namespace lldb_vscode { enum ProgressEventType { - progressInvalid, progressStart, progressUpdate, progressEnd }; +class ProgressEvent; +using ProgressEventReportCallback = std::function; + class ProgressEvent { public: - ProgressEvent() {} - - ProgressEvent(uint64_t progress_id, const char *message, uint64_t completed, -uint64_t total); + /// Actual constructor to use that returns an optional, as the event might be + /// not apt for the IDE, e.g. an unnamed start event, or a redundant one. + /// + /// \param[in] progre