Commit Graph

10371 Commits

Author SHA1 Message Date
Pavel Labath 97a9ac1982 Avoid leaking log file descriptors into the inferior process.
Summary:
This commit adds a new open flag File::eOpenOptionCloseOnExec (i.e., O_CLOEXEC), and adds it to
the list of flags when opening log files (#ifndef windows). A regression test is included.

Reviewers: vharron, clayborg

Subscribers: lldb-commits

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

llvm-svn: 228310
2015-02-05 16:44:42 +00:00
Oleksiy Vyalov 4536c458e1 Fix warning about the use of mktemp and make platform agnostic by adding and using PipeBase::CreateWithUniqueName - on behalf of flackr.
http://reviews.llvm.org/D7348

llvm-svn: 228307
2015-02-05 16:29:12 +00:00
Ed Maste 72b3b62fac In fd leak test report all open fds, not only first failure
llvm-svn: 228306
2015-02-05 16:11:33 +00:00
Ed Maste 7f0230fad9 Avoid leakage of file descriptors in LLDB (apply r228130 to FreeBSD)
llvm-svn: 228305
2015-02-05 16:09:03 +00:00
Hafiz Abid Qadeer ec13f825a6 Fix "-data-list-register-values" MI commands.
If register numbers are not provided then this commands is supposed
to return all the register values. But it was returning nothing in
that case.

More details about this command at
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Data-Manipulation.html#GDB_002fMI-Data-Manipulation

llvm-svn: 228304
2015-02-05 15:55:43 +00:00
Hafiz Abid Qadeer 6a814ad142 Fix a typo in list-register-names command.
It was giving error when process was valid.

llvm-svn: 228299
2015-02-05 14:57:07 +00:00
Hafiz Abid Qadeer 98219ede4d Add missing options in -var-list-children command.
The options are checked in the following order.
    print-values
    no-values
    all-values
    simple-values

See the following link for the details of these arguments.
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html

llvm-svn: 228296
2015-02-05 14:06:30 +00:00
Hafiz Abid Qadeer cb8c3d789e Add and update lldb-mi tests.
This patch includes following changes:

Fix comments and code style
Add new tests for many commands
Improve existing tests
Merge MiProgramArgsTestCase and MiExecTestCase
Improve runCmd of MiTestCaseBase: add exactly option
Improve test example (make it more complicated)

Patch from ki.stfu. I xfailed some tests on Linux and also
added an empty command after -gdb-exit as it blocks without
it.

Patch was reviewed in http://reviews.llvm.org/D7410.

llvm-svn: 228286
2015-02-05 10:35:17 +00:00
Pavel Labath f81ed47a07 Clean up dependency .d.$$$$ files for tests
Summary:
Mac-only tests were leaving .d.$$$$ dependency files left in the test tree. This happened
because:
1) "make clean" was invoked although no tests in the folder were run
2) The Makefile had main.d as a dependency, which meant it tried to compile the source file (to extract
dependencies).
3) The compile failed (does not compile on linux) and left behind a main.d.$$$$ temporary file.
4) "make clean" tried to clean up these temporary files, but the expansion $(wildcard *.d.[0-9]*)
was performed before the temporary file was created, so this file was not caught.

I fix this by giving all the temporary files deterministic names, which makes it easier to clean
them up afterwards. I also make the rules for generating the dependency files more robust and
less likely to leak files in the first place.

Reviewers: vharron, zturner

Subscribers: lldb-commits

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

llvm-svn: 228285
2015-02-05 09:52:42 +00:00
Justin Hibbits f9ec0d1ea5 Implement initial Altivec support
Summary:
This adds the register plumbing, as well as register reading in FreeBSD core
dumps.  Further work on the POSIX/FreeBSD ProcessMonitor is required in order to
support ptrace access to these registers.

Reviewers: tfiala, emaste

Reviewed By: emaste

Subscribers: emaste, lldb-commits

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

llvm-svn: 228278
2015-02-05 07:12:01 +00:00
Justin Hibbits b07ee8ded9 Add PowerPC FPR access to the process monitor
Summary: This adds reading and writing to the POSIX PowerPC ProcessMonitor.

Reviewers: emaste

Reviewed By: emaste

Subscribers: emaste, lldb-commits

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

llvm-svn: 228277
2015-02-05 07:10:11 +00:00
Greg Clayton 68c00bd205 Keep the user data for compile units up to date since we often create lldb_private::CompileUnit objects without creating the DWARFCompileUnit objects when we do DWARF in .o files.
Now we make sure to update our DWARFCompileUnit -> lldb_private::CompileUnit user data when it isn't set to ensure quick transitions between the two.

<rdar://problem/18371367>

llvm-svn: 228264
2015-02-05 02:10:29 +00:00
Greg Clayton 08928f308b Don't wait for the dynamic loader to set a module as a dynamic link editor, figure it out through the ObjectFile.
Background: dyld binaries often have extra symbols in their symbol table like "malloc" and "free" for the early bringup of dyld and we often don't want to set breakpoints in dynamic linker binaries. We also don't want to call the "malloc" or "free" function in dyld when a user writes an expression like "(void *)malloc(123)" so we need to avoid doing name lookups in dyld. We mark Modules as being dynamic link editors and this helps do correct lookups for breakpoints by name and function lookups.

<rdar://problem/19716267>

llvm-svn: 228261
2015-02-05 02:01:34 +00:00
Oleksiy Vyalov 1ef7b2c897 Extend SBPlatform with capability to launch/terminate a process remotely. Integrate this change into test framework in order to spawn processes on a remote target.
http://reviews.llvm.org/D7263

llvm-svn: 228230
2015-02-04 23:19:15 +00:00
Reid Kleckner d9041a3d99 Unbreak the cmake build by adding some new files
llvm-svn: 228224
2015-02-04 22:46:17 +00:00
Vince Harron cd540c095a fixed copy/paste error in comment
-This line, and those below, will be ignored--

M    include/lldb/Target/FileAction.h

llvm-svn: 228218
2015-02-04 22:31:44 +00:00
Vince Harron fa03bac794 Get test/types tests passing on remote targets
redirecting output to a path that will work well on host or target.
copying file from output location to location on local host that
test will read from

llvm-svn: 228217
2015-02-04 22:25:34 +00:00
Greg Clayton 281b65bcde Update documenation for the changed in from ${var.script:<pythonfunction>} to the new ${script.var:<pythonfunction>}.
llvm-svn: 228216
2015-02-04 22:24:47 +00:00
Greg Clayton 79ede57194 Remove changes I accidentally checked in with my previous commit.
llvm-svn: 228210
2015-02-04 22:02:49 +00:00
Greg Clayton 554f68d385 Get rid of Debugger::FormatPrompt() and replace it with the new FormatEntity class.
Why? Debugger::FormatPrompt() would run through the format prompt every time and parse it and emit it piece by piece. It also did formatting differently depending on which key/value pair it was parsing. 

The new code improves on this with the following features:
1 - Allow format strings to be parsed into a FormatEntity::Entry which can contain multiple child FormatEntity::Entry objects. This FormatEntity::Entry is a parsed version of what was previously always done in Debugger::FormatPrompt() so it is more efficient to emit formatted strings using the new parsed FormatEntity::Entry.
2 - Allows errors in format strings to be shown immediately when setting the settings (frame-format, thread-format, disassembly-format
3 - Allows auto completion by implementing a new OptionValueFormatEntity and switching frame-format, thread-format, and disassembly-format settings over to using it.
4 - The FormatEntity::Entry for each of the frame-format, thread-format, disassembly-format settings only replaces the old one if the format parses correctly
5 - Combines all consecutive string values together for efficient output. This means all "${ansi.*}" keys and all desensitized characters like "\n" "\t" "\0721" "\x23" will get combined with their previous strings
6 - ${*.script:} (like "${var.script:mymodule.my_var_function}") have all been switched over to use ${script.*:} "${script.var:mymodule.my_var_function}") to make the format easier to parse as I don't believe anyone was using these format string power user features.
7 - All key values pairs are defined in simple C arrays of entries so it is much easier to add new entries.

These changes pave the way for subsequent modifications where we can modify formats to do more (like control the width of value strings can do more and add more functionality more easily like string formatting to control the width, printf formats and more).

llvm-svn: 228207
2015-02-04 22:00:53 +00:00
Oleksiy Vyalov f31a77f6cd Fix synchronization issue in Broadcaster::HijackBroadcaster.
llvm-svn: 228179
2015-02-04 19:42:32 +00:00
Vince Harron c46945149c Fix TestTargetAPI.py when run against remote host.
In tests where stdio is redirected to a file, the file must be copied
back from the remote host for analysis by the test.

llvm-svn: 228175
2015-02-04 19:25:21 +00:00
Zachary Turner 362a813736 Fix broken windows build due to use of O_CLOEXEC.
llvm-svn: 228171
2015-02-04 19:11:48 +00:00
Hafiz Abid Qadeer 94e222f943 Fix a typo.
The member m_nTimes is used in rest of lldb-mi to represent hit count.
In one place, it was assigned a wrong value (number of locations). This
resulted in lldb-mi showing a hit count of variable 1 when it was created.

Committed as obvious.

llvm-svn: 228150
2015-02-04 16:04:16 +00:00
Pavel Labath 9180f96cfe Have llgs tests output their traces into session dir
Summary: This reduces the bloat in the source tree and makes the tests more consistent.

Reviewers: vharron, zturner

Subscribers: lldb-commits

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

llvm-svn: 228134
2015-02-04 10:48:29 +00:00
Pavel Labath 493c3a127f Avoid leakage of file descriptors in LLDB and LLGS
Summary:
Both LLDB and LLGS are leaking file descriptors into the debugged process. This plugs the leak by
closing the unneeded descriptors. In one case I use O_CLOEXEC, which I hope is supported on
relevant platforms. I also added a regression test and plugged a fd leak in dosep.py.

Reviewers: vharron, clayborg

Subscribers: lldb-commits

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

llvm-svn: 228130
2015-02-04 10:36:57 +00:00
Hafiz Abid Qadeer d1f606ff0f Fix a race condition in lldb-mi.
lldb-mi has 3 threads.
1. One that waits for user intput.
2. Another waits for 1st thread to get input command.
3. Waits for events from lldb.

2 & 3 needs to be synchronized so that they don't end up
doing things at same time. For example, while "break insert" is
processing, we can get a breakpoint event. Depending on where we
are in "break-insert", it can have different behavior. In some
cases, it can cause breakpoint to be deleted too. I have added a 
mutex so that command processing and event processing are done 
exclusively and they are not running at the same time.

In longer term, I think thread 2 & 3 should be merged to be only 
one thread which can wait on command or events.

Reviewed in http://reviews.llvm.org/D7371.

llvm-svn: 228128
2015-02-04 09:59:23 +00:00
Chaoren Lin bc78f1696c Test commit.
Removed trailing whitespace.

From: Vince Harron <vharron@google.com>
llvm-svn: 228115
2015-02-04 05:40:07 +00:00
Greg Clayton 8031d28823 Fix it so we always get major, minor and update from the version in ObjectFileMachO::GetMinimumOSVersion(...) and ObjectFileMachO::GetSDKVersion(...).
<rdar://problem/19697053>

llvm-svn: 228092
2015-02-04 00:40:25 +00:00
Jason Molenda 250b1b8902 Small fix for the "memory write -i filename" command -- if the user fails to specify the
number of bytes to write into the inferior process, the "default byte size" will be 1.
In that case, we want to copy the entire file into memory.  The code was looking for
a default byte size of 0 to indicate that the user had not provided a specific # of
bytes to copy; adjust that to 1 to match the actual default value.
<rdar://problem/18074973>

llvm-svn: 228067
2015-02-03 23:39:47 +00:00
Stephane Sezer 765fcc0d5b Use basename of main executable in POSIX-DYLD on Android.
Summary:
The Android dynamic linker reports only the basename of each SO entry, so for
the above check to be successful, we need to compare it to the basename of the
main executable.

This also has a nasty side-effect when working with older version of
Android (verified on platform version 16), and debugging PIE
executables: the dynamic linker has a bug and reports the load address
of the main executable (which is a shared object, because PIE) to be 0.
We then try to update the list of loaded sections for all shared
objects, including the main executable, and set the load address to 0,
which breaks everything that relies on resolving addresses in the main
executable (breakpoints, stepping, etc). This commit also fixes that broken
behavior when debugging on older Androids. This bug doesn't happen on newer
Android versions (verified for Android L).

Test Plan: Run test suite on linux.

Reviewers: clayborg, tfiala, richard.mitton

Subscribers: lldb-commits

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

llvm-svn: 228057
2015-02-03 22:48:34 +00:00
Zachary Turner 02624e4154 Fix compilation failure on Windows.
llvm-svn: 227998
2015-02-03 18:26:00 +00:00
Hafiz Abid Qadeer 9a0d572750 Restore the signal handler for Windows as it is not presistent there.
On windows, signal handler is reset to default once a signal is received. 
This causes doing ctrl-c twice on console (or pressing suspend button twice
in eclipse ide which uses SIGINT to stop the debuggee) to crash lldb-mi on 
windows. Although there is very tiny window (after signal handler is called
and before we restore the handler) where default handler will be in place.
But this is hardly a problem in practice as IDEs generally disable their suspend
button once it has been presses.

llvm-svn: 227964
2015-02-03 11:20:00 +00:00
Pavel Labath 1702eb1840 Test commit. No changes.
llvm-svn: 227960
2015-02-03 10:38:21 +00:00
Hafiz Abid Qadeer 0d51c1563b Fix CLI commands in lldb-mi.
This patch fixes execution of CLI commands in MI mode. The CLI commands are 
executed using "-interpreter-exec" command. The bug was in the 
CMICmnLLDBDebugSessionInfo class which contained the following members: 
SBProcess, SBTarget, SBDebugger and SBListener, but CLI commands don't affect
them and they aren't updated. Therefore some members can contain incorrect 
(or obsolete) reference and it can cause an error. My patch removes these 
members and uses getters that provides the updated instance every time it is used.

Patch from Ilia K ki.stfu@gmail.com. Approved by Greg.

llvm-svn: 227958
2015-02-03 10:05:54 +00:00
Bruce Mitchener 991b5966a3 Change void* name_token to const void* to address warnings.
Reviewers: granata.enrico, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 227952
2015-02-03 08:01:34 +00:00
Bruce Mitchener fd3cd13af5 Cast to (const OptionPermissions*) to avoid warning.
Reviewers: clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 227951
2015-02-03 07:59:26 +00:00
Enrico Granata decf03b68f Add an expectall() API that allows you to pass a list of patterns and have pexpect match *ALL* of them instead of just picking one
llvm-svn: 227938
2015-02-03 03:11:59 +00:00
Enrico Granata 3ea3b39319 Make it easier to see what's going on by tracing the test case
llvm-svn: 227936
2015-02-03 02:46:36 +00:00
Greg Clayton ff48e4bea0 Fixed bugs in the multi-threaded access in HostInfoBase. Prior to this fix, static bool variables were used but this is not sufficient. We now use std::call_once in all places where the previous static bool code was used to try to implement thread safety.
This was causing code that opened multiple targets to try and get a path to debugserver from the GDB remote communication class, and it would get the LLDB path and some instances would return empty strings and it would cause debugserver to not be found.

<rdar://problem/18756927>

llvm-svn: 227935
2015-02-03 02:05:44 +00:00
Chaoren Lin 6a196ce691 Fix TestThreadStepOut on Linux with LLGS
Remove implicit stop action on $vCont package for threads where no
explicit action or default action specified based on the specification
(they have to stay in there original state).

llvm-svn: 227933
2015-02-03 01:51:56 +00:00
Chaoren Lin 2ce7627807 Fix compilation error and cleanup in ThreadStateCoordinatorTest
llvm-svn: 227932
2015-02-03 01:51:54 +00:00
Chaoren Lin 0be9ebbfbd Add missing switch cases to silence warnings.
llvm-svn: 227931
2015-02-03 01:51:50 +00:00
Chaoren Lin 18fe6404f9 Implement setting and clearing watchpoints.
llvm-svn: 227930
2015-02-03 01:51:47 +00:00
Chaoren Lin 2fe1d0abc2 Moving header files from source/Host/common to proper location.
llvm-svn: 227929
2015-02-03 01:51:38 +00:00
Chaoren Lin 37c768ca58 Make ThreadStateCoordinator to handle properly failed stop/resume operations.
llvm-svn: 227928
2015-02-03 01:51:30 +00:00
Chaoren Lin a1f0ba7d38 Mark TestProcessLaunch.test_set_working_dir_with_dwarf as expected to fail in LLGS mode due llvm.org/pr20265
llvm-svn: 227927
2015-02-03 01:51:28 +00:00
Chaoren Lin 28e57429fc Share crash information between LLGS and local POSIX debugging with
CrashReason class. Deliver crash information from LLGS to lldb via
description field of thread stop packet.

llvm-svn: 227926
2015-02-03 01:51:25 +00:00
Chaoren Lin 72b8f05878 Mark several tests as XFAIL with new expectedFailureLLGS decorator since they are failing in Darwin for the same reason.
llvm-svn: 227925
2015-02-03 01:51:18 +00:00
Chaoren Lin 86fd8e45f4 Modify ThreadStateCoodrinator in order to resume threads if stop wasn't requested.
llvm-svn: 227924
2015-02-03 01:51:15 +00:00