Summary:
There was a race condition regarding the output of the inferior process. The reading of the
output is performed on a separate thread, and there was no guarantee that the output will get
eventually consumed. Because of that, it was happening that calling Process::GetSTDOUT was not
returning anything even though the process was terminated and would definitely not produce any
further output. This was usually happening only under very heavy system load, but it can be
reproduced by placing an usleep in the stdio thread (Process::STDIOReadThreadBytesReceived).
This patch addresses this by adding synchronization capabilities to the Communication thread.
After calling Communication::SynchronizeWithReadThread one can be sure that all pending input has
been processed by the read thread. This function is then called after every public event which
stops the process to obtain the entire process output.
Test Plan: TestProcessIO.py should now succeed every time instead of flaking in and out.
Reviewers: clayborg, jingham
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D8246
llvm-svn: 232023
Summary:
This patch fixes SDK selection in the following case:
```
platform select remote-ios --sysroot "/Users/IliaK/Library/Developer/Xcode/iOS DeviceSupport/8.1.2 (12B440)" --build 12B440 --version 8.1.2
target create --arch arm64 "~/Project1.app"
```
Currently the lldb selects a first SDK version (in name order) in directory and then updates it after the device is connected. This approach ignores user's arguments and actually "platform select" command doesn't make sense.
After this patch, lldb takes a SDK which matches to user's arguments.
Reviewers: jasonmolenda, clayborg
Reviewed By: clayborg
Subscribers: lldb-commits, clayborg, jasonmolenda, aemerson
Differential Revision: http://reviews.llvm.org/D8249
llvm-svn: 232017
This was previously initialized by ProcessGDBRemote::Initialize but lldb-server does not contain ProcessGDBRemote anymore so this needs to be initialized directly.
Differential Revision: http://reviews.llvm.org/D8186
llvm-svn: 231966
In http://reviews.llvm.org/D7880 the initialization for LLGS was separated out so that LLGS could initialize only the components it needs to. This further reduces the set of components initialized for LLGS.
Differential Revision: http://reviews.llvm.org/D8112
llvm-svn: 231964
Summary:
ProcessGDBRemote::AsyncThread nuked its own thread handle upon exiting. This prevented the main
thread from joining it correctly in StopAsyncThread. I address this by moving the Reset() call to
StopAsyncThread, after the join.
Reviewers: clayborg, zturner
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D8218
llvm-svn: 231915
kernel debug session, instead of issuing a warning (which on one ever
sees), drop the user-specified kernel binary Module from the target and
try to discover the correct one dynamically.
<rdar://problem/19450329>
llvm-svn: 231885
After http://reviews.llvm.org/D8133 landed as r231550 process launch on remote platform stopped working.
This adds Debugger::InitializeForLLGS and tracks whether one or both of Initialize and InitializeForLLGS have been called, calling only the corresponding lldb_private::Terminate* methods as necessary. Since lldb_private::Terminate calls lldb_private::TerminateForLLGS, the latter method may be called twice if Initialize was called for both however the terminate methods ensure they are only called once after being initialized.
This still maintains the reduced binary size, though it does now technically link in lldb_private::Terminate on lldb-server even though this should never be called.
This should resolve the issue raised in http://reviews.llvm.org/D8133 where Debugger::Terminate assumed that there were 0 references to debugger and terminated early.
Differential Revision: http://reviews.llvm.org/D8183
llvm-svn: 231808
The issue can happen if you strip your main executable and then run an expression and it would fail to find the stripped symbol and it would then not be able to make the function call. The issue was fixed by doing our normal FindFunctions call.
<rdar://problem/20072750>
llvm-svn: 231667
Thic change have effect wehn the AVX registers aren't available with
reporting the count of user registers without them.
Differential revision: http://reviews.llvm.org/D8111
llvm-svn: 231638
Linux configure+make builds have ~175 tests failing that aren't
failing in cmake builds. The tests have error messages like
"'a.out' doesn't contain the architecture x86-64" ObjectFileELF
plugin wasn't loaded when this message was output.
I found ScriptInterpreterPython::InitializePrivate() is calling
Debugger::Terminate(), which terminates ObjectFileELF (and lots
of other stuff) setup earlier in the InitializeForLLGS.
So I moved python Init/Term from Init/TermForLLGS to Init/Term
llvm-svn: 231550
This means you can set an expression prefix file with:
(lldb) settings set target.expr-prefix /tmp/to/prefix.txt
And you can run an expression and modify your expression prefix file in another editor without having to type:
(lldb) settings set target.expr-prefix /tmp/to/prefix.txt
again...
<rdar://problem/12155942>
llvm-svn: 231535
This removes Host::Backtrace from the codebase, and changes all
call sites to use llvm::sys::PrintStackTrace(). This makes the
functionality available for all platforms, and even for platforms
which currently had a supported implementation of Host::Backtrace,
this patch should enable richer information in stack traces, such
as file and line number information, as well as giving it the
ability to unwind through inlined functions.
llvm-svn: 231511
- use a hardcoded formatter to match all vector types, and make it so that their element type is taken into account when doing default formatting
- special case a vector of char to display byte values instead of characters by default
Fixes the test failures Ilia was seeing
llvm-svn: 231504
Previously it was initialized by ProcessLinux but lldb-server don't
contain ProcessLinux anymore so it have to be initialized by
NativeProcessLinux also.
Differential revision: http://reviews.llvm.org/D8080
llvm-svn: 231482
Summary:
starting a debug session on linux with -o "process launch" lldb parameter was failing since
Target::Launch (in sychronous mode) is expecting to be able to receive public process events.
However, PlatformLinux did not set up event hijacking on process launch, which caused these
events to be processed elsewhere and left Target::Launch hanging. This patch enables event
interception in PlatformLinux (which was commented out).
Upon enabling event interception, I noticed an issue, which I traced back to the inconsistent
state of public run lock, which remained false even though public and private process states were
"stopped". I addressed this by making sure the run lock is "stopped" upon exit from
WaitForProcessToStop (which already had similar provisions for other return paths).
Test Plan: This should fix the intermittent TestFormats failure we have been experiencing on Linux.
Reviewers: jingham, clayborg, vharron
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D8079
llvm-svn: 231460
Unlike GDB, we tackle the problem of representing vector types in different styles by having a synthetic child provider that recognizes the format you're trying to apply to the variable, and coming up with the right type and number of child values to match that format
This makes for a more compact representation and less visual noise
Fixes rdar://5429347
llvm-svn: 231449
This is a temporary fix until a more comprehensive fix can be made for finding functions that we call in expressions.
We find "NSLog" in ClangExpressionDeclMap::FindExternalVisibleDecls() in after a call to target->GetImages().FindFunctions(...). Note that there are two symbols: NSLog from CFNetwork which is not external, and NSLog from Foundation which _is_ external. We do something with the external symbol with:
if (extern_symbol)
{
AddOneFunction (context, NULL, extern_symbol, current_id);
context.m_found.function = true;
}
Then later we try to lookup the _Z5NSLogP8NSStringz name and we don't find it so we call ClangExpressionDeclMap::GetFunctionAddress() with "_Z5NSLogP8NSStringz" as the name and the sc_list_size is zero at the "if" statement at line 568 because we don't find the mangled name and we extract the basename "NSLog" and call:
FindCodeSymbolInContext(ConstString(basename), m_parser_vars->m_sym_ctx, sc_list);
sc_list_size = sc_list.GetSize();
and we get a list size of two again, and we proceed to search for the symbol again, this time ignoring the external vs non-external-ness of the symbols that we find. This fix ensures we prioritize the external symbol until we get a real fix from Sean Callanan when he gets back to make sure we don't do multiple lookups for the same symbol we already resolved.
<rdar://problem/19879282>
llvm-svn: 231420
operator in addition to the vendor-extension DW_OP_GNU_push_tls_address.
clang on PS4 and Darwin will be emitting the standard opcode
as of r231286 via http://reviews.llvm.org/D8018
Behavior of this standard opcode is the same as
DW_OP_GNU_push_tls_address.
<rdar://problem/20043195>
llvm-svn: 231342
We would like it if LLDB never crashed, especially if we never caused LLDB to crash
On the other hand, having assertions can sometimes be useful
lldbassert(x) is the best of both worlds:
- in debug builds, it turns into a regular assert, which is fine because we don't mind debug LLDB to crash on development machines
- in non-debug builds, it emits a message formatted just like assert(x) would, but then instead of crashing, it dumps a backtrace, suggests filing a bug, and keeps running
llvm-svn: 231310
Setting it from the Target architecture cause problems when the target
archiutecture is filled just by examining the executable because in that
case the OS isn't set.
Differential revision: http://reviews.llvm.org/D8035
llvm-svn: 231234
The deadlock occurred when the Attach or the Launch operation failed for
any reason.
Differential revision: http://reviews.llvm.org/D8030
llvm-svn: 231231
Summary:
Symbol table generation code was failing to take into account the debug symbols because
the object file was looking only into its own section list when doing the generation, even though
the debug symbols from another object file were correctly detected and loaded by the
SymbolVendor. This changes the code to use the unified section list, which fixes this problem.
Test Plan:
I do not intend do submit this yet since it causes (or more like, exposes) the issue
in D7884, but I wanted to put this out here, so that anyone who wants to take a look at it can do
so. (And I also wanted to know if this is the right approach to the problem :).
Reviewers: clayborg, zturner
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D7913
llvm-svn: 231229
Summary:
Symbols in ELF files can be versioned, but LLDB currently does not understand these. This problem
becomes apparent once one loads glibc with debug info. Here (in the .symtab section) the versions
are embedded in the name (name@VERSION), which causes issues when evaluating expressions
referencing memcpy for example (current glibc contains memcpy@@GLIBC_2.14 and
memcpy@GLIBC_2.2.5).
This problem was not evident without debug symbols as the .dynsym section
stores the bare names and the actual versions are present in a separate section (.gnu.version_d),
which LLDB ignores. This resulted in two definitions of memcpy in the symbol table.
This patch adds support for storing annotated names to the Symbol class. If
Symbol.m_contains_linker_annotations is true then this symbol is annotated. Unannotated name can
be obtained by calling StripLinkerAnnotations on the corresponding ObjectFile. ObjectFileELF
implements this to strip @VERSION suffixes when requested. Symtab uses this function to add the
bare name as well as the annotated name to the name lookup table.
To preserve the size of the Symbol class, I had to steal one bit from the m_type field.
Test Plan:
This fixes TestExprHelpExamples.py when run with a glibc with debug symbols. Writing
an environment agnostic test case would require building a custom shared library with symbol
versions and testing symbol resolution against that, which is somewhat challenging.
Reviewers: clayborg, jingham
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D8036
llvm-svn: 231228