[Lldb-commits] [PATCH] D116094: Add support for a version 2 of "main bin spec" Mach-O LC_NOTE in corefiles, handle specifications with a slide value
jasonmolenda created this revision. jasonmolenda added a project: LLDB. Herald added a subscriber: JDevlieghere. jasonmolenda requested review of this revision. The Mach-O corefiles have a "main bin spec" LC_NOTE which allows the corefile creator to specify a binary's UUID, load address, and type (userland, kernel, frimware). This patch extends that structure with two new fields - an optional slide, and an optional platform (currently unused). We have a corefile creator that will only know the offset that a binary was loaded at, as well as its UUID, so lldb will need to find the original binary and add the offset to its file address to get the correct load address. I changed the ObjectFile::GetCorefileMainBinaryInfo method from taking a load address, to taking a value and a bool of whether the value is an address or an offset. This is based on Module::SetLoadAddress, and it seemed good to stick with that argument style. The majority of the patch is changing TestFirmwareCorefiles.py. I changed create-empty-corefile.cpp to work on Intel or Apple Silicon macs, have it generate version 2 of the 'main bin spec' LC_NOTE, both with an address and with a slide. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D116094 Files: lldb/include/lldb/Symbol/ObjectFile.h lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp Index: lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp === --- lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp +++ lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp @@ -20,9 +20,10 @@ uint32_t version; uint32_t type; uint64_t address; + uint64_t slide; uuid_t uuid; uint32_t log2_pagesize; - uint32_t unused; + uint32_t platform; }; union uint32_buf { @@ -49,33 +50,36 @@ buf.push_back(conv.bytebuf[i]); } -std::vector x86_lc_thread_load_command() { +std::vector lc_thread_load_command(cpu_type_t cputype) { std::vector data; - add_uint32(data, LC_THREAD);// thread_command.cmd - add_uint32(data, 184); // thread_command.cmdsize - add_uint32(data, x86_THREAD_STATE64); // thread_command.flavor - add_uint32(data, x86_THREAD_STATE64_COUNT); // thread_command.count - add_uint64(data, 0x); // rax - add_uint64(data, 0x0400); // rbx - add_uint64(data, 0x); // rcx - add_uint64(data, 0x); // rdx - add_uint64(data, 0x); // rdi - add_uint64(data, 0x); // rsi - add_uint64(data, 0xff9246e2ba20); // rbp - add_uint64(data, 0xff9246e2ba10); // rsp - add_uint64(data, 0x); // r8 - add_uint64(data, 0x); // r9 - add_uint64(data, 0x); // r10 - add_uint64(data, 0x); // r11 - add_uint64(data, 0xff7f96ce5fe1); // r12 - add_uint64(data, 0x); // r13 - add_uint64(data, 0x); // r14 - add_uint64(data, 0xff9246e2bac0); // r15 - add_uint64(data, 0xff8015a8f6d0); // rip - add_uint64(data, 0x0001); // rflags - add_uint64(data, 0x0002); // cs - add_uint64(data, 0x0003); // fs - add_uint64(data, 0x0004); // gs + // Emit an LC_THREAD register context appropriate for the cputype + // of the binary we're embedded. The tests in this case do not + // use the register values, so 0's are fine, lldb needs to see at + // least one LC_THREAD in the corefile. +#if defined(__x86_64__) + if (cputype == CPU_TYPE_X86_64) { +add_uint32(data, LC_THREAD); // thread_command.cmd +add_uint32(data, + 16 + (x86_THREAD_STATE64_COUNT * 4)); // thread_command.cmdsize +add_uint32(data, x86_THREAD_STATE64);// thread_command.flavor +add_uint32(data, x86_THREAD_STATE64_COUNT); // thread_command.count +for (int i = 0; i < x86_THREAD_STATE64_COUNT; i++) { + add_uint32(data, 0); // whatever, just some empty register values +} + } +#endif +#if defined(__arm64__) || defined(__aarch64__) + if (cputype == CPU_TYPE_ARM64) { +add_uint32(data, LC_THREAD); // thread_command.cmd +add_uint32(data, + 16 + (ARM_THREAD_STATE64_COUNT * 4)); // thread_command.cmdsize +add_uint32(data, ARM_THREAD_STATE64);// thread_command.flavor +add_uint32(data, ARM_THREAD_STATE64_COUNT); // thread_command.count +for (int i = 0; i < ARM_THREAD_STATE64_COUNT; i++) { + add_ui
[Lldb-commits] [PATCH] D116094: Add support for a version 2 of "main bin spec" Mach-O LC_NOTE in corefiles, handle specifications with a slide value
JDevlieghere accepted this revision. JDevlieghere added a comment. This revision is now accepted and ready to land. A few small nits but the change itself looks sound to me. LGTM. Comment at: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:7052 + if (image.load_address != LLDB_INVALID_ADDRESS) +sprintf(namebuf, "mem-image-0x%" PRIx64, image.load_address); + else No need to change this, but if you ever have situation where the buffer is variable length, LLVM's `formatv` makes this very easy: ``` std::string s = llvm::formatv("mem-image+{0:x}", image.load_address) ``` Comment at: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp:224 +if (value != LLDB_INVALID_ADDRESS) { + bool changed = false; + module_sp->SetLoadAddress(target, value, value_is_offset, changed); You can hoist this out of the if-check and reuse it in all the blocks instead of having to duplicate the variable each time. Comment at: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp:230 + bool changed = false; + module_sp->SetLoadAddress(target, 0, value_is_slide, changed); +} When I was reading this code, I found this a little confusing, given that `value_is_offset` is an input parameter and this is meant as a constant. Not sure how to make this better other than possibly using `/*value_is_offset=*/ true`. Anyway small nit, don't feel like you need to change anything here. Comment at: lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py:41 @skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking explicitly for a dSYM") -@skipIf(archs=no_match(['x86_64'])) +@skipIf(archs=no_match(['x86_64', 'arm64', 'arm64e', 'aarch64'])) +@skipIfRemote Nice Comment at: lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py:72-88 +target = self.dbg.CreateTarget('') err = lldb.SBError() if self.TraceOn(): self.runCmd("script print('loading corefile %s')" % self.verstr_corefile_addr) -self.process = self.target.LoadCore(self.verstr_corefile_addr) +self.process = target.LoadCore(self.verstr_corefile_addr) self.assertEqual(self.process.IsValid(), True) if self.TraceOn(): Given that you already build the corefiles only once, would it make sense to make these separate tests so that *if* they fail, you can immediately tell from the logs? Or maybe these tests are sharing something that I missed? Comment at: lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py:177 +dsym_python_dir = '%s.dSYM/Contents/Resources/Python' % (aout_exe) +os.makedirs(dsym_python_dir) +python_os_plugin_path = os.path.join(self.getSourceDir(), I believe you need to pass `exist_ok` to avoid this failing when the dir already exists. Comment at: lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py:184 +] +with open(dsym_python_dir + "/a_out.py", "w") as writer: +for l in python_init: `os.path.join` Comment at: lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py:191 +dwarfdump_cmd_output = subprocess.check_output( +('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True).decode("utf-8") +aout_uuid = None We shouldn't be hardcoding this, we already have `llvm-dwarfdump` as a test dependency. That said, unlike `dsymutil` there's no good way to get the `dwarfdump` binary. There's other tests doing the same, so we (I?) should address this in another patch. Comment at: lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py:200-227 +shell_cmds = [ +'#! /bin/sh', +'# the last argument is the uuid', +'while [ $# -gt 1 ]', +'do', +' shift', +'done', I feel like we have a handful of tests creating this dsymforuuid wrapper. At some point we should consider moving this in the `lldbutil` so we don't have to copy-paste this everywhere. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116094/new/ https://reviews.llvm.org/D116094 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D115951: Cache the manual DWARF index out to the LLDB cache directory when the LLDB index cache is enabled.
wallace accepted this revision. wallace added a comment. This revision is now accepted and ready to land. lgtm Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115951/new/ https://reviews.llvm.org/D115951 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9531146 - [lldb] Use `GNUInstallDirs` to support custom installation dirs.
Author: John Ericson Date: 2021-12-22T00:28:53Z New Revision: 95311468997160401c027e3bad3b14a391c1ead6 URL: https://github.com/llvm/llvm-project/commit/95311468997160401c027e3bad3b14a391c1ead6 DIFF: https://github.com/llvm/llvm-project/commit/95311468997160401c027e3bad3b14a391c1ead6.diff LOG: [lldb] Use `GNUInstallDirs` to support custom installation dirs. Extracted from D99484. My new plan is to start from the outside and work inward. Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D115570 Added: Modified: lldb/CMakeLists.txt lldb/cmake/modules/AddLLDB.cmake lldb/cmake/modules/LLDBConfig.cmake Removed: diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 5c2dac3f51f6d..79d451965ed43 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.13.4) +include(GNUInstallDirs) + # Add path for custom modules. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 8be214a8509a5..3291a7c808e16 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -1,3 +1,5 @@ +include(GNUInstallDirs) + function(lldb_tablegen) # Syntax: # lldb_tablegen output-file [tablegen-arg ...] SOURCE source-file @@ -113,7 +115,7 @@ function(add_lldb_library name) endif() # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS install(TARGETS ${name} COMPONENT ${name} - RUNTIME DESTINATION bin + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION ${install_dest} ARCHIVE DESTINATION ${install_dest} FRAMEWORK DESTINATION ${install_dest}) diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 01c501a7f717b..e12e548ad0c41 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -231,7 +231,7 @@ include_directories(BEFORE if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/ COMPONENT lldb-headers -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN ".cmake" EXCLUDE @@ -239,7 +239,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ COMPONENT lldb-headers -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN ".cmake" EXCLUDE ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D115570: [lldb] Use `GNUInstallDirs` to support custom installation dirs.
This revision was automatically updated to reflect the committed changes. Closed by commit rG953114689971: [lldb] Use `GNUInstallDirs` to support custom installation dirs. (authored by Ericson2314). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115570/new/ https://reviews.llvm.org/D115570 Files: lldb/CMakeLists.txt lldb/cmake/modules/AddLLDB.cmake lldb/cmake/modules/LLDBConfig.cmake Index: lldb/cmake/modules/LLDBConfig.cmake === --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -231,7 +231,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/ COMPONENT lldb-headers -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN ".cmake" EXCLUDE @@ -239,7 +239,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ COMPONENT lldb-headers -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN ".cmake" EXCLUDE Index: lldb/cmake/modules/AddLLDB.cmake === --- lldb/cmake/modules/AddLLDB.cmake +++ lldb/cmake/modules/AddLLDB.cmake @@ -1,3 +1,5 @@ +include(GNUInstallDirs) + function(lldb_tablegen) # Syntax: # lldb_tablegen output-file [tablegen-arg ...] SOURCE source-file @@ -113,7 +115,7 @@ endif() # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS install(TARGETS ${name} COMPONENT ${name} - RUNTIME DESTINATION bin + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION ${install_dest} ARCHIVE DESTINATION ${install_dest} FRAMEWORK DESTINATION ${install_dest}) Index: lldb/CMakeLists.txt === --- lldb/CMakeLists.txt +++ lldb/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.13.4) +include(GNUInstallDirs) + # Add path for custom modules. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} Index: lldb/cmake/modules/LLDBConfig.cmake === --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -231,7 +231,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/ COMPONENT lldb-headers -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN ".cmake" EXCLUDE @@ -239,7 +239,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ COMPONENT lldb-headers -DESTINATION include +DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h" PATTERN ".cmake" EXCLUDE Index: lldb/cmake/modules/AddLLDB.cmake === --- lldb/cmake/modules/AddLLDB.cmake +++ lldb/cmake/modules/AddLLDB.cmake @@ -1,3 +1,5 @@ +include(GNUInstallDirs) + function(lldb_tablegen) # Syntax: # lldb_tablegen output-file [tablegen-arg ...] SOURCE source-file @@ -113,7 +115,7 @@ endif() # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS install(TARGETS ${name} COMPONENT ${name} - RUNTIME DESTINATION bin + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION ${install_dest} ARCHIVE DESTINATION ${install_dest} FRAMEWORK DESTINATION ${install_dest}) Index: lldb/CMakeLists.txt === --- lldb/CMakeLists.txt +++ lldb/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.13.4) +include(GNUInstallDirs) + # Add path for custom modules. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D115570: [lldb] Use `GNUInstallDirs` to support custom installation dirs.
Ericson2314 added a comment. Thanks, @compnerd! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115570/new/ https://reviews.llvm.org/D115570 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D112564: [lldb] Add support for UTF-8 unicode formatting
ljmf00 updated this revision to Diff 395777. ljmf00 retitled this revision from "[lldb] Add support for custom char8_t types with different name" to "[lldb] Add support for UTF-8 unicode formatting". ljmf00 edited the summary of this revision. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112564/new/ https://reviews.llvm.org/D112564 Files: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py Index: lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py === --- lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py +++ lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py @@ -115,8 +115,7 @@ self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character array", string_expr)) self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character", string_expr)) self.assertIn('= ..90zaZA... \n', self.getFormatted("printable character", string_expr)) -# FIXME: This should probably print the characters in the uint128_t. -self.assertIn('= 0x2007080c0a0d090b415a617a30391b00\n', self.getFormatted("unicode8", string_expr)) +self.assertIn('= 0x00 0x1b 0x39 0x30 0x7a 0x61 0x5a 0x41 0x0b 0x09 0x0d 0x0a 0x0c 0x08 0x07 0x20\n', self.getFormatted("unicode8", string_expr)) # OSType ostype_expr = "(__UINT64_TYPE__)0x" @@ -137,6 +136,9 @@ # bytes with ASCII self.assertIn(r'= " \U001b\a\b\f\n\r\t\vaA09\0"', self.getFormatted("bytes with ASCII", "cstring")) +# unicode8 +self.assertIn('= 0x78 0x56 0x34 0x12\n', self.getFormatted("unicode8", "0x12345678")) + # unicode16 self.assertIn('= U+5678 U+1234\n', self.getFormatted("unicode16", "0x12345678")) Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp === --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -5149,6 +5149,8 @@ case clang::BuiltinType::UChar: case clang::BuiltinType::WChar_U: return lldb::eFormatChar; +case clang::BuiltinType::Char8: + return lldb::eFormatUnicode8; case clang::BuiltinType::Char16: return lldb::eFormatUnicode16; case clang::BuiltinType::Char32: @@ -8957,6 +8959,7 @@ case eFormatCharPrintable: case eFormatCharArray: case eFormatBytes: +case eFormatUnicode8: case eFormatBytesWithASCII: item_count = byte_size; byte_size = 1; Index: lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py === --- lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py +++ lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py @@ -115,8 +115,7 @@ self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character array", string_expr)) self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character", string_expr)) self.assertIn('= ..90zaZA... \n', self.getFormatted("printable character", string_expr)) -# FIXME: This should probably print the characters in the uint128_t. -self.assertIn('= 0x2007080c0a0d090b415a617a30391b00\n', self.getFormatted("unicode8", string_expr)) +self.assertIn('= 0x00 0x1b 0x39 0x30 0x7a 0x61 0x5a 0x41 0x0b 0x09 0x0d 0x0a 0x0c 0x08 0x07 0x20\n', self.getFormatted("unicode8", string_expr)) # OSType ostype_expr = "(__UINT64_TYPE__)0x" @@ -137,6 +136,9 @@ # bytes with ASCII self.assertIn(r'= " \U001b\a\b\f\n\r\t\vaA09\0"', self.getFormatted("bytes with ASCII", "cstring")) +# unicode8 +self.assertIn('= 0x78 0x56 0x34 0x12\n', self.getFormatted("unicode8", "0x12345678")) + # unicode16 self.assertIn('= U+5678 U+1234\n', self.getFormatted("unicode16", "0x12345678")) Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp === --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -5149,6 +5149,8 @@ case clang::BuiltinType::UChar: case clang::BuiltinType::WChar_U: return lldb::eFormatChar; +case clang::BuiltinType::Char8: + return lldb::eFormatUnicode8; case clang::BuiltinType::Char16: return lldb::eFormatUnicode16; case clang::BuiltinType::Char32: @@ -8957,6 +8959,7 @@ case eFormatCharPrintable: case eFormatCharArray: case eFormatBytes: +case eF
[Lldb-commits] [PATCH] D112564: [lldb] Add support for UTF-8 unicode formatting
ljmf00 added a comment. @labath I found the missing part, DumpTypeValue depends on lldb::Format and eFormatUnicode8 case should be added there too. I added tests and also changed the patch message. Can you re-review? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112564/new/ https://reviews.llvm.org/D112564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D116136: [lldb] Add UTF-8 char basic type
ljmf00 created this revision. ljmf00 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. A UTF-8 Basic type should be exposed the same way we have UTF-16 and UTF-32 basic types Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D116136 Files: lldb/bindings/python/python-extensions.swig lldb/docs/python_api_enums.rst lldb/include/lldb/lldb-enumerations.h Index: lldb/include/lldb/lldb-enumerations.h === --- lldb/include/lldb/lldb-enumerations.h +++ lldb/include/lldb/lldb-enumerations.h @@ -747,6 +747,7 @@ eBasicTypeWChar, eBasicTypeSignedWChar, eBasicTypeUnsignedWChar, + eBasicTypeChar8, eBasicTypeChar16, eBasicTypeChar32, eBasicTypeShort, Index: lldb/docs/python_api_enums.rst === --- lldb/docs/python_api_enums.rst +++ lldb/docs/python_api_enums.rst @@ -1017,6 +1017,7 @@ .. py:data:: eBasicTypeWChar .. py:data:: eBasicTypeSignedWChar .. py:data:: eBasicTypeUnsignedWChar +.. py:data:: eBasicTypeChar8 .. py:data:: eBasicTypeChar16 .. py:data:: eBasicTypeChar32 .. py:data:: eBasicTypeShort Index: lldb/bindings/python/python-extensions.swig === --- lldb/bindings/python/python-extensions.swig +++ lldb/bindings/python/python-extensions.swig @@ -563,6 +563,7 @@ if basic_type == eBasicTypeWChar: return (True,False) if basic_type == eBasicTypeSignedWChar: return (True,True) if basic_type == eBasicTypeUnsignedWChar: return (True,False) +if basic_type == eBasicTypeChar8: return (True,False) if basic_type == eBasicTypeChar16: return (True,False) if basic_type == eBasicTypeChar32: return (True,False) if basic_type == eBasicTypeShort: return (True,True) Index: lldb/include/lldb/lldb-enumerations.h === --- lldb/include/lldb/lldb-enumerations.h +++ lldb/include/lldb/lldb-enumerations.h @@ -747,6 +747,7 @@ eBasicTypeWChar, eBasicTypeSignedWChar, eBasicTypeUnsignedWChar, + eBasicTypeChar8, eBasicTypeChar16, eBasicTypeChar32, eBasicTypeShort, Index: lldb/docs/python_api_enums.rst === --- lldb/docs/python_api_enums.rst +++ lldb/docs/python_api_enums.rst @@ -1017,6 +1017,7 @@ .. py:data:: eBasicTypeWChar .. py:data:: eBasicTypeSignedWChar .. py:data:: eBasicTypeUnsignedWChar +.. py:data:: eBasicTypeChar8 .. py:data:: eBasicTypeChar16 .. py:data:: eBasicTypeChar32 .. py:data:: eBasicTypeShort Index: lldb/bindings/python/python-extensions.swig === --- lldb/bindings/python/python-extensions.swig +++ lldb/bindings/python/python-extensions.swig @@ -563,6 +563,7 @@ if basic_type == eBasicTypeWChar: return (True,False) if basic_type == eBasicTypeSignedWChar: return (True,True) if basic_type == eBasicTypeUnsignedWChar: return (True,False) +if basic_type == eBasicTypeChar8: return (True,False) if basic_type == eBasicTypeChar16: return (True,False) if basic_type == eBasicTypeChar32: return (True,False) if basic_type == eBasicTypeShort: return (True,True) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D116136: [lldb] Add UTF-8 char basic type
ljmf00 added inline comments. Comment at: lldb/include/lldb/lldb-enumerations.h:750 eBasicTypeUnsignedWChar, + eBasicTypeChar8, eBasicTypeChar16, Does the order of the enum matter here? Since this is part of the public API it might break something externally. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116136/new/ https://reviews.llvm.org/D116136 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D116094: Add support for a version 2 of "main bin spec" Mach-O LC_NOTE in corefiles, handle specifications with a slide value
jasonmolenda updated this revision to Diff 395800. jasonmolenda added a comment. Update patch to address Jonas' feedback. Most of the changes in this update are to TestFirmwareCorefiles.py, cleaning its structure up given how the test has grown over time. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116094/new/ https://reviews.llvm.org/D116094 Files: lldb/include/lldb/Symbol/ObjectFile.h lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp Index: lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp === --- lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp +++ lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp @@ -20,9 +20,10 @@ uint32_t version; uint32_t type; uint64_t address; + uint64_t slide; uuid_t uuid; uint32_t log2_pagesize; - uint32_t unused; + uint32_t platform; }; union uint32_buf { @@ -49,33 +50,36 @@ buf.push_back(conv.bytebuf[i]); } -std::vector x86_lc_thread_load_command() { +std::vector lc_thread_load_command(cpu_type_t cputype) { std::vector data; - add_uint32(data, LC_THREAD);// thread_command.cmd - add_uint32(data, 184); // thread_command.cmdsize - add_uint32(data, x86_THREAD_STATE64); // thread_command.flavor - add_uint32(data, x86_THREAD_STATE64_COUNT); // thread_command.count - add_uint64(data, 0x); // rax - add_uint64(data, 0x0400); // rbx - add_uint64(data, 0x); // rcx - add_uint64(data, 0x); // rdx - add_uint64(data, 0x); // rdi - add_uint64(data, 0x); // rsi - add_uint64(data, 0xff9246e2ba20); // rbp - add_uint64(data, 0xff9246e2ba10); // rsp - add_uint64(data, 0x); // r8 - add_uint64(data, 0x); // r9 - add_uint64(data, 0x); // r10 - add_uint64(data, 0x); // r11 - add_uint64(data, 0xff7f96ce5fe1); // r12 - add_uint64(data, 0x); // r13 - add_uint64(data, 0x); // r14 - add_uint64(data, 0xff9246e2bac0); // r15 - add_uint64(data, 0xff8015a8f6d0); // rip - add_uint64(data, 0x0001); // rflags - add_uint64(data, 0x0002); // cs - add_uint64(data, 0x0003); // fs - add_uint64(data, 0x0004); // gs + // Emit an LC_THREAD register context appropriate for the cputype + // of the binary we're embedded. The tests in this case do not + // use the register values, so 0's are fine, lldb needs to see at + // least one LC_THREAD in the corefile. +#if defined(__x86_64__) + if (cputype == CPU_TYPE_X86_64) { +add_uint32(data, LC_THREAD); // thread_command.cmd +add_uint32(data, + 16 + (x86_THREAD_STATE64_COUNT * 4)); // thread_command.cmdsize +add_uint32(data, x86_THREAD_STATE64);// thread_command.flavor +add_uint32(data, x86_THREAD_STATE64_COUNT); // thread_command.count +for (int i = 0; i < x86_THREAD_STATE64_COUNT; i++) { + add_uint32(data, 0); // whatever, just some empty register values +} + } +#endif +#if defined(__arm64__) || defined(__aarch64__) + if (cputype == CPU_TYPE_ARM64) { +add_uint32(data, LC_THREAD); // thread_command.cmd +add_uint32(data, + 16 + (ARM_THREAD_STATE64_COUNT * 4)); // thread_command.cmdsize +add_uint32(data, ARM_THREAD_STATE64);// thread_command.flavor +add_uint32(data, ARM_THREAD_STATE64_COUNT); // thread_command.count +for (int i = 0; i < ARM_THREAD_STATE64_COUNT; i++) { + add_uint32(data, 0); // whatever, just some empty register values +} + } +#endif return data; } @@ -121,7 +125,8 @@ void add_lc_note_main_bin_spec_load_command( std::vector> &loadcmds, std::vector &payload, -int payload_file_offset, std::string uuidstr, uint64_t address) { +int payload_file_offset, std::string uuidstr, uint64_t address, +uint64_t slide) { std::vector loadcmd_data; add_uint32(loadcmd_data, LC_NOTE); // note_command.cmd @@ -145,15 +150,16 @@ loadcmds.push_back(loadcmd_data); // Now write the "main bin spec" payload. - add_uint32(payload, 1); // version + add_uint32(payload, 2); // version add_uint32(payload, 3); // type == 3 [ firmware, standalone, etc ] add_uint64(payload, address);// load address + add_uint64(payload, slide); // slide uuid_t uuid;