[Lldb-commits] [lldb] r274741 - Implement GetMemoryRegions() for Linux and Mac OSX core files.
Author: hhellyer Date: Thu Jul 7 03:21:28 2016 New Revision: 274741 URL: http://llvm.org/viewvc/llvm-project?rev=274741&view=rev Log: Implement GetMemoryRegions() for Linux and Mac OSX core files. Summary: This patch fills in the implementation of GetMemoryRegions() on the Linux and Mac OS core file implementations of lldb_private::Process (ProcessElfCore::GetMemoryRegions and ProcessMachCore::GetMemoryRegions.) The GetMemoryRegions API was added under: http://reviews.llvm.org/D20565 The patch re-uses the m_core_range_infos list that was recently added to implement GetMemoryRegionInfo in both ProcessElfCore and ProcessMachCore to ensure the returned regions match the regions returned by Process::GetMemoryRegionInfo(addr_t load_addr, MemoryRegionInfo ®ion_info). Reviewers: clayborg Subscribers: labath, lldb-commits Differential Revision: http://reviews.llvm.org/D21751 Modified: lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h lldb/trunk/include/lldb/Core/RangeMap.h lldb/trunk/include/lldb/Target/MemoryRegionInfo.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py lldb/trunk/scripts/interface/SBMemoryRegionInfo.i lldb/trunk/source/API/SBMemoryRegionInfo.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h?rev=274741&r1=274740&r2=274741&view=diff == --- lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h (original) +++ lldb/trunk/include/lldb/API/SBMemoryRegionInfo.h Thu Jul 7 03:21:28 2016 @@ -76,6 +76,16 @@ public: bool IsExecutable (); +//-- +/// Check if this memory address is mapped into the process address +/// space. +/// +/// @return +/// true if this memory address is in the process address space. +//-- +bool +IsMapped (); + bool operator == (const lldb::SBMemoryRegionInfo &rhs) const; Modified: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=274741&r1=274740&r2=274741&view=diff == --- lldb/trunk/include/lldb/Core/RangeMap.h (original) +++ lldb/trunk/include/lldb/Core/RangeMap.h Thu Jul 7 03:21:28 2016 @@ -1352,7 +1352,7 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound(m_entries.begin(), end, addr, [](const Entry &lhs, B rhs_base) -> bool { -return lhs.GetRangeBase() < rhs_base; +return lhs.GetRangeEnd() <= rhs_base; }); if (pos != end) Modified: lldb/trunk/include/lldb/Target/MemoryRegionInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/MemoryRegionInfo.h?rev=274741&r1=274740&r2=274741&view=diff == --- lldb/trunk/include/lldb/Target/MemoryRegionInfo.h (original) +++ lldb/trunk/include/lldb/Target/MemoryRegionInfo.h Thu Jul 7 03:21:28 2016 @@ -30,7 +30,8 @@ namespace lldb_private m_range (), m_read (eDontKnow), m_write (eDontKnow), -m_execute (eDontKnow) +m_execute (eDontKnow), +m_mapped (eDontKnow) { } @@ -75,6 +76,12 @@ namespace lldb_private return m_execute; } +OptionalBool +GetMapped () const +{ +return m_mapped; +} + void SetReadable (OptionalBool val) { @@ -92,6 +99,12 @@ namespace lldb_private { m_execute = val; } + +void +SetMapped (OptionalBool val) +{ +m_mapped = val; +} //-- // Get permissions as a uint32_t that is a mask of one or more bits from @@ -128,7 +141,8 @@ namespace lldb_private return m_range == rhs.m_range && m_read == rhs.m_read && m_write == rhs.m_write && - m_execute == rhs.m_execute; + m_execute == rhs.m_execute && +
Re: [Lldb-commits] [PATCH] D22081: Use shell cat command as a workaround if ADB stat cannot lookup a file
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Looks good. Please also run clang-format over the patch (also when I don't request it, i tend to forget about that). Comment at: source/Plugins/Platform/Android/AdbClient.cpp:429 @@ +428,3 @@ +dst.write (&output_buffer[0], output_buffer.size ()); +return Error (); +} We should close the file and make check for the error flags on the stream to make sure the write was successful. http://reviews.llvm.org/D22081 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D20464: [LLDB][MIPS] Check if libatomic needs to be specified explicitly.
nitesh.jain added a comment. In http://reviews.llvm.org/D20464#473884, @Eugene.Zelenko wrote: > As fas as I could judge from log, you built LLDB with LLVM/Clang. But problem > happens when it's necessary to build LLDB separately from LLVM/Clang > (standalone build). Then we need to introduce a 64 bit atomic check in cmake/modules/LLDBStandalone.cmake. what do you thing? Thanks Repository: rL LLVM http://reviews.llvm.org/D20464 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274743 - Try to fix the OSX build with old SDK after r274725
Author: tberghammer Date: Thu Jul 7 05:38:05 2016 New Revision: 274743 URL: http://llvm.org/viewvc/llvm-project?rev=274743&view=rev Log: Try to fix the OSX build with old SDK after r274725 Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=274743&r1=274742&r2=274743&view=diff == --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Thu Jul 7 05:38:05 2016 @@ -631,8 +631,14 @@ MachProcess::GetMachOInformationFromMemo if (ReadMemory (load_cmds_p, sizeof (struct uuid_command), &uuidcmd) == sizeof (struct uuid_command)) uuid_copy (inf.uuid, uuidcmd.uuid); } -if (lc.cmd == LC_VERSION_MIN_IPHONEOS || lc.cmd == LC_VERSION_MIN_MACOSX -|| lc.cmd == LC_VERSION_MIN_WATCHOS || lc.cmd == LC_VERSION_MIN_TVOS) +bool lc_cmd_known = lc.cmd == LC_VERSION_MIN_IPHONEOS || lc.cmd == LC_VERSION_MIN_MACOSX; +#if defined(LC_VERSION_MIN_TVOS) +lc_cmd_known |= lc.cmd == LC_VERSION_MIN_TVOS; +#endif +#if defined(LC_VERSION_MIN_WATCHOS) +lc_cmd_known |= lc.cmd == LC_VERSION_MIN_WATCHOS; +#endif +if (lc_cmd_known) { struct version_min_command vers_cmd; if (ReadMemory (load_cmds_p, sizeof (struct version_min_command), &vers_cmd) != sizeof (struct version_min_command)) @@ -647,12 +653,16 @@ MachProcess::GetMachOInformationFromMemo case LC_VERSION_MIN_MACOSX: inf.min_version_os_name = "macosx"; break; +#if defined(LC_VERSION_MIN_TVOS) case LC_VERSION_MIN_TVOS: inf.min_version_os_name = "tvos"; break; +#endif +#if defined(LC_VERSION_MIN_WATCHOS) case LC_VERSION_MIN_WATCHOS: inf.min_version_os_name = "watchos"; break; +#endif default: return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r274725 - debugserver will now report the minimum version load command
Hi Jason, This CL caused a build failure on our OSX build bot: http://lab.llvm.org:8011/builders/lldb-x86_64-darwin-13.4/builds/11405/steps/ninja%20build%20local/logs/stdio I committed in a possible fix at http://reviews.llvm.org/rL274743 but please take a look as I don't know too much about this code so my fix might be wrong. Thanks, Tamas On Thu, Jul 7, 2016 at 4:19 AM Jason Molenda via lldb-commits < lldb-commits@lists.llvm.org> wrote: > Author: jmolenda > Date: Wed Jul 6 22:12:01 2016 > New Revision: 274725 > > URL: http://llvm.org/viewvc/llvm-project?rev=274725&view=rev > Log: > debugserver will now report the minimum version load command > os name and version # from the mach-o binary as it scans the > header/load commands from memory and sends the details back > in the jGetLoadedDynamicLibrariesInfos response. lldb isn't > using these fields yet but I have a suspicion I'm going to > need them soon. > > > > Modified: > lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h > lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=274725&r1=274724&r2=274725&view=diff > > == > --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Wed Jul 6 > 22:12:01 2016 > @@ -69,6 +69,8 @@ public: > struct mach_header_64 mach_header; > std::vector segments; > uuid_t uuid; > +std::string min_version_os_name; > +std::string min_version_os_version; > }; > > struct binary_image_information > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=274725&r1=274724&r2=274725&view=diff > > == > --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Wed Jul 6 > 22:12:01 2016 > @@ -631,6 +631,44 @@ MachProcess::GetMachOInformationFromMemo > if (ReadMemory (load_cmds_p, sizeof (struct uuid_command), > &uuidcmd) == sizeof (struct uuid_command)) > uuid_copy (inf.uuid, uuidcmd.uuid); > } > +if (lc.cmd == LC_VERSION_MIN_IPHONEOS || lc.cmd == > LC_VERSION_MIN_MACOSX > +|| lc.cmd == LC_VERSION_MIN_WATCHOS || lc.cmd == > LC_VERSION_MIN_TVOS) > +{ > +struct version_min_command vers_cmd; > +if (ReadMemory (load_cmds_p, sizeof (struct > version_min_command), &vers_cmd) != sizeof (struct version_min_command)) > +{ > +return false; > +} > +switch (lc.cmd) > +{ > +case LC_VERSION_MIN_IPHONEOS: > +inf.min_version_os_name = "iphoneos"; > +break; > +case LC_VERSION_MIN_MACOSX: > +inf.min_version_os_name = "macosx"; > +break; > +case LC_VERSION_MIN_TVOS: > +inf.min_version_os_name = "tvos"; > +break; > +case LC_VERSION_MIN_WATCHOS: > +inf.min_version_os_name = "watchos"; > +break; > +default: > +return false; > +} > +uint32_t = vers_cmd.sdk >> 16; > +uint32_t yy = (vers_cmd.sdk >> 8) & 0xffu; > +uint32_t zz = vers_cmd.sdk & 0xffu; > +inf.min_version_os_version = ""; > +inf.min_version_os_version += std::to_string(); > +inf.min_version_os_version += "."; > +inf.min_version_os_version += std::to_string(yy); > +if (zz != 0) > +{ > +inf.min_version_os_version += "."; > +inf.min_version_os_version += std::to_string(zz); > +} > +} > load_cmds_p += lc.cmdsize; > } > return true; > @@ -657,6 +695,13 @@ MachProcess::FormatDynamicLibrariesIntoJ > uuid_unparse_upper (image_infos[i].macho_info.uuid, uuidstr); > image_info_dict_sp->AddStringItem ("uuid", uuidstr); > > +if (image_infos[i].macho_info.min_version_os_name.empty() == false > +&& image_infos[i].macho_info.min_version_os_version.empty() > == false) > +{ > +image_info_dict_sp->AddStringItem ("min_version_os_name", > image_infos[i].macho_info.min_version_os_name); > +image_info_dict_sp->AddStringItem ("min_version_os_sdk", > image_infos[i].macho_info.min_version_os_version); > +} > + > JSONGenerator::DictionarySP mach_header_dict_sp (ne
Re: [Lldb-commits] [PATCH] D22052: Respect `ANDROID_SERIAL` environment variable used by ADB
ldrumm removed rL LLVM as the repository for this revision. ldrumm updated this revision to Diff 63055. ldrumm added a comment. - Ensure if ANDROID_SERIAL is set, it exists in the list of connected devices (Address feedback from @ovyalov) - Also add a hint in the error message in case multiple devices are attached and no serial number is available. http://reviews.llvm.org/D22052 Files: source/Plugins/Platform/Android/AdbClient.cpp Index: source/Plugins/Platform/Android/AdbClient.cpp === --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -99,19 +100,24 @@ if (error.Fail()) return error; -if (device_id.empty()) +std::string android_serial; +if (!device_id.empty()) +android_serial = device_id; +else if (const char *env_serial = std::getenv("ANDROID_SERIAL")) +android_serial = env_serial; + +if (android_serial.empty()) { if (connect_devices.size() != 1) -return Error("Expected a single connected device, got instead %" PRIu64, -static_cast(connect_devices.size())); - +return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'", + connect_devices.size()); adb.SetDeviceID(connect_devices.front()); } else { -auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id); +auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial); if (find_it == connect_devices.end()) -return Error("Device \"%s\" not found", device_id.c_str()); +return Error("Device \"%s\" not found", android_serial.c_str()); adb.SetDeviceID(*find_it); } Index: source/Plugins/Platform/Android/AdbClient.cpp === --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -99,19 +100,24 @@ if (error.Fail()) return error; -if (device_id.empty()) +std::string android_serial; +if (!device_id.empty()) +android_serial = device_id; +else if (const char *env_serial = std::getenv("ANDROID_SERIAL")) +android_serial = env_serial; + +if (android_serial.empty()) { if (connect_devices.size() != 1) -return Error("Expected a single connected device, got instead %" PRIu64, -static_cast(connect_devices.size())); - +return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'", + connect_devices.size()); adb.SetDeviceID(connect_devices.front()); } else { -auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id); +auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial); if (find_it == connect_devices.end()) -return Error("Device \"%s\" not found", device_id.c_str()); +return Error("Device \"%s\" not found", android_serial.c_str()); adb.SetDeviceID(*find_it); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274750 - Fix for PrintStackTraces
Author: ravitheja Date: Thu Jul 7 08:00:29 2016 New Revision: 274750 URL: http://llvm.org/viewvc/llvm-project?rev=274750&view=rev Log: Fix for PrintStackTraces Summary: The issue arises due to the wrong unwinder used for the first stack frame, where the default unwinder returns erroneous frame whereas the fallback would have given the correct frame had it been used. The following fix consists of two parts -> 1) The first part changes the unwinding strategy, earlier the default unwinder was used to get 2 more stack frames and if it failed a fallback unwinder was used. Now we try to obtain as many frames (max 10) as we can get from default unwinder and also fallback unwinder and use the one that gives more number of frames. 2) Normally unwindplans are assosciated with functions and the row to be used is obtained from the offset (obtained from the low_pc of the function symbol). Sometimes it may occur that the unwindplan is assosciated to the complete Elf section in which case the offset calculation would be wrong as the debugger uses the same offset originally obtained from the function symbol. Hence this offset is recalculated. Reviewers: tberghammer, lldb-commits, labath, jasonmolenda Subscribers: jingham Differential Revision: http://reviews.llvm.org/D21221 Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/ lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile?rev=274750&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile Thu Jul 7 08:00:29 2016 @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +CFLAGS ?= -g -fomit-frame-pointer + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py?rev=274750&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py Thu Jul 7 08:00:29 2016 @@ -0,0 +1,51 @@ +""" +Test that we can backtrace correctly from Non ABI functions on the stack +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class EHFrameBasedUnwind(TestBase): +mydir = TestBase.compute_mydir(__file__) + + +@skipUnlessPlatform(['linux']) +@skipIf(archs=["aarch64", "arm", "i386", "i686"]) +def test (self): +"""Test that we can backtrace correctly from Non ABI functions on the stack""" +self.build() +self.setTearDownCleanup() + +exe = os.path.join(os.getcwd(), "a.out") +target = self.dbg.CreateTarget(exe) + +self.assertTrue(target, VALID_TARGET) + +lldbutil.run_break_set_by_symbol (self, "func") + +process = target.LaunchSimple (["abc", "xyz"], None, self.get_process_working_directory()) + +if not process: +self.fail("SBTarget.Launch() failed") + +if process.GetState() != lldb.eStateStopped: +self.fail("Process should be in the 'stopped' state, " + "instead the actual state is: '%s'" % + lldbutil.state_type_to_str(process.GetState())) + +stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) +self.expect(stacktraces, exe=False, +substrs = ['(int)argc=3']) + +self.runCmd("thread step-inst") + +stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) +self.expect(stacktraces, exe=False, +substrs = ['(int)argc=3']) Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c?rev=274750&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c (added) +++ lldb/t
Re: [Lldb-commits] [PATCH] D20464: [LLDB][MIPS] Check if libatomic needs to be specified explicitly.
Eugene.Zelenko added a comment. > Then we need to introduce a 64 bit atomic check in > cmake/modules/LLDBStandalone.cmake. What do you think? > > Thanks I think this should be right solution. Repository: rL LLVM http://reviews.llvm.org/D20464 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D22081: Use shell cat command as a workaround if ADB stat cannot lookup a file
ldrumm added a subscriber: ldrumm. Comment at: source/Plugins/Platform/Android/PlatformAndroid.cpp:244 @@ +243,3 @@ +char cmd[PATH_MAX]; +snprintf (cmd, sizeof (cmd), "cat '%s'", source_spec.GetCString (false)); + I have some issues with this approach. If the filename contains the literal `'` character, this command fail with unpredictable results. The solution would seem to be to pass a list of strings a'la POSIX `exec` i.e.: `- AdbClient::internalShell (const char* command, uint32_t timeout_ms, std::vector &output_buf)` `+ AdbClient::internalShell (std::vector command, uint32_t timeout_ms, std::vector &output_buf)` but on a little investigation, it does seem that the adb protocol is limited to escaping for the shell command, and does not propagate return status. If I run the following python command: ``` import subprocess print(subprocess.check_output(['adb', 'shell', 'cat', "/data/'"])) ``` The TCP conversation looks like this: ``` 0017host:transport:6D8E7152 OKAY 0012shell:cat /data/\' OKAY ``` When I try and `cat` a file that doesn't exist: ``` 0017host:transport:6D8E7152OKAY0016 shell:cat /nonexistent OKAY/system/bin/sh: cat: /nonexistent: No such file or directory ``` So there's seemingly no way to know whether the file exists using `adb shell cat $FILE`, or whether you're getting the error message as contents. However, if I use the adb pull command on the same file, the return status is propogated to the calling shell because the stat fails: ``` 0017host:transport:6D8E7152 OKAY 0005sync: OKAY STAT/nonexistent STAT ``` So it seems like the protocol itself does not handle escaping consistently but requires clients to do this on a per adb command basis and there is no way to know the difference between success and failure for the `cat file` approach. Unfortunately, I don't actually have a better solution to offer here. http://reviews.llvm.org/D22081 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D22081: Use shell cat command as a workaround if ADB stat cannot lookup a file
labath added a comment. You raised good points here, Luke. I've thought about the quoting issue, but as you have already noticed there is no way to pass arguments containing quotes to adb correctly. Thinking about it more, what we could do is detect this situation (look for `'` in the file name) and abort the whole process even before issuing the "adb shell" command. As for the return value, this should not be a big problem, as further down the line we will discover that this is not a real ELF file and ignore it, but perhaps we could help here by searching for the file name in the first 1K bytes of the result, and ignoring the file if we find it? Oleksiy, what do you think? http://reviews.llvm.org/D22081 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274762 - Bump up timeout in TestCallWithTimeout
Author: labath Date: Thu Jul 7 10:45:57 2016 New Revision: 274762 URL: http://llvm.org/viewvc/llvm-project?rev=274762&view=rev Log: Bump up timeout in TestCallWithTimeout remote targets need a bit more time to get their act together Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py?rev=274762&r1=274761&r2=274762&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py Thu Jul 7 10:45:57 2016 @@ -57,7 +57,7 @@ class ExprCommandWithTimeoutsTestCase(Te frame = thread.GetFrameAtIndex(0) -value = frame.EvaluateExpression("wait_a_while(25)", options) +value = frame.EvaluateExpression("wait_a_while(30)", options) self.assertTrue (value.IsValid()) self.assertFalse (value.GetError().Success()) @@ -65,7 +65,7 @@ class ExprCommandWithTimeoutsTestCase(Te interp = self.dbg.GetCommandInterpreter() result = lldb.SBCommandReturnObject() -return_value = interp.HandleCommand("expr -t 100 -u true -- wait_a_while(25)", result) +return_value = interp.HandleCommand("expr -t 100 -u true -- wait_a_while(30)", result) self.assertTrue (return_value == lldb.eReturnStatusFailed) # Okay, now do it again with long enough time outs: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274763 - [LLGS] Work around an adb bug on Android <=M
Author: labath Date: Thu Jul 7 10:46:00 2016 New Revision: 274763 URL: http://llvm.org/viewvc/llvm-project?rev=274763&view=rev Log: [LLGS] Work around an adb bug on Android <=M On android M it can happen that we get a ETXTBSY, when we try to launch the inferior. Sleeping and retrying should help us get more stable results. Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=274763&r1=274762&r2=274763&view=diff == --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu Jul 7 10:46:00 2016 @@ -561,6 +561,18 @@ NativeProcessLinux::ChildFunc(const Laun // Execute. We should never return... execve(args.m_argv[0], const_cast(args.m_argv), const_cast(envp)); +if (errno == ETXTBSY) +{ +// On android M and earlier we can get this error because the adb deamon can hold a write +// handle on the executable even after it has finished uploading it. This state lasts +// only a short time and happens only when there are many concurrent adb commands being +// issued, such as when running the test suite. (The file remains open when someone does +// an "adb shell" command in the fork() child before it has had a chance to exec.) Since +// this state should clear up quickly, wait a while and then give it one more go. +usleep(1); +execve(args.m_argv[0], const_cast(args.m_argv), const_cast(envp)); +} + // ...unless exec fails. In which case we definitely need to end the child here. ExitChildAbnormally(eExecFailed); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D22097: [zorg] Remove flunkOnFailure=False from the scripted LLDB builder
labath created this revision. labath added reviewers: chying, gkistanova. labath added a subscriber: lldb-commits. The unit tests appear to be running reliably, so let's make them affect the build output. (All scripted LLDB builtbots are still marked as experimental though.) http://reviews.llvm.org/D22097 Files: zorg/buildbot/builders/LLDBBuilder.py Index: zorg/buildbot/builders/LLDBBuilder.py === --- zorg/buildbot/builders/LLDBBuilder.py +++ zorg/buildbot/builders/LLDBBuilder.py @@ -971,8 +971,6 @@ command=[pathSep + 'testUnit' + scriptExt], description=["testing"], descriptionDone=["unit test"], - flunkOnFailure=False, - warnOnFailure=False, workdir='scripts')) getTestSteps(f, scriptExt, pathSep) # upload test traces Index: zorg/buildbot/builders/LLDBBuilder.py === --- zorg/buildbot/builders/LLDBBuilder.py +++ zorg/buildbot/builders/LLDBBuilder.py @@ -971,8 +971,6 @@ command=[pathSep + 'testUnit' + scriptExt], description=["testing"], descriptionDone=["unit test"], - flunkOnFailure=False, - warnOnFailure=False, workdir='scripts')) getTestSteps(f, scriptExt, pathSep) # upload test traces ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D22052: Respect `ANDROID_SERIAL` environment variable used by ADB
ovyalov accepted this revision. ovyalov added a comment. This revision is now accepted and ready to land. LGTM http://reviews.llvm.org/D22052 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274776 - Respect ANDROID_SERIAL environment variable used by ADB
Author: ldrumm Date: Thu Jul 7 13:02:44 2016 New Revision: 274776 URL: http://llvm.org/viewvc/llvm-project?rev=274776&view=rev Log: Respect ANDROID_SERIAL environment variable used by ADB When multiple Android devices are attached, the default behaviour of ADB is to resolve a device number based on the presence of ANDROID_SERIAL if the serial number is not explicitly passed by the -s parameter. This patch emulates that behaviour in lldb's ADB platform connector Differential Revision: http://reviews.llvm.org/D22052 Modified: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp Modified: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp?rev=274776&r1=274775&r2=274776&view=diff == --- lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp (original) +++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp Thu Jul 7 13:02:44 2016 @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -99,19 +100,24 @@ AdbClient::CreateByDeviceID(const std::s if (error.Fail()) return error; -if (device_id.empty()) +std::string android_serial; +if (!device_id.empty()) +android_serial = device_id; +else if (const char *env_serial = std::getenv("ANDROID_SERIAL")) +android_serial = env_serial; + +if (android_serial.empty()) { if (connect_devices.size() != 1) -return Error("Expected a single connected device, got instead %" PRIu64, -static_cast(connect_devices.size())); - +return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'", + connect_devices.size()); adb.SetDeviceID(connect_devices.front()); } else { -auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id); +auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial); if (find_it == connect_devices.end()) -return Error("Device \"%s\" not found", device_id.c_str()); +return Error("Device \"%s\" not found", android_serial.c_str()); adb.SetDeviceID(*find_it); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D22052: Respect `ANDROID_SERIAL` environment variable used by ADB
This revision was automatically updated to reflect the committed changes. ldrumm marked an inline comment as done. Closed by commit rL274776: Respect ANDROID_SERIAL environment variable used by ADB (authored by ldrumm). Changed prior to commit: http://reviews.llvm.org/D22052?vs=63055&id=63095#toc Repository: rL LLVM http://reviews.llvm.org/D22052 Files: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp Index: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp === --- lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp +++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -99,19 +100,24 @@ if (error.Fail()) return error; -if (device_id.empty()) +std::string android_serial; +if (!device_id.empty()) +android_serial = device_id; +else if (const char *env_serial = std::getenv("ANDROID_SERIAL")) +android_serial = env_serial; + +if (android_serial.empty()) { if (connect_devices.size() != 1) -return Error("Expected a single connected device, got instead %" PRIu64, -static_cast(connect_devices.size())); - +return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'", + connect_devices.size()); adb.SetDeviceID(connect_devices.front()); } else { -auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id); +auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial); if (find_it == connect_devices.end()) -return Error("Device \"%s\" not found", device_id.c_str()); +return Error("Device \"%s\" not found", android_serial.c_str()); adb.SetDeviceID(*find_it); } Index: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp === --- lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp +++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -99,19 +100,24 @@ if (error.Fail()) return error; -if (device_id.empty()) +std::string android_serial; +if (!device_id.empty()) +android_serial = device_id; +else if (const char *env_serial = std::getenv("ANDROID_SERIAL")) +android_serial = env_serial; + +if (android_serial.empty()) { if (connect_devices.size() != 1) -return Error("Expected a single connected device, got instead %" PRIu64, -static_cast(connect_devices.size())); - +return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'", + connect_devices.size()); adb.SetDeviceID(connect_devices.front()); } else { -auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id); +auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial); if (find_it == connect_devices.end()) -return Error("Device \"%s\" not found", device_id.c_str()); +return Error("Device \"%s\" not found", android_serial.c_str()); adb.SetDeviceID(*find_it); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D22097: [zorg] Remove flunkOnFailure=False from the scripted LLDB builder
chying accepted this revision. chying added a comment. This revision is now accepted and ready to land. Looks good. http://reviews.llvm.org/D22097 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274783 - Add an "experimental" setting to disable injecting local variables into expressions.
Author: jingham Date: Thu Jul 7 13:25:48 2016 New Revision: 274783 URL: http://llvm.org/viewvc/llvm-project?rev=274783&view=rev Log: Add an "experimental" setting to disable injecting local variables into expressions. This feature was added to solve a lookup problem in expressions when local variables shadow ivars. That solution requires fully realizing all local variables to evaluate any expression, and can cause significant performance problems when evaluating expressions in frames that have many complex locals. Until we get a better solution, this setting mitigates the problem when you don't have local variables that shadow ivars. Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Expression/ExpressionSourceCode.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=274783&r1=274782&r2=274783&view=diff == --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Thu Jul 7 13:25:48 2016 @@ -63,6 +63,12 @@ typedef enum LoadCWDlldbinitFile //-- // TargetProperties //-- +class TargetExperimentalProperties : public Properties +{ +public: +TargetExperimentalProperties(); +}; + class TargetProperties : public Properties { public: @@ -237,6 +243,12 @@ public: void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info); + +bool +GetInjectLocalVariables(ExecutionContext *exe_ctx) const; + +void +SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b); private: //-- @@ -257,6 +269,7 @@ private: // Member variables. //-- ProcessLaunchInfo m_launch_info; +std::unique_ptr m_experimental_properties_up; }; class EvaluateExpressionOptions Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=274783&r1=274782&r2=274783&view=diff == --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Jul 7 13:25:48 2016 @@ -121,7 +121,7 @@ Properties::IsSettingExperimental(const return false; const char *experimental = GetExperimentalSettingsName(); -auto dot_pos = strchr(setting, '.'); +const char *dot_pos = strchr(setting, '.'); if (dot_pos == nullptr) return strcmp(experimental, setting) == 0; else Modified: lldb/trunk/source/Expression/ExpressionSourceCode.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=274783&r1=274782&r2=274783&view=diff == --- lldb/trunk/source/Expression/ExpressionSourceCode.cpp (original) +++ lldb/trunk/source/Expression/ExpressionSourceCode.cpp Thu Jul 7 13:25:48 2016 @@ -200,7 +200,8 @@ bool ExpressionSourceCode::GetText (std: const char *target_specific_defines = "typedef signed char BOOL;\n"; std::string module_macros; -if (Target *target = exe_ctx.GetTargetPtr()) +Target *target = exe_ctx.GetTargetPtr(); +if (target) { if (target->GetArchitecture().GetMachine() == llvm::Triple::aarch64) { @@ -278,8 +279,11 @@ bool ExpressionSourceCode::GetText (std: ConstString object_name; if (Language::LanguageIsCPlusPlus(frame->GetLanguage())) { -lldb::VariableListSP var_list_sp = frame->GetInScopeVariableList(false, true); -AddLocalVariableDecls(var_list_sp, lldb_local_var_decls); +if (target->GetInjectLocalVariables(&exe_ctx)) +{ +lldb::VariableListSP var_list_sp = frame->GetInScopeVariableList(false, true); +AddLocalVariableDecls(var_list_sp, lldb_local_var_decls); +} } } Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=274783&r1=274782&r2=274783&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Thu J
[Lldb-commits] [lldb] r274787 - Check whether Sema::CreateBuiltinUnaryOp returns an empty result.
Author: jingham Date: Thu Jul 7 14:06:37 2016 New Revision: 274787 URL: http://llvm.org/viewvc/llvm-project?rev=274787&view=rev Log: Check whether Sema::CreateBuiltinUnaryOp returns an empty result. If it does, calling AddInitializerToDecl will crash, so we should abort the result synthesis in this case. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=274787&r1=274786&r2=274787&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Thu Jul 7 14:06:37 2016 @@ -373,6 +373,8 @@ ASTResultSynthesizer::SynthesizeBodyResu ExprResult address_of_expr = m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr); if (address_of_expr.get()) m_sema->AddInitializerToDecl(result_decl, address_of_expr.get(), true, false); +else +return false; } else { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274788 - Fix DWARF 4 bitfield support in LLDB to support the DW_AT_data_bit_offset attribute.
Author: gclayton Date: Thu Jul 7 14:44:14 2016 New Revision: 274788 URL: http://llvm.org/viewvc/llvm-project?rev=274788&view=rev Log: Fix DWARF 4 bitfield support in LLDB to support the DW_AT_data_bit_offset attribute. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=274788&r1=274787&r2=274788&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Jul 7 14:44:14 2016 @@ -2808,6 +2808,7 @@ DWARFASTParserClang::ParseChildMembers(c uint32_t member_byte_offset = (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX; size_t byte_size = 0; int64_t bit_offset = 0; +uint64_t data_bit_offset = UINT64_MAX; size_t bit_size = 0; bool is_external = false; // On DW_TAG_members, this means the member is static uint32_t i; @@ -2827,6 +2828,7 @@ DWARFASTParserClang::ParseChildMembers(c case DW_AT_bit_offset: bit_offset = form_value.Signed(); break; case DW_AT_bit_size:bit_size = form_value.Unsigned(); break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; +case DW_AT_data_bit_offset: data_bit_offset = form_value.Unsigned(); break; case DW_AT_data_member_location: if (form_value.BlockData()) { @@ -3014,22 +3016,30 @@ DWARFASTParserClang::ParseChildMembers(c // AT_bit_size indicates the size of the field in bits. / -if (byte_size == 0) -byte_size = member_type->GetByteSize(); - -ObjectFile *objfile = die.GetDWARF()->GetObjectFile(); -if (objfile->GetByteOrder() == eByteOrderLittle) +if (data_bit_offset != UINT64_MAX) { -this_field_info.bit_offset += byte_size * 8; -this_field_info.bit_offset -= (bit_offset + bit_size); +this_field_info.bit_offset = data_bit_offset; } else { -this_field_info.bit_offset += bit_offset; +if (byte_size == 0) +byte_size = member_type->GetByteSize(); + +ObjectFile *objfile = die.GetDWARF()->GetObjectFile(); +if (objfile->GetByteOrder() == eByteOrderLittle) +{ +this_field_info.bit_offset += byte_size * 8; +this_field_info.bit_offset -= (bit_offset + bit_size); +} +else +{ +this_field_info.bit_offset += bit_offset; +} } if ((this_field_info.bit_offset >= parent_bit_size) || !last_field_info.NextBitfieldOffsetIsValid(this_field_info.bit_offset)) { +ObjectFile *objfile = die.GetDWARF()->GetObjectFile(); objfile->GetModule()->ReportWarning("0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid bit offset (0x%8.8" PRIx64 ") member will be ignored. Please file a bug against the compiler and include the preprocessed output for %s\n", die.GetID(), DW_TAG_value_to_name(tag), ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274809 - Fix it so that we only grab the typedef from the module DWARF file if the type that is typedef'ed is a declaration. This fixes the following bugs:
Author: gclayton Date: Thu Jul 7 18:57:39 2016 New Revision: 274809 URL: http://llvm.org/viewvc/llvm-project?rev=274809&view=rev Log: Fix it so that we only grab the typedef from the module DWARF file if the type that is typedef'ed is a declaration. This fixes the following bugs: [PR28156] TestWithModuleDebugging.py: failing on macOS https://llvm.org/bugs/show_bug.cgi?id=27412 https://llvm.org/bugs/show_bug.cgi?id=28156 Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=274809&r1=274808&r2=274809&view=diff == --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Jul 7 18:57:39 2016 @@ -275,30 +275,6 @@ DWARFASTParserClang::ParseTypeFromDWARF switch (tag) { case DW_TAG_typedef: -// Try to parse a typedef from the DWO file first as modules -// can contain typedef'ed structures that have no names like: -// -// typedef struct { int a; } Foo; -// -// In this case we will have a structure with no name and a -// typedef named "Foo" that points to this unnamed structure. -// The name in the typedef is the only identifier for the struct, -// so always try to get typedefs from DWO files if possible. -// -// The type_sp returned will be empty if the typedef doesn't exist -// in a DWO file, so it is cheap to call this function just to check. -// -// If we don't do this we end up creating a TypeSP that says this -// is a typedef to type 0x123 (the DW_AT_type value would be 0x123 -// in the DW_TAG_typedef), and this is the unnamed structure type. -// We will have a hard time tracking down an unnammed structure -// type in the module DWO file, so we make sure we don't get into -// this situation by always resolving typedefs from the DWO file. -type_sp = ParseTypeFromDWO(die, log); -if (type_sp) -return type_sp; - -LLVM_FALLTHROUGH; case DW_TAG_base_type: case DW_TAG_pointer_type: case DW_TAG_reference_type: @@ -352,6 +328,42 @@ DWARFASTParserClang::ParseTypeFromDWARF } } +if (tag == DW_TAG_typedef) +{ +// Try to parse a typedef from the DWO file first as modules +// can contain typedef'ed structures that have no names like: +// +// typedef struct { int a; } Foo; +// +// In this case we will have a structure with no name and a +// typedef named "Foo" that points to this unnamed structure. +// The name in the typedef is the only identifier for the struct, +// so always try to get typedefs from DWO files if possible. +// +// The type_sp returned will be empty if the typedef doesn't exist +// in a DWO file, so it is cheap to call this function just to check. +// +// If we don't do this we end up creating a TypeSP that says this +// is a typedef to type 0x123 (the DW_AT_type value would be 0x123 +// in the DW_TAG_typedef), and this is the unnamed structure type. +// We will have a hard time tracking down an unnammed structure +// type in the module DWO file, so we make sure we don't get into +// this situation by always resolving typedefs from the DWO file. +const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid)); + +// First make sure that the die that this is typedef'ed to _is_ +// just a declaration (DW_AT_declaration == 1), not a full definition +// since template types can't be represented in modules since only +// concrete instances of templates are ever emitted and modules +// won't contain those +if (encoding_die && encoding_die.G
Re: [Lldb-commits] [PATCH] D22081: Use shell cat command as a workaround if ADB stat cannot lookup a file
ovyalov updated this revision to Diff 63173. ovyalov added a comment. Addressed review comments: - Check whether shell command output starts with /system/bin/sh: in order to find out whether command failed - Fail-fast download if filename contains single-quotes - clang-format http://reviews.llvm.org/D22081 Files: source/Plugins/Platform/Android/AdbClient.cpp source/Plugins/Platform/Android/AdbClient.h source/Plugins/Platform/Android/PlatformAndroid.cpp Index: source/Plugins/Platform/Android/PlatformAndroid.cpp === --- source/Plugins/Platform/Android/PlatformAndroid.cpp +++ source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -230,7 +230,30 @@ if (error.Fail ()) return error; -return sync_service->PullFile (source_spec, destination); +uint32_t mode = 0, size = 0, mtime = 0; +error = sync_service->Stat(source_spec, mode, size, mtime); +if (error.Fail()) return error; + +if (mode != 0) return sync_service->PullFile(source_spec, destination); + +auto source_file = source_spec.GetCString(false); + +Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); +if (log) + log->Printf("Got mode == 0 on '%s': try to get file via 'shell cat'", + source_file); + +if (strchr(source_file, '\'') != nullptr) + return Error("Doesn't support single-quotes in filenames"); + +// mode == 0 can signify that adbd cannot access the file +// due security constraints - try "cat ..." as a fallback. +AdbClient adb(m_device_id); + +char cmd[PATH_MAX]; +snprintf(cmd, sizeof(cmd), "cat '%s'", source_file); + +return adb.ShellToFile(cmd, 6 /* ms */, destination); } Error Index: source/Plugins/Platform/Android/AdbClient.h === --- source/Plugins/Platform/Android/AdbClient.h +++ source/Plugins/Platform/Android/AdbClient.h @@ -119,6 +119,9 @@ Error Shell (const char* command, uint32_t timeout_ms, std::string* output); +Error ShellToFile(const char *command, uint32_t timeout_ms, + const FileSpec &output_file_spec); + std::unique_ptr GetSyncService (Error &error); @@ -156,8 +159,10 @@ Error StartSync (); -Error -ReadAllBytes (void *buffer, size_t size); +Error internalShell(const char *command, uint32_t timeout_ms, +std::vector &output_buf); + +Error ReadAllBytes(void *buffer, size_t size); std::string m_device_id; std::unique_ptr m_conn; Index: source/Plugins/Platform/Android/AdbClient.cpp === --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -383,31 +383,62 @@ return ::ReadAllBytes (*m_conn, buffer, size); } -Error -AdbClient::Shell (const char* command, uint32_t timeout_ms, std::string* output) -{ -auto error = SwitchDeviceTransport (); -if (error.Fail ()) -return Error ("Failed to switch to device transport: %s", error.AsCString ()); - -StreamString adb_command; -adb_command.Printf("shell:%s", command); -error = SendMessage (adb_command.GetData(), false); -if (error.Fail ()) -return error; - -error = ReadResponseStatus (); -if (error.Fail ()) -return error; - -std::vector in_buffer; -error = ReadMessageStream (in_buffer, timeout_ms); -if (error.Fail()) -return error; - -if (output) -output->assign(in_buffer.begin(), in_buffer.end()); -return error; +Error AdbClient::internalShell(const char *command, uint32_t timeout_ms, + std::vector &output_buf) { + output_buf.clear(); + + auto error = SwitchDeviceTransport(); + if (error.Fail()) +return Error("Failed to switch to device transport: %s", error.AsCString()); + + StreamString adb_command; + adb_command.Printf("shell:%s", command); + error = SendMessage(adb_command.GetData(), false); + if (error.Fail()) return error; + + error = ReadResponseStatus(); + if (error.Fail()) return error; + + error = ReadMessageStream(output_buf, timeout_ms); + if (error.Fail()) return error; + + // ADB doesn't propagate return code of shell execution - if + // output starts with /system/bin/sh: most likely command failed. + static const char *kShellPrefix = "/system/bin/sh:"; + if (output_buf.size() > strlen(kShellPrefix)) { +if (!memcmp(&output_buf[0], kShellPrefix, strlen(kShellPrefix))) + return Error("Shell command %s failed: %s", command, + std::string(output_buf.begin(), output_buf.end()).c_str()); + } + + return Error(); +} + +Error AdbClient::Shell(const char *command, uint32_t timeout_ms, + std::string *output) { + std::vector output_buffer; + auto error = internalShell(command, timeout_ms, output_buffer); + if (error.Fail()) retur
Re: [Lldb-commits] [PATCH] D22081: Use shell cat command as a workaround if ADB stat cannot lookup a file
ovyalov added a comment. In http://reviews.llvm.org/D22081#476766, @labath wrote: > You raised good points here, Luke. > > I've thought about the quoting issue, but as you have already noticed there > is no way to pass arguments containing quotes to adb correctly. Thinking > about it more, what we could do is detect this situation (look for `'` in the > file name) and abort the whole process even before issuing the "adb shell" > command. > > As for the return value, this should not be a big problem, as further down > the line we will discover that this is not a real ELF file and ignore it, but > perhaps we could help here by searching for the file name in the first 1K > bytes of the result, and ignoring the file if we find it? > > Oleksiy, what do you think? Initially I was thinking that we can pass any shell output to the caller so either module cache or ELF ObjectFile will verify its correctness - but since Platform::GetFile can be used to download an arbitrary file we should try to handle execution errors as much as we can. I added for "/system/bin/sh:" output prefix check - presumably it should cover majority of failures. As an alternative we can run a command like "$user_cmd || echo $rand_id" and then look whether output ends with $rand_id - but it might be an overkill. http://reviews.llvm.org/D22081 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r274822 - Add an API to unwind from a hand-called expression.
Author: jingham Date: Thu Jul 7 21:12:05 2016 New Revision: 274822 URL: http://llvm.org/viewvc/llvm-project?rev=274822&view=rev Log: Add an API to unwind from a hand-called expression. This is just an SB API way of doing "thread return -x". Modified: lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/scripts/interface/SBThread.i lldb/trunk/source/API/SBThread.cpp Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=274822&r1=274821&r2=274822&view=diff == --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Thu Jul 7 21:12:05 2016 @@ -150,6 +150,9 @@ public: SBError ReturnFromFrame (SBFrame &frame, SBValue &return_value); +SBError +UnwindInnermostExpression(); + //-- /// LLDB currently supports process centric debugging which means when any /// thread in a process stops, all other threads are stopped. The Suspend() Modified: lldb/trunk/scripts/interface/SBThread.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBThread.i?rev=274822&r1=274821&r2=274822&view=diff == --- lldb/trunk/scripts/interface/SBThread.i (original) +++ lldb/trunk/scripts/interface/SBThread.i Thu Jul 7 21:12:05 2016 @@ -259,6 +259,14 @@ public: SBError ReturnFromFrame (SBFrame &frame, SBValue &return_value); +%feature("autodoc", " +Unwind the stack frames from the innermost expression evaluation. +This API is equivalent to 'thread return -x'. +") UnwindInnermostExpression; + +SBError +UnwindInnermostExpression(); + %feature("docstring", " //-- /// LLDB currently supports process centric debugging which means when any Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=274822&r1=274821&r2=274822&view=diff == --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Thu Jul 7 21:12:05 2016 @@ -1249,6 +1249,31 @@ SBThread::ReturnFromFrame (SBFrame &fram return sb_error; } +SBError +SBThread::UnwindInnermostExpression() +{ +SBError sb_error; + +Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + +std::unique_lock lock; +ExecutionContext exe_ctx(m_opaque_sp.get(), lock); + +if (log) +log->Printf ("SBThread(%p)::UnwindExpressionEvaluation", + static_cast(exe_ctx.GetThreadPtr())); + +if (exe_ctx.HasThreadScope()) +{ +Thread *thread = exe_ctx.GetThreadPtr(); +sb_error.SetError (thread->UnwindInnermostExpression()); +if (sb_error.Success()) +thread->SetSelectedFrameByIndex(0, false); +} + +return sb_error; + +} bool SBThread::Suspend() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits