Commit Graph

6576 Commits

Author SHA1 Message Date
Tamas Berghammer bd05108e53 Fix execution of platform shell commands on android
* Add missing functionality to the process launcher
* Fixup PATH environment variable to workaround an OS bug
* Add default shell path to the host info structure

Differential revision: http://reviews.llvm.org/D8009

llvm-svn: 231065
2015-03-03 12:14:45 +00:00
Greg Clayton 786ad18049 Fix a crasher where we might have a N_UNDF symbol with no name and this could cause ObjectFileMachO::ParseSymtab() to crash.
<rdar://problem/19989491>

llvm-svn: 231048
2015-03-03 01:40:46 +00:00
Robert Flack ab3269d275 Reduce the number of components initialized by lldb-server to reduce static binary size.
Separate out the necessary component initialization for lldb-server such that the linker can greatly reduce the binary size. With this patch the size of lldb-server on my 64 bit linux release build drops from 46MB to 26MB.

Differential Revision: http://reviews.llvm.org/D7880

llvm-svn: 230963
2015-03-02 15:14:50 +00:00
Pavel Labath 6100f61bce Fix build breakage on win7-msvc caused by r230955
llvm-svn: 230958
2015-03-02 13:39:39 +00:00
Pavel Labath 00b7f95b12 Fix handling of backslashes in Args parsing
Summary:
Presently Args::SetCommandString allows quotes to be escaped with backslash. However, the
backslash itself is not removed from the argument, nor there is a way to escape the backslash
itself. This leads to surprising results:

"a b" c"   -> 'a b', 'c'  # Here we actually have an unterminated quote, but that is ignored
"a b\" c"  -> 'a b\" c'   # We try to escape the quote. That works but the backslash is not removed.
"a b\\" c" -> 'a b\\" c'  # Escaping the backslash has no effect.

This change changes quote handling to be more shell-like:
- single quotes and backquotes are literal and there is no way to escape the closing quote or
  anything else inside;
- inside double quotes you can use backslash to escape the closing quote and another backslash
- outside any quotes, you can use backslash to escape quotes, spaces and itself.

This makes the parsing more consistent with what the user is familiar and increases the
probability that pasting the command line from shell to the "process launch" command "just work".

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7855

llvm-svn: 230955
2015-03-02 12:46:22 +00:00
Tamas Berghammer 6806fded8c Make it possible to stop the operation thread in NativeProcessLinux
Previously the operation thread is stopped with a cancel event but
pthread_cancel is not supported on android. This CL creates a custom
operation which asks the operation thread to exit without any pthread
call.

Differential revision: http://reviews.llvm.org/D7937

llvm-svn: 230945
2015-03-02 11:04:03 +00:00
Vince Harron bc477ddee0 Linux - debugging of local processes via lldb-gdbserver
Instead of lldb calling the ptrace APIs directly, it launches an llgs
instance and communicates with it via the remote debug protocol.

This has two advantages.

There is more code shared between the remote debugging code path
and the local debugging code path. If a feature works in remote, it
probably works locally and vice-versa.

It makes us more architecturally similar to OSX (which also does
local debugging via a connection to debugserver).

This path is called LLGS local. We think that this configuration is
now at parity with (or better than) local linux debugging.

It is currently invoked if you have an environment variable defined
"PLATFORM_LINUX_FORCE_LLGS_LOCAL"

We would like to switch to LLGS local as the default path and only
use the non-LLGS path if someone has an environment variable defined
"PLATFORM_LINUX_DISABLE_LLGS_LOCAL"

Later, if all goes well, we would like to remove non-LLGS local
debugging support to simplify the codebase and avoid confusion.

llvm-svn: 230919
2015-03-01 23:21:29 +00:00
Chaoren Lin 451dd50673 Advertise 32 bit support for PlatformRemoteGDBServer on 64 bit systems.
Reviewers: vharron, clayborg, zturner

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7970

llvm-svn: 230906
2015-03-01 20:48:18 +00:00
Chaoren Lin e56f6dceea Fix attaching to 32 bit inferior with 64 bit llgs.
Summary: Executable module should use inferior architecture instead of host architecture.

Reviewers: ovyalov, vharron, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7977

llvm-svn: 230887
2015-03-01 04:31:16 +00:00
Chaoren Lin c934659736 Casting pid to ::pid_t when invoking syscall.
Summary:
syscalls involving pid/tid on 32 bit binaries are failing with
"Invalid argument" because the uint64_t arguments are too wide.

Reviewers: clayborg, ovyalov, sivachandra

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7963

llvm-svn: 230817
2015-02-28 00:20:16 +00:00
Ilia K 686b1fe65a Fix FileSpec::GetPath to return null-terminated strings
Summary:
Before this fix the FileSpec::GetPath() returned string which might be without '\0' at the end.
It could have happened if the size of buffer for path was less than actual path.

Test case:
```
FileSpec test("/path/to/file", false);
char buf[]="!!!!!!";
test.GetPath(buf, 3);
```

Before fix:
```
   233          FileSpec test("/path/to/file", false);
   234          char buf[]="!!!!!!";
   235          test.GetPath(buf, 3);
   236
-> 237          if (core_file)
   238          {
   239              if (!core_file.Exists())
   240              {
(lldb) print buf
(char [7]) $0 = "/pa!!!"
```

After fix:
```
   233          FileSpec test("/path/to/file", false);
   234          char buf[]="!!!!!!";
   235          test.GetPath(buf, 3);
   236
-> 237          if (core_file)
   238          {
   239              if (!core_file.Exists())
   240              {
(lldb) print buf
(char [7]) $0 = "/p"
```

Reviewers: zturner, abidh, clayborg

Reviewed By: abidh, clayborg

Subscribers: tberghammer, vharron, lldb-commits, clayborg, zturner, abidh

Differential Revision: http://reviews.llvm.org/D7553

llvm-svn: 230787
2015-02-27 19:43:08 +00:00
Greg Clayton f9da928993 Fixed an infinite recursion bug that could happen when using python operating system plug-ins where we would ask the operating system plug-in to update its threads and this would cause the plugin to run an expression which would eventually run IRForTarget::CreateResultVariable() which would try to get the selected thread and cause re-entrant bug.
<rdar://problem/19924734>

llvm-svn: 230711
2015-02-27 00:12:22 +00:00
Bruce Mitchener 11d86362ae Remove duplicated code for synthetic array members.
Summary:
The code for GetSyntheticArrayMemberFromPointer and
GetSyntheticArrayMemberFromArray was identical, so just collapse the
the methods into one.

Reviewers: granata.enrico, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7911

llvm-svn: 230708
2015-02-26 23:55:39 +00:00
Chaoren Lin b6cd5fe918 Fix Bug 20400
Summary:
http://llvm.org/bugs/show_bug.cgi?id=20400

The default triple of i686-pc-linux-gnu for 32 bit linux targets is compatible
but not necessarily identical to the inferior binaries.

Applying Azat Khuzhin's solution of using ArchSpec::IsCompatibleMatch() instead
of ArchSpec::IsExactMatch() when comparing ObjectFile and Modules architecture.

Reviewers: vharron

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7897

llvm-svn: 230694
2015-02-26 22:15:16 +00:00
Oleksiy Vyalov b071bee295 Use getProcessTriple inside HostInfoBase::ComputeHostArchitectureSupport instead of getDefaultTargetTriple.
http://reviews.llvm.org/D7893

llvm-svn: 230674
2015-02-26 20:02:13 +00:00
Chaoren Lin f591f69fc3 Can't set watchpoints on launching threads on Linux LLGS.
Summary:
They'll be set anyway when the thread starts running, so the launching threads
should just ignore the set request.

Reviewers: ovyalov

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7914

llvm-svn: 230671
2015-02-26 19:48:15 +00:00
Siva Chandra 9aaab55800 Fix a typo Debugger::ExecuteIOHanders to Debugger::ExecuteIOHandlers.
Test Plan: Build LLDB.

Reviewers: zturner, vharron, clayborg

Reviewed By: vharron, clayborg

Subscribers: jingham, lldb-commits

Differential Revision: http://reviews.llvm.org/D7894

llvm-svn: 230663
2015-02-26 19:26:36 +00:00
Enrico Granata b523deaa38 Fix a bug where LLDB could be convinced to attempt to extract a bitfield of size 0, and consequently crash
llvm-svn: 230661
2015-02-26 19:00:23 +00:00
Robert Flack e08dc42a73 Test commit - fix typo.
llvm-svn: 230629
2015-02-26 13:03:57 +00:00
Tamas Berghammer 2d52afd71c Increase default packet timeout for android to 20s
Differential revision: http://reviews.llvm.org/D7853

llvm-svn: 230626
2015-02-26 11:37:21 +00:00
Oleksiy Vyalov fb9015ddaa Return a current executable's directory from HostInfoAndroid::ComputeSupportExeDirectory.
http://reviews.llvm.org/D7876

llvm-svn: 230604
2015-02-26 02:50:14 +00:00
Enrico Granata 99b0a9cdd7 If we are trying to load the scripting resource for a module whose name happens to be a Python keyword, then prefix the filename with an _ (e.g. a module named def will load _def.py)
Fixes rdar://13893506

llvm-svn: 230602
2015-02-26 01:37:26 +00:00
Greg Clayton bc63aaccf7 Optimize finding the Complete Definition of an ObjC class for debug with .o files with lots of .o files.
When we have a debug map we have an executable with a bunch of STAB symbols and each source file has a N_SO symbol which scopes a bunch of symbols inside of it. We can use this to our advantage here when looking for the complete definition of an objective C class by looking for a symbol whose name matches the class name and whose type is eSymbolTypeObjCClass. If we find one, that symbol will be contained within a N_SO symbol. This symbol gets turned into a symbol whose type is eSymbolTypeSourceFile and that symbol will contain the eSymbolTypeObjCClass which helps us to locate the correct .o file and allows us to only look in that file.

To further accelerate things, if we are looking for the implementation, we can avoid looking at all .o files if we don't find a matching symbol because we have a debug map, which means the objective C symbol for the class can't have been stripped, so we can safely not search all remaining .o files. This will save us lots of time when trying to look for "NSObject" and any other AppKit and Foundation classes that we never have implementation definitions for.

<rdar://problem/19234225>

llvm-svn: 230562
2015-02-25 22:41:34 +00:00
Oleksiy Vyalov 6801be3354 Add qModuleInfo request in order to get module information (uuid, triple,..) by module path from remote platform.
http://reviews.llvm.org/D7709

llvm-svn: 230556
2015-02-25 22:15:44 +00:00
Zachary Turner 49be160531 Revert "Fix warnings found with clang-cl."
SWIG doesn't like enum : unsigned.  Revert this until I can
fix this in a way that swig likes.

llvm-svn: 230531
2015-02-25 19:52:41 +00:00
Zachary Turner 00998f0beb Solve hang on Windows when lldb fails to launch the process.
The DebuggerThread was detecting the launch error, but it was
ignored by ProcessWindows::DoLaunch, causing LLDB to wait forever
in the debugger loop.

This fixes the test case that explicitly attempts to launch a
process from a non-existant path.

Patch by Adrian McCarthy
Differential Revision: http://reviews.llvm.org/D7874

llvm-svn: 230523
2015-02-25 18:56:47 +00:00
Zachary Turner 171d943ac5 Fix warnings found with clang-cl.
Earlier this week I was able to get clang-cl on Windows to be
able to self host.  This opened the door to being able to
get a whole new slew of warnings for the Windows build.

This patch fixes all of the warnings, many of which were real
bugs.

llvm-svn: 230522
2015-02-25 18:42:47 +00:00
Greg Clayton 1e28adfe75 MacOSX symbol table change to combine the N_GSYM debug map entry with the "_OBJC_CLASS_$_", "_OBJC_METACLASS_$_", and "_OBJC_IVAR_$_" non debug symbols. This allows the symbol that represents the object file to contain the eSymbolTypeObjCClass and eSymbolTypeObjCMetaClass and will help us to be able to efficiently lookup the real definition of an objective C class without loading all .o files linearly to find the .o file that contains the true definition.
llvm-svn: 230509
2015-02-25 17:25:02 +00:00
Greg Clayton 2d9ce1926c Fix the dumping of symbol tables to be correctly alligned for all entries when using "image dump symtab".
llvm-svn: 230508
2015-02-25 17:22:05 +00:00
Hafiz Abid Qadeer ed69e30d68 Add missing "return" statements.
ExecutionContext::GetAddressByteSize() was calling GettAddressByteSize () on Target and Process class but was ignoring the return type. I have added the missing return.
No regression in the test suite. Committed as obvious.

llvm-svn: 230502
2015-02-25 16:01:12 +00:00
Tamas Berghammer 14f4476a88 Truncate target file for stdout and stderr
Add O_TRUNC when opening file for redirecting stdout and stderr of the
process. It is neccessary because if the file exists then on some
platform the original content is kept while it isn't overwritten by the
new data causing pollution of the saved stdout and stderr.

llvm-svn: 230492
2015-02-25 13:21:45 +00:00
Pavel Labath 7257d28025 Skip symlinks to the original file when searching for debug info
Summary:
Symbols::LocateExecutableSymbolFile tries to locate the file in containing the debug info in a
splitdebug configuration. It tries to skip over the original file in its search path, but it was
easily fooled by symlinks. This changes the function to use llvm::sys::fs::equivalent, which can
correctly compare symlinks.

As a side effect, I had to fix one test because the address for the "abort" function resolves on
my system to "__GI_abort" now. With the debug info, the libc on my system contains two symbols
associated with the address of the abort function, and lldb prefers __GI_abort, possibly because
the debug info is associated with it. It would be nice at some point to have it prefer the public
symbol name.

Reviewers: emaste, zturner

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7836

llvm-svn: 230476
2015-02-25 10:44:35 +00:00
Jason Molenda 671a29d30d When FileSpec::Resolve is given a bare file like "ls",
and llvm::sys::fs::make_absolute prepends the current
working directory to that path, leave the original
bare file name unchanged if $cwd/ls doesn't exist.

http://reviews.llvm.org/D7477
<rdar://problem/18775190>

llvm-svn: 230451
2015-02-25 02:35:25 +00:00
Oleksiy Vyalov 946e39a8d1 Fix logging in GDBRemoteCommunicationServerPlatform.
llvm-svn: 230418
2015-02-25 01:11:38 +00:00
Greg Clayton 7d1069d09e If you try to auto-complete "target symbols<TAB>" you get "target symbolsadd" instead of "target symbols ".
Fix this by returning the fact that the "symbols" word is complete if there is nothing else to complete after the "symbols" word.

<rdar://problem/19164599>

llvm-svn: 230408
2015-02-25 00:32:43 +00:00
Oleksiy Vyalov c282ebd724 Fix qLaunchGDBServer packet parsing in GDBRemoteCommunicationServerPlatform.
llvm-svn: 230390
2015-02-24 22:23:39 +00:00
Zachary Turner 030b8cb413 Resubmit "[CMake] Change lldbAPI to be a CMake OBJECT library."
This resubmits r230380.  The primary cause of the failure was
actually just a warning, which we can disable at the CMake level
in a followup patch on the LLVM side.  The other thing which was
actually an error on the bot should be able to be fixed with
a clean.

llvm-svn: 230389
2015-02-24 22:17:57 +00:00
Zachary Turner 0980447a5f Revert "[CMake] Change lldbAPI to be a CMake OBJECT library."
This reverts commit r230380.  It causes CMake to fail on certain
machines with an error about needing to use string(STRIP_GENEX).

llvm-svn: 230382
2015-02-24 21:28:01 +00:00
Zachary Turner f4f8740eb0 [CMake] Change lldbAPI to be a CMake OBJECT library.
An OBJECT library is a special type of CMake library that produces
no archive, has no link interface, and no link inputs.  It is like
a regular archive, just without the physical output.  To link
against an OBJECT library, you reference it in the *source* file
list of a library using the special syntax $<TARGET_OBJECTS:lldbAPI>.
This will cause every object file to be passed to the linker
independently, as opposed to a single archive being passed to the
linker.

This is *extremely* important on Windows.  lldbAPI exports all of the
SB classes using __declspec(dllexport).  Unfortunately for technical
reasons it is not possible (well, extremely difficult) to get the
linker to propagate a __declspec(dllexport) attribute from a symbol
in an object file in an archive to a DLL that links against that
archive.  The solution to this is for the DLL to link the object files
directly.  So lldbAPI must be an OBJECT library.

This fixes an issue that has been present since the duplicated
lldbAPI file lists were removed, which would cause linker failures.

As a side effect, this also makes LLDB_DISABLE_PYTHON=1 work again
on Windows, which was previously totally broken.

llvm-svn: 230380
2015-02-24 20:58:39 +00:00
Tamas Berghammer 912800c400 Create ScopedTimeout class for GDBRemoteCommunication
This new class makes it easier to change the timeout of a
GDBRemoteCommunication instance for a short time and then restore it to
its original value.

Differential revision: http://reviews.llvm.org/D7826

llvm-svn: 230319
2015-02-24 10:23:39 +00:00
Vince Harron f7839220ee Fix typo that breaks FileSystem::IsLocal
llvm-svn: 230312
2015-02-24 05:24:12 +00:00
Vince Harron 294aeb9a40 Compile fix for FileSystem::IsLocal on Linux
llvm-svn: 230311
2015-02-24 05:14:49 +00:00
Enrico Granata 4ae3dda605 Update LLDB to read a newer format of Objective-C class information from the dyld shared cache
Also, since most of the time the lack of such information is a serious problem that hinders productive debugging, emit an actual user visible warning when this occurs (once per process)

Fixes rdar://19898507

llvm-svn: 230299
2015-02-24 02:11:06 +00:00
Greg Clayton 736888c84b Avoid crashing by not mmap'ing files on network mounted file systems.
This is implemented by making a new FileSystem function:

bool
FileSystem::IsLocal(const FileSpec &spec)

Then using this in a new function:

DataBufferSP
FileSpec::MemoryMapFileContentsIfLocal(off_t file_offset, size_t file_size) const;

This function only mmaps data if the file is a local file since that means we can reliably page in data. We were experiencing crashes where people would use debug info files on network mounted file systems and that mount would go away and cause the next access to a page that wasn't paged in to crash LLDB. 

We now avoid this by just copying the data into a heap buffer and keeping a permanent copy to avoid the crash. Updated all previous users of FileSpec::MemoryMapFileContentsIfLocal() in ObjectFile subclasses over to use the new FileSpec::MemoryMapFileContentsIfLocal() function.

<rdar://problem/19470249>

llvm-svn: 230283
2015-02-23 23:47:09 +00:00
Zachary Turner d487bb12d9 [CMake] On Windows, require manual specification of python libs.
Embedding python with MSVC is very finicky, for reasons having
to do with the operating system's CRT, the implementation of
python itself on Windows, and even bugs in CMake.

One side effect of this is that we cannot rely on FindPythonLibs
and FindPythonInterp CMake functions to locate the correct
version of Python.  We must instead manually specify the location
of PYTHON_LIBRARY and PYTHON_INCLUDE_DIR.

As a side effect, this fixes building LLDB in release mode by
specifying -DCMAKE_BUILD_TYPE=Release, which was previously
broken.

llvm-svn: 230262
2015-02-23 21:20:59 +00:00
Ed Maste 56c7a19d41 Remove EOL whitespace from PlatformLinux
This reduces the noise when diffing PlatformFreeBSD and PlatformLinux.

llvm-svn: 230251
2015-02-23 20:18:37 +00:00
Ed Maste ff1b5c4244 Add null RegisterContext assertions
This makes these failures slightly more obvious, avoiding the need to
run LLDB under a debugger or rely on a LLDB core.  I encountered these
while bringing up a new OS/arch combination.

llvm-svn: 230236
2015-02-23 18:12:20 +00:00
Ed Maste 3a8ab6ee2a Exit early from DumpELFProgramHeaders if parse fails
This matches the way DumpELFSectionHeaders is implemented and is
recommended by the LLVM coding conventions.

llvm-svn: 230228
2015-02-23 15:33:11 +00:00
Ed Maste aec140380f elf-core: correct "no sections" to "no segments."
The error reported here is that there are no phdr entries, so it's
referring to segments, not sections.

llvm-svn: 230227
2015-02-23 15:28:42 +00:00
Tamas Berghammer 0f86b74304 Fix the communication in qPlatform_[mkdir,chmod]
With the previous implementation the protocol used by the client and the
server for the response was different and worked only by an accident.
With this change the communication is fixed and the return code from
mkdir and chmod correctly captured by lldb. The change also add
documentation for the qPlatform__[mkdir,chmod] packages.

Differential revision: http://reviews.llvm.org/D7786

llvm-svn: 230213
2015-02-23 11:03:08 +00:00