Re: [Lldb-commits] [PATCH] D22628: Fixing layout of elf-core file related structures
labath added a comment. Looks good, just please fix the small stylistic issue. Comment at: source/Plugins/Process/elf-core/ThreadElfCore.h:24 @@ -23,3 +23,3 @@ { -int64_t tv_sec; -int32_t tv_usec; +alignas(8) uint64_t tv_sec; +alignas(8) uint64_t tv_usec; Please define a separate type for a "64-bit integer aligned to 8 bytes", so we can avoid littering the code with the alignas directives. https://reviews.llvm.org/D22628 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r276403 - Fix a crash when an ELF section symbol have no name
Author: tberghammer Date: Fri Jul 22 05:43:03 2016 New Revision: 276403 URL: http://llvm.org/viewvc/llvm-project?rev=276403&view=rev Log: Fix a crash when an ELF section symbol have no name Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=276403&r1=276402&r2=276403&view=diff == --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jul 22 05:43:03 2016 @@ -2211,10 +2211,12 @@ ObjectFileELF::ParseSymbols (Symtab *sym break; const char *symbol_name = strtab_data.PeekCStr(symbol.st_name); +if (!symbol_name) +symbol_name = ""; // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && -(symbol_name == NULL || symbol_name[0] == '\0')) +(symbol_name == nullptr || symbol_name[0] == '\0')) continue; // Skipping oatdata and oatexec sections if it is requested. See details above the @@ -2461,7 +2463,7 @@ ObjectFileELF::ParseSymbols (Symtab *sym bool is_global = symbol.getBinding() == STB_GLOBAL; uint32_t flags = symbol.st_other << 8 | symbol.st_info | additional_flags; -bool is_mangled = symbol_name ? (symbol_name[0] == '_' && symbol_name[1] == 'Z') : false; +bool is_mangled = (symbol_name[0] == '_' && symbol_name[1] == 'Z'); llvm::StringRef symbol_ref(symbol_name); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D22628: Fixing layout of elf-core file related structures
dvlahovski added a comment. So, alignas doesn't work with typedef We can use a #define but that's kind of ugly https://reviews.llvm.org/D22628 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r276406 - Fixing layout of elf-core file related structures
Author: labath Date: Fri Jul 22 07:18:45 2016 New Revision: 276406 URL: http://llvm.org/viewvc/llvm-project?rev=276406&view=rev Log: Fixing layout of elf-core file related structures Summary: The binary layout of prstatus and prpsinfo was wrong. Some of the member variables where not aligned properly and others where with a wrong type (e.g. the time related stuff in prstatus). I used the structs defined in bfd in binutils to see what the layout of the elf-core format in these section is. (https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/hosts/x86-64linux.h;h=4e420a1f2081dd3b51f5d6b7a8e4093580f5cdb5;hb=master) Note: those structures are only for x86 64 bit elf-core files This shouldn't have any impact on the functionality, because lldb actually uses only a few of the member variables of those structs and they are with a correct type and alignment. I found this while trying to add/fix the support for i386 core files (https://llvm.org/bugs/show_bug.cgi?id=26947) Reviewers: labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D22628 Author: Dimitar Vlahovski Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp?rev=276406&r1=276405&r2=276406&view=diff == --- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Fri Jul 22 07:18:45 2016 @@ -228,8 +228,8 @@ ELFLinuxPrStatus::Parse(DataExtractor &d { case ArchSpec::eCore_s390x_generic: case ArchSpec::eCore_x86_64_x86_64: -len = data.ExtractBytes(0, ELFLINUXPRSTATUS64_SIZE, byteorder, this); -return len == ELFLINUXPRSTATUS64_SIZE; +len = data.ExtractBytes(0, sizeof(ELFLinuxPrStatus), byteorder, this); +return len == sizeof(ELFLinuxPrStatus); default: return false; } @@ -252,8 +252,8 @@ ELFLinuxPrPsInfo::Parse(DataExtractor &d { case ArchSpec::eCore_s390x_generic: case ArchSpec::eCore_x86_64_x86_64: -len = data.ExtractBytes(0, ELFLINUXPRPSINFO64_SIZE, byteorder, this); -return len == ELFLINUXPRPSINFO64_SIZE; +len = data.ExtractBytes(0, sizeof(ELFLinuxPrPsInfo), byteorder, this); +return len == sizeof(ELFLinuxPrPsInfo); default: return false; } Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h?rev=276406&r1=276405&r2=276406&view=diff == --- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h (original) +++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h Fri Jul 22 07:18:45 2016 @@ -21,17 +21,13 @@ struct compat_timeval { -int64_t tv_sec; -int32_t tv_usec; +alignas(8) uint64_t tv_sec; +alignas(8) uint64_t tv_usec; }; // PRSTATUS structure's size differs based on architecture. // Currently parsing done only for x86-64 architecture by // simply reading data from the buffer. -// The following macros are used to specify the size. -// Calculating size using sizeof() wont work because of padding. -#define ELFLINUXPRSTATUS64_SIZE (112) -#define ELFLINUXPRPSINFO64_SIZE (132) #undef si_signo #undef si_code @@ -39,24 +35,24 @@ struct compat_timeval struct ELFLinuxPrStatus { -int32_t si_signo; -int32_t si_code; -int32_t si_errno; - -int16_t pr_cursig; - -uint64_tpr_sigpend; -uint64_tpr_sighold; - -uint32_tpr_pid; -uint32_tpr_ppid; -uint32_tpr_pgrp; -uint32_tpr_sid; - -compat_timeval pr_utime; -compat_timeval pr_stime; -compat_timeval pr_cutime; -compat_timeval pr_cstime; +int32_t si_signo; +int32_t si_code; +int32_t si_errno; + +int16_t pr_cursig; + +alignas(8) uint64_t pr_sigpend; +alignas(8) uint64_t pr_sighold; + +uint32_t pr_pid; +uint32_t pr_ppid; +uint32_t pr_pgrp; +uint32_t pr_sid; + +compat_timeval pr_utime; +compat_timeval pr_stime; +compat_timeval pr_cutime; +compat_timeval pr_cstime; ELFLinuxPrStatus(); @@ -70,28 +66,30 @@ struct ELFLinuxPrStatus { case lldb_private::ArchSpec::eCore_s390x_generic: case lldb_private::ArchSpec::eCore_x86_64_x86_64: -return ELFLINUXPRSTATUS64_SIZE; +return sizeof(ELFLinuxPrStatus); default: return 0; } } }; +static_assert(s
Re: [Lldb-commits] [PATCH] D22628: Fixing layout of elf-core file related structures
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Ok, nevermind then. Looks good. https://reviews.llvm.org/D22628 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r276411 - Support loading files even when incorrect file name specified by the linker
Author: tberghammer Date: Fri Jul 22 07:55:35 2016 New Revision: 276411 URL: http://llvm.org/viewvc/llvm-project?rev=276411&view=rev Log: Support loading files even when incorrect file name specified by the linker "Incorrect" file name seen on Android whene the main executable is called "app_process32" (or 64) but the linker specifies the package name (e.g. com.android.calculator2). Additionally it can be present in case of some linker bugs. This CL adds logic to try to fetch the correct file name from the proc file system based on the base address sepcified by the linker in case we are failed to load the module by name. Differential revision: http://reviews.llvm.org/D22219 Modified: lldb/trunk/docs/lldb-gdb-remote.txt lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h lldb/trunk/include/lldb/Target/MemoryRegionInfo.h lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py lldb/trunk/source/API/SBMemoryRegionInfo.cpp lldb/trunk/source/Core/DynamicLoader.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Modified: lldb/trunk/docs/lldb-gdb-remote.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=276411&r1=276410&r2=276411&view=diff == --- lldb/trunk/docs/lldb-gdb-remote.txt (original) +++ lldb/trunk/docs/lldb-gdb-remote.txt Fri Jul 22 07:55:35 2016 @@ -888,6 +888,12 @@ tuples to return are: permissions:; // is a string that contains one // or more of the characters from "rwx" + +name:; // is a hex encoded string that contains the name of + // the memory region mapped at the given address. In case of + // regions backed by a file it have to be the absolute path of + // the file while for anonymous regions it have to be the name + // associated to the region if that is available. error:; // where is // a hex encoded string value that Modified: lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h?rev=276411&r1=276410&r2=276411&view=diff == --- lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h (original) +++ lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h Fri Jul 22 07:55:35 2016 @@ -86,6 +86,19 @@ public: bool IsMapped (); + +//-- +/// Returns the name of the memory region mapped at the given +/// address. +/// +/// @return +/// In case of memory mapped files it is the absolute path of +/// the file otherwise it is a name associated with the memory +/// region. If no name can be determined the returns nullptr. +//-- +const char * +GetName(); + bool operator == (const lldb::SBMemoryRegionInfo &rhs) const; Modified: lldb/trunk/include/lldb/Target/MemoryRegionInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/MemoryRegionInfo.h?rev=276411&r1=276410&r2=276411&view=diff == --- lldb/trunk/include/lldb/Target/MemoryRegionInfo.h (original) +++ lldb/trunk/include/lldb/Target/MemoryRegionInfo.h Fri Jul 22 07:55:35 2016 @@ -10,6 +10,7 @@ #ifndef lldb_MemoryRegionInfo_h #define lldb_MemoryRegionInfo_h +#include "lldb/Core/ConstString.h" #include "lldb/Core/RangeMap.h" #include "lldb/Utility/Range.h" @@ -81,6 +82,12 @@ namespace lldb_private { return m_mapped; } + +const ConstString& +GetName () const +{ +return m_name; +} void SetReadable (OptionalBool val) @@ -106,6 +113,12 @@ namespace lldb_private m_mapped = val; } +void +SetName (const char* name) +{ +m_name = ConstString(name); +} + //-- // Get permissions as a uint32_t that is a mask of one or more bits from // the lldb::Permissions @@ -157,6 +170,7 @@ namespace lldb_private OptionalBool m_write; OptionalBool m_execute; OptionalBool m_mapped; +ConstString m_name; }; } Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/tes
Re: [Lldb-commits] [PATCH] D22219: Support loading files even when incorrect file name specified by the linker
This revision was automatically updated to reflect the committed changes. Closed by commit rL276411: Support loading files even when incorrect file name specified by the linker (authored by tberghammer). Changed prior to commit: https://reviews.llvm.org/D22219?vs=63664&id=65064#toc Repository: rL LLVM https://reviews.llvm.org/D22219 Files: lldb/trunk/docs/lldb-gdb-remote.txt lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h lldb/trunk/include/lldb/Target/MemoryRegionInfo.h lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py lldb/trunk/source/API/SBMemoryRegionInfo.cpp lldb/trunk/source/Core/DynamicLoader.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -2221,6 +2221,15 @@ response.PutChar (';'); } + +// Name +ConstString name = region_info.GetName(); +if (name) +{ +response.PutCString("name:"); +response.PutCStringAsRawHex8(name.AsCString()); +response.PutChar(';'); +} } return SendPacketNoLock(response.GetData(), response.GetSize()); Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp === --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2458,6 +2458,13 @@ region_info.SetMapped(MemoryRegionInfo::eNo); } } +else if (name.compare ("name") == 0) +{ +StringExtractorGDBRemote name_extractor; +name_extractor.GetStringRef().swap(value); +name_extractor.GetHexByteString(value); +region_info.SetName(value.c_str()); +} else if (name.compare ("error") == 0) { StringExtractorGDBRemote name_extractor; Index: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp === --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1678,6 +1678,20 @@ else return Error ("unexpected /proc/{pid}/maps exec permission char"); +line_extractor.GetChar(); // Read the private bit +line_extractor.SkipSpaces(); // Skip the separator +line_extractor.GetHexMaxU64(false, 0); // Read the offset +line_extractor.GetHexMaxU64(false, 0); // Read the major device number +line_extractor.GetChar(); // Read the device id separator +line_extractor.GetHexMaxU64(false, 0); // Read the major device number +line_extractor.SkipSpaces(); // Skip the separator +line_extractor.GetU64(0, 10); // Read the inode number + +line_extractor.SkipSpaces(); +const char* name = line_extractor.Peek(); +if (name) +memory_region_info.SetName(name); + return Error (); } Index: lldb/trunk/source/API/SBMemoryRegionInfo.cpp === --- lldb/trunk/source/API/SBMemoryRegionInfo.cpp +++ lldb/trunk/source/API/SBMemoryRegionInfo.cpp @@ -110,6 +110,11 @@ return m_opaque_ap->GetMapped() == MemoryRegionInfo::eYes; } +const char * +SBMemoryRegionInfo::GetName () { +return m_opaque_ap->GetName().AsCString(); +} + bool SBMemoryRegionInfo::GetDescription (SBStream &description) { Index: lldb/trunk/source/Core/DynamicLoader.cpp === --- lldb/trunk/source/Core/DynamicLoader.cpp +++ lldb/trunk/source/Core/DynamicLoader.cpp @@ -12,13 +12,14 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Target/DynamicLoader.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Core/PluginManager.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" +#include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -177,37 +178,67 @@ { Target &target
[Lldb-commits] [lldb] r276485 - Remove some tab characters that snuck in to my mnost recent edits.
Author: jmolenda Date: Fri Jul 22 17:26:26 2016 New Revision: 276485 URL: http://llvm.org/viewvc/llvm-project?rev=276485&view=rev Log: Remove some tab characters that snuck in to my mnost recent edits. Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp?rev=276485&r1=276484&r2=276485&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp Fri Jul 22 17:26:26 2016 @@ -1263,5 +1263,5 @@ DynamicLoaderDarwin::UseDYLDSPI (Process log->Printf ("DynamicLoaderDarwin::UseDYLDSPI: Use old DynamicLoader plugin"); } - return use_new_spi_interface; +return use_new_spi_interface; } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp?rev=276485&r1=276484&r2=276485&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp Fri Jul 22 17:26:26 2016 @@ -70,10 +70,10 @@ DynamicLoaderMacOS::CreateInstance (Proc } } - if (UseDYLDSPI (process) == false) - { - create = false; - } +if (UseDYLDSPI (process) == false) +{ +create = false; +} if (create) return new DynamicLoaderMacOS (process); @@ -189,8 +189,8 @@ DynamicLoaderMacOS::DoInitialImageFetch( { if (JSONImageInformationIntoImageInfo (all_image_info_json_sp, image_infos)) { - if (log) - log->Printf ("Initial module fetch: Adding %" PRId64 " modules.\n", (uint64_t) image_infos.size()); +if (log) +log->Printf ("Initial module fetch: Adding %" PRId64 " modules.\n", (uint64_t) image_infos.size()); UpdateSpecialBinariesFromNewImageInfos (image_infos); AddModulesUsingImageInfos (image_infos); @@ -233,11 +233,11 @@ DynamicLoaderMacOS::NotifyBreakpointHit if (process != dyld_instance->m_process) return false; - if (dyld_instance->m_image_infos_stop_id != UINT32_MAX +if (dyld_instance->m_image_infos_stop_id != UINT32_MAX && process->GetStopID() < dyld_instance->m_image_infos_stop_id) - { - return false; - } +{ +return false; +} const lldb::ABISP &abi = process->GetABI(); if (abi) @@ -249,7 +249,7 @@ DynamicLoaderMacOS::NotifyBreakpointHit Value mode_value; // enum dyld_notify_mode { dyld_notify_adding=0, dyld_notify_removing=1, dyld_notify_remove_all=2 }; Value count_value; // unsigned long count - Value headers_value; // uint64_t machHeaders[] (aka void*) +Value headers_value; // uint64_t machHeaders[] (aka void*) CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); CompilerType clang_uint32_type = clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint, 32); @@ -258,7 +258,7 @@ DynamicLoaderMacOS::NotifyBreakpointHit mode_value.SetValueType (Value::eValueTypeScalar); mode_value.SetCompilerType (clang_uint32_type); - if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 4) +if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 4) { count_value.SetValueType (Value::eValueTypeScalar); count_value.SetCompilerType (clang_uint32_type); @@ -422,7 +422,7 @@ DynamicLoaderMacOS::GetDyldLockVariableA // Look for this symbol: // -// int__attribute__((visibility("hidden"))) _dyld_global_lock_held = 0; +// int __attribute__((visibility("hidden"))) _dyld_global_lock_held = 0; // // in libdyld.dylib. Error ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits