Commit Graph

1145 Commits

Author SHA1 Message Date
Ilia K 0e919bca7f Refactor lldb-mi's prompt
Summary:
This patch fixes/cleans code around of (gdb) prompt:
# Add CMICmnStreamStdout::WritePrompt
# Clean up CMICmnStreamStdout::TextToStdout (don't lock
  the m_mutex twice because it will be locked in CMICmnStreamStdout::WritePriv)
# Remove unused CMICmnStreamStdin::m_bShowPrompt field
# Refactor CMICmnLLDBDebuggerHandleEvents to use CMICmnStreamStdout::WritePrompt
  instead of TextToStdout("(gdb)")
# Refactor CMIDriver to use CMICmnStreamStdout::WritePrompt instead of
  ```
    if (bOk && m_rStdin.GetEnablePrompt())
        bOk = m_rStdOut.WriteMIResponse(m_rStdin.GetPrompt());
  ```

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 237248
2015-05-13 12:18:20 +00:00
Vince Harron d7e6a4f2f0 Fixed a ton of gcc compile warnings
Removed some unused variables, added some consts, changed some casts
to const_cast. I don't think any of these changes are very
controversial.

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

llvm-svn: 237218
2015-05-13 00:25:54 +00:00
Ilia K d84713bd86 Show error message from failed evaluation when doing -var-create
Summary:
When -var-create fails, we will now show the error message from the failed evaluation if it is available.

Patch from chuckr@microsoft.com

Test Plan: I fixed the MiVarTestCase.test_lldbmi_eval test to expect the new error string. All MI tests passing on OS X.

Reviewers: abidh, ChuckR

Subscribers: greggm, lldb-commits, paulmaybee

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

llvm-svn: 237094
2015-05-12 06:15:16 +00:00
Ilia K f44ab29e05 Escape strings in disassembly comments.
Summary: Patch from chuckr@microsoft.com

Reviewers: abidh, ChuckR

Subscribers: paulmaybee, lldb-commits

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

llvm-svn: 237092
2015-05-12 05:55:23 +00:00
Vince Harron 9753dd98b3 Add support for ./dotest.py --channel and --log-success
Summary:
New dotest options that allow arbitrary log channels and
categories to be enabled.  Also enables logging for locally run
debug servers.
    
Log messages are separated into separate files per test case.
(this makes it possible to log in dosep runs)
    
These new log files are stored side-by-side with trace files in the
session directory.
    
These files are deleted by default if the test run is successful.
    
If --log-success is specified, even successful logs are retained.
    
--log-success is useful for creating reference log files.
    
Test Plan:
add '--channel "lldb all" --channel "gdb-remote packets" --log-success'
to your dotest options

Tested on OSX and Linux
    
Differential Revision: http://reviews.llvm.org/D9594

llvm-svn: 236956
2015-05-10 15:22:09 +00:00
Ilia K fd0325b81e Fix =breakpoint-created event after creation of BP (MI)
For example:
was:
```
$ bin/lldb-mi ~/p/hello
[...]
-break-insert main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000e2d",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="14",times="0",original-location="main"}
(gdb)
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000e2d",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="14",times="0",original-location="main"}
```

now:
```
$ bin/lldb-mi ~/p/hello
[...]
-break-insert main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000e2d",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="14",times="0",original-location="main"}
(gdb)
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000e2d",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="14",times="0",original-location="main"}
```

llvm-svn: 236837
2015-05-08 12:18:11 +00:00
Ilia K 3e6f515531 Remove duplicated code in CMICmdCmdBreakInsert::Acknowledge (MI)
llvm-svn: 236834
2015-05-08 12:11:13 +00:00
Ilia K e077ef7a69 Fix -break-insert without -f to cause an error if BP not resolved (MI)
For example:
was:
```
$ bin/lldb-mi ~/p/hello
[...]
-break-insert main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000e2d",func="main",file="hello.cpp",fullname="/Users/Ilia
hello.cpp",line="14",pending=["main"],times="0",original-location="main"}
```

now:
```
$ bin/lldb-mi ~/p/hello
[...]
-break-insert main
^error,msg="Command 'break-insert'. Breakpoint location 'main' not found"
```

llvm-svn: 236832
2015-05-08 12:09:56 +00:00
Ilia K 913b2d4fd3 Fix BP address for local symbols if target not launched (MI)
For example:
was:
```
$ bin/lldb-mi ~/p/hello
[...]
-break-insert -f main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffffffffffff",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="14",pending=["main"],times="0",original-location="main"}
```

now:
```
$ bin/lldb-mi ~/p/hello
[...]
-break-insert -f main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000e2d",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="14",pending=["main"],times="0",original-location="main"}
```

llvm-svn: 236830
2015-05-08 12:06:17 +00:00
Ilia K b9bfd969e3 Add support for Unicode strings in CMICmnLLDBUtilSBValue::GetValue (MI)
This patch includes the following changes:
# Add CMIUtilString::ConvertToASCII to convert unicode to ASCII (MI)
# Rework CMICmnLLDBUtilSBValue::GetSimpleValue to print wide/unicode char (MI)
## Add CMICmnLLDBUtilSBValue::GetSimpleValueChar
## Extend CMICmnLLDBUtilSBValue::IsCharType to accept char16_t/char32_t
## Don't ignore the fail_value in SBValue::GetValueAsUnsigned
# Rework CMIUtilString::ConvertToASCII (MI)
## Don't use templates
## Change the function signature to convert signle characters (was std::basic_string)
## Rename CMIUtilString::ConvertToASCII to CMIUtilString::ConvertToPrintableASCII
# Add CMIUtilString::ConvertToPrintableASCII for char (MI)
## Refactor CMIUtilString::Escape
## Simplify CMICmnLLDBUtilSBValue::GetSimpleValueChar for char
# Add char16_t* and char32_t* support in CMICmnLLDBUtilSBValue::GetSimpleValue (MI)
## Add CMICmnLLDBUtilSBValue::GetSimpleValueCStringPointer
## Add CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory2
   (it's extended version of CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory)
# Improve error checking in CMICmnLLDBUtilSBValue::GetSimpleValueChar (MI)
# Refactor CMICmnLLDBUtilSBValue (MI)
## Remove CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory
   (use CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory2 instead)
## Rename CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory2 to
   CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory
## Move CMICmnLLDBUtilSBValue::GetValueCString to private methods
## Rename CMICmnLLDBUtilSBValue::GetValueCString to
   CMICmnLLDBUtilSBValue::GetSimpleValueCStringArray
## Remove CMICmnLLDBUtilSBValue::GetChildValueCString
# Improve MiGdbSetShowTestCase.test_lldbmi_gdb_set_show_print_char_array_as_string test to check char16_t/char32_t (MI)
# Fix CMICmnLLDBUtilSBValue::GetSimpleValueCStringArray for Unicode (MI)
## Fix handling of char16_t and char32_t
## Improve CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory to read
   variables of type char[]: add vnMaxLen argument
## Turn on few cases to check char16_t[] and char32_t[] output in
   MiGdbSetShowTestCase.test_lldbmi_gdb_set_show_print_char_array_as_string
# Remove unnecessary checks in CMICmnLLDBUtilSBValue (MI)

llvm-svn: 236827
2015-05-08 11:21:13 +00:00
Ilia K 24862eaca0 Fix -var-create for undefined variables (MI)
llvm-svn: 236825
2015-05-08 10:58:45 +00:00
Ilia K a4cfe98a86 Print process's output line by line (MI)
For example:
was:
```
@"'\r\n` - it's \\ni=1\r\nj=2\r\nx=3\r\ny=4\r\nargc: /Users/IliaK/p/hello\r\nargc: (null)\r\n"
```

now:
```
@"'\r\n"
@"` - it's \\ni=1\r\n"
@"j=2\r\n"
@"x=3\r\n"
@"y=4\r\n"
@"argc: /Users/IliaK/p/hello\r\n"
@"argc: (null)\r\n"
```

llvm-svn: 236824
2015-05-08 10:52:50 +00:00
Ilia K 307b917696 Fix -var-list-children command (MI)
This patch incldues the following:
# Add from/to arguments in -var-list-children command (MI)
## Handle from and to args
## Don't print children=[] if numchild is 0
## A bit refactoring
## Add MiVarTestCase.test_lldbmi_var_list_children test
# Refactor -var-list-children (MI)
## Remove CMICmdCmdVarListChildren::VecMIValueResult_t
## Add CMICmdCmdVarListChildren::m_miValueList
## Remove CMICmdCmdVarListChildren::m_vecMiValueResult
   (use CMICmdCmdVarListChildren::m_miValueList instead)
## Print error message if value is invalid:
   ```
     ^error,msg="variable invalid"
   ```
## Refactor CMICmdCmdVarListChildren::Acknowledge and remove duplicated code
## Don't print children=[] if numchild is 0
## Add error checking
## Use CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e for print-values
## Add few more empty-range test cases in MiVarTestCase.test_lldbmi_var_list_children
#Improve MiVarTestCase.test_lldbmi_var_list_children test (MI)

llvm-svn: 236820
2015-05-08 10:10:14 +00:00
Greg Clayton 3d415cd2cd qProcessInfo was not correctly detecting the sysctl value for "hw.cpu64bit_capable".
It was just detecting the existance of the value. If it gets the value correctly, we need to check that it is non-zero to see if cpu64bit_capable should be true.

<rdar://problem/20857426> 

llvm-svn: 236759
2015-05-07 18:42:03 +00:00
Ilia K 7bb59b360b Implement -target-attach and -target-detach
Summary:
This changes add -target-attach and -target-detach. 

-target-attach allows lldb-mi to attach to an existing process by it's process id, matching gdb mi's syntax of '-target-attach <pid'. Additionally, support has been added for attaching to a process by name using '-target-attach -n <name>'. Combining this with --waitfor will allow lldb mi to attach to a process by name when the process starts. 

-target-detach simply detaches from the current process

Patch from chuckr@microsoft.com

Test Plan: I have added three tests, one each for -target-attach <pid>, -target-attach -n <name>, and -target-attach -n <name> --waitfor

Reviewers: paulmaybee, abidh, ChuckR

Subscribers: greggm, lldb-commits

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

llvm-svn: 236705
2015-05-07 07:38:49 +00:00
Ilia K d3da77e84e Add -s/--source option support (MI)
Summary:
This patch adds -s/--source option to execute source file with prepared command.
For example:
```
$ cat start_script 
target create ~/p/hello
process launch -s
continue
$ bin/lldb-mi -s start_script 
(gdb)
target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
^done
(gdb)
process launch -s
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
Process 33289 launched: '/Users/IliaK/p/hello' (x86_64)
^done
(gdb)
continue
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
Process 33289 resuming
Process 33289 exited with status = 0 (0x00000000) 
^done
```

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 236703
2015-05-07 06:51:46 +00:00
Ilia K 8913012ee9 Remove quit hook in CMIDriver::DoMainLoop (MI)
Summary:
This patch removes quit hook and fixes 1 bug:
# Fix "quit" hook in CMIDriver::DoMainLoop (MI)
# Fix bug when the handler thread exits without any notification (MI)
# Fix a race condition in CMICmnLLDBDebugger::MonitorSBListenerEvents (MI)

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 236702
2015-05-07 06:45:42 +00:00
Bruce Mitchener 2873469ec0 Fix LLDB-MI -data-read-memory-bytes command to comply with GDB/MI spec
Summary:
- The address argument can now be an expression (e.g. &array), it's no longer restricted to being just a number literal.
- The -o (offset) option is now properly handled, not just silently ignored.
- The --thread option is now properly handled.
- A new --frame option has been added for consistency with GDB.
- Added a new test to verify old and new functionality.

Patch by Vadim Macagon. Thanks!

Test Plan: ./dotest.py -A x86_64 -C clang --executable $BUILDDIR/bin/lldb tools/lldb-mi/data

Reviewers: domipheus, abidh, ki.stfu

Reviewed By: abidh, ki.stfu

Subscribers: brucem, lldb-commits

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

llvm-svn: 236694
2015-05-07 05:32:13 +00:00
Chaoren Lin ec53482aef PosixPipes should not be copyable but should be movable.
Summary: This addresses Oleksiy's comment in D9307.

Reviewers: clayborg, ovyalov

Reviewed By: clayborg, ovyalov

Subscribers: lldb-commits

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

llvm-svn: 236320
2015-05-01 16:49:23 +00:00
Jason Molenda 29db330ce7 Use #include "lldb/API/SBCommandReturnObject.h" instead of <...>.
llvm-svn: 236284
2015-04-30 23:31:04 +00:00
Ilia K ebb4dfd350 Rework =shlibs-added/=shlibs-removed
Summary:
This patch includes the following:
* Rename =shlibs-added/=shlibs-removed to standard =library-loaded/=library-unloaded
* Remove redundant fields
* Add extra symbols-loaded/symbols-path and loaded_addr fields
* Rename CMICmnMIOutOfBandRecord::eOutOfBand_TargetModulesLoaded/eOutOfBand_TargetModulesUnloaded to CMICmnMIOutOfBandRecord::eOutOfBand_TargetModuleLoaded/eOutOfBand_TargetModuleUnloaded

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: jasonmolenda, jingham, abidh

Reviewed By: abidh

Subscribers: lldb-commits, jingham, jasonmolenda, abidh

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

llvm-svn: 236225
2015-04-30 11:08:31 +00:00
Ilia K 4ba3aee138 Add -data-info-line command (MI)
Summary: Add -data-info-line command + test

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 236208
2015-04-30 07:14:24 +00:00
Chaoren Lin 4dc65069a1 lldb-gdbserver should not use unnamed pipes on Windows.
llvm-svn: 236138
2015-04-29 19:01:43 +00:00
Chaoren Lin a52f48412d Add file descriptor constructor for PipePosix.
llvm-svn: 236133
2015-04-29 17:36:58 +00:00
Hafiz Abid Qadeer fda237d09f Add support for -stack-list-variables.
This command is able to list both local variables and stack arguments for a specific thread/frame.
Args are denoted with 'arg="1"'.
Patch from Chuck Ries.

llvm-svn: 236090
2015-04-29 08:18:41 +00:00
Hafiz Abid Qadeer 7f2f0ccb0a Replace sprintf with snprintf to avoid a crash.
During testing -data-list-register-values, I saw a crash here due to buffer overflow.
This commit should fix the crash. There is still problem with printing 1-byte register
in some cases that I will fix separately.

No regression on MI test cases.

llvm-svn: 235991
2015-04-28 14:16:00 +00:00
Ilia K 7f83624222 Add language option in -gdb-show command (MI)
Summary:
Add language option in -gdb-show command + test:
```
$ bin/lldb-mi ~/p/hello
[...]
b main
[...]
r
[...]
(gdb)
-gdb-show language
^done,value="c++"
(gdb)
quit
```

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh, granata.enrico, jingham, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, jingham, granata.enrico, clayborg, abidh

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

llvm-svn: 235983
2015-04-28 12:51:16 +00:00
Bruce Mitchener 41ad9c4128 LLDB-MI: -var-list-children with no children doesn't need a children value in the response.
Summary:
When using GDB with MI, if there aren't children for a variable,
it doesn't include a "children" value in the response. LLDB does
and sets it to "[]" while variables with children have an unquoted
list: children=[...].

This removes the children value entirely when there are no children
making this match GDB in behavior.

Test Plan: Ran tests on Mac OS X and they passed.

Reviewers: abidh, domipheus

Subscribers: lldb-commits

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

llvm-svn: 235974
2015-04-28 10:03:55 +00:00
Chaoren Lin 368c9f6e9b Add an unnamed pipe fail-safe to launching lldb-gdbserver.
Summary:
Currently, launching lldb-gdbserver from platform on Android requires root for
mkfifo() and an explicit TMPDIR variable. This should remove both requirements.

Test Plan: Successfully launched lldb-gdbserver on a non-rooted Android device.

Reviewers: tberghammer, vharron, clayborg

Reviewed By: clayborg

Subscribers: tberghammer, lldb-commits

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

llvm-svn: 235940
2015-04-27 23:20:30 +00:00
Hafiz Abid Qadeer 398732979a Improve handling of ctrl-c with MSVC.
Currently hitting Ctrl-C in Windows LLDB-MI just exits MI. But according to test_lldbmi_stopped_when_interrupt() in TestMiSignal.py Ctrl-C should send a SIGINT signal to the inferior.
Patch adds this functionality to Windows so SIGINT is sent on Ctrl-C.

Patch from EwanCrawford. Reviewed in http://reviews.llvm.org/D9248.

llvm-svn: 235887
2015-04-27 15:04:42 +00:00
Ilia K c04ce6e25c Fix double stdout/stderr output from CLI commands in MI mode (MI)
Summary:
This patch fixes stdout/stderr output that printed twice for CLI commands:
was:
```
(gdb)
target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
Current executable set to '~/p/hello' (x86_64).
^done
(gdb)
```
now:
```
(gdb)
target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
^done
(gdb)
```

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 235857
2015-04-27 10:07:49 +00:00
Ilia K b64b8e16db Clean the CMIDriver (MI)
This patch does the following things:
* Use CMICmnStreamStdout::TextToStdout to print (gdb) prompt in CMIDriver::InitClientIDEEclipse
* Remove unnecessary inclusions

llvm-svn: 235817
2015-04-26 05:55:59 +00:00
Ilia K fb2be6c6f3 Clean CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended (MI)
Don't call the lldb::SBProcess::GetRestartedFromEvent twice while
handling the CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended.

llvm-svn: 235812
2015-04-25 21:21:55 +00:00
Ilia K 41a38d2021 Fix CMIUtilThreadActiveObjBase::ThreadIsActive when a thread has died (MI)
llvm-svn: 235811
2015-04-25 21:20:00 +00:00
Ilia K 94b8ebcacf Add -gdb-set/-gdb-show aggregate-field-names option (MI)
Use this option to print/skip field names (default is on):
```
-var-create var1 * complx
^done,name="var1",numchild="3",value="{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}",type="complex_type",thread-id="1",has_more="0"
-var-create var2 * complx_array
^done,name="var2",numchild="2",value="{[0] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, [1] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}",type="complex_type [2]",thread-id="1",has_more="0"
-gdb-set print aggregate-field-names off
^done
-var-create var3 * complx
^done,name="var3",numchild="3",value="{3,{3},0x[0-9a-f]+}",type="complex_type",thread-id="1",has_more="0"
-var-create var4 * complx_array
^done,name="var4",numchild="2",value="{{4,{4},0x[0-9a-f]+},{5,{5},0x[0-9a-f]+}}",type="complex_type [2]",thread-id="1",has_more="0"
```

llvm-svn: 235807
2015-04-25 20:33:02 +00:00
Ilia K 81bd06d787 Add -gdb-set/-gdb-show expand-aggregates option (MI)
Use this option to expand complex types always:
```
-var-create var1 * complx
^done,name="var1",numchild="3",value="{...}",type="complex_type",thread-id="1",has_more="0"
-var-create var2 * complx_array
^done,name="var2",numchild="2",value="[2]",type="complex_type [2]",thread-id="1",has_more="0"
-gdb-set print expand-aggregates on
^done
-var-create var3 * complx
^done,name="var3",numchild="3",value="{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}",type="complex_type",thread-id="1",has_more="0"
-var-create var4 * complx_array
^done,name="var4",numchild="2",value="{[0] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, [1] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}",type="complex_type [2]",thread-id="1",has_more="0"
```

llvm-svn: 235805
2015-04-25 20:10:02 +00:00
Ilia K aa82b4af84 Add -gdb-set/-gdb-show print char-array-as-string option (MI)
llvm-svn: 235804
2015-04-25 19:44:56 +00:00
Ilia K afef49267a Fix CMICmnLLDBDebuggerHandleEvents::GetProcessStdout/GetProcessStderr to use stream-record (MI)
llvm-svn: 235711
2015-04-24 11:33:36 +00:00
Ilia K b9355045e1 Fix CMICmnMIOutOfBandRecord to accept stream-records (MI)
Previously the CMICmnMIOutOfBandRecord class worked only with async-records.

llvm-svn: 235709
2015-04-24 11:27:36 +00:00
Ilia K 3b0494c304 MI fix allowing multiple logging instances of lldb-mi to run simultaneously.
Summary:
Currently if two instances of lldb-mi are running with logging enabled using '--log' the log file conflicts. This produces the following error 
MI: Error: File Handler. Error Permission denied opening 'C:\Users\Ewan\LLVM\build\Debug\bin\lldb-mi-log.txt'

Fixed in this patch by renaming lldb-mi-log.txt based on the date, e.g. lldb-mi-log.txt-20150316163631.log, and moving the file into the temp directory by using the --log-dir option.

Regrading previous review comments the P_tmpdir macro is defined in Windows but always points to "\", which doesn't help much. Also when using the Windows API for GetTempPath() dynamic memory seems much more messy.

Patch from ewan@codeplay.com

Reviewers: abidh, EwanCrawford

Subscribers: zturner, lldb-commits, deepak2427

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

llvm-svn: 235589
2015-04-23 12:48:42 +00:00
Ilia K 5a931869d4 MI Refactor CMIUtilSystemWindows::GetExecutablesPath()
Summary:
My understanding of the Windows API call GetLastError() is that it should only be checked when ::GetModuleFileName()  returns 0 on error.
Otherwise GetExecutablesPath() could return an error despite nLen being valid if GetLastError() was inconsistent.
Patch updates function to only call GetOSLastError() when nLen == 0

Patch from ewan@codeplay.com

Reviewers: EwanCrawford

Subscribers: lldb-commits, deepak2427

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

llvm-svn: 235515
2015-04-22 15:43:43 +00:00
Ilia K d854180afb MI support for '-var-create $regname' command.
Summary:
This command is currently processed using expression evaluation, meaning the variable binds to the result of the expression not the register.
Therefore any subsequent calls to '-var-assign' will not update the register. Fixed by detecting '$' prefix for registers according to specification.

Thanks, Ewan

Patch from ewan@codeplay.com

Reviewers: EwanCrawford

Subscribers: lldb-commits, deepak2427

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

llvm-svn: 235195
2015-04-17 14:49:54 +00:00
Pavel Labath 1107b5a597 Use non-blocking waitpid in NativeProcessLinux
Summary:
This is the first phase of the merging of Monitor and Operation threads in NativeProcessLinux
(which is necessary since the two threads race inside Linux kernel). Here, I reimplement the
Monitor thread do use non-blocking waitpid calls, which enables later addition of code from the
operation thread.

Test Plan: Ran the test suite a couple of times, no regressions detected.

Reviewers: vharron, ovyalov, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 235193
2015-04-17 14:07:49 +00:00
Ilia K 7e38b5802a Add comments to LLDB-MI disassembly.
Summary:
This patch adds the comments which are included in LLDB disassembly, but are currently missing in MI, e.g.

 ^done,asm_insns=[...,{address="0x00000000004004ff",func-name="main",offset="18",size="2",inst="jmp 0x40050b ; <+30> at main.c:7"}]

 instead of

 ^done,asm_insns=[...,{address="0x00000000004004ff",func-name="main",offset="18",size="2",inst="jmp 0x40050b"}]

Thanks, Ewan

Patch from ewan@codeplay.com

Reviewers: abidh, EwanCrawford

Subscribers: ted, lldb-commits, deepak2427

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

llvm-svn: 235017
2015-04-15 16:17:50 +00:00
Ilia K bc929b80dc Fix handling of the executable arg which contains spaces (MI)
* Don't use the CMICmdArgValFile::GetFileNamePath for the CMIDriver::m_strCmdLineArgExecuteableFileNamePath
  because it wraps path with spaces into quotes what is already being done in CMIDriver::LocalDebugSessionStartupExecuteCommands
* Improve the MiSyntaxTestCase.test_lldbmi_specialchars test to catch this error
  ```
    $ bin/lldb-mi "~/p/ hello"
    (gdb)
    -file-exec-and-symbols "\"~/p/ hello\""
    ^error,msg="Command 'file-exec-and-symbols'. Target binary '\"~/p/ hello\"' is invalid. error: unable to find executable for '/"~/p/ hello/"'"
  ```

llvm-svn: 234888
2015-04-14 14:12:22 +00:00
Ilia K 2ecf23bc5d Fix CMICmnStreamStdout::WritePriv which causes a stack overflow (MI)
This includes:
* Remove IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN enum value
* Remove IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN mapped string in CMICmnResources::ms_pResourceId2TextData
* Fix a stack overflow which happens when fputs() fails:
  ```
    [...]
    frame #21153: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
    frame #21154: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
    frame #21155: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
    frame #21156: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
    frame #21157: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
    frame #21158: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
    frame #21159: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
    frame #21160: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
    frame #21161: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
    frame #21162: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
    frame #21163: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
    frame #21164: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
    frame #21165: 0x00000001045dc540 lldb-mi`CMICmnStreamStdout::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
    frame #21166: 0x00000001045de5fb lldb-mi`CMIDriver::DoMainLoop() + 939
    frame #21167: 0x00000001045e2334 lldb-mi`CMIDriverMgr::DriverMainLoop() + 36
    frame #21168: 0x00000001045e1a39 lldb-mi`main + 217
    frame #21169: 0x00007fff90f395c9 libdyld.dylib`start + 1
  ```

llvm-svn: 234751
2015-04-13 14:40:16 +00:00
Ilia K 9b618d25ca Generate an event when a pending breakpoint binds
Summary:
This checkin sends an MI event when a module is loaded that causes a pending breakpoint to bind to it's real address in the target. This allows breakpoints to be set before the process is launched, and the target address of the BP to be discovered when the module loads, prior to the breakpoint being hit. 

Patch from chuckr@microsoft.com

Test Plan:
I ran the check-lldb target with and without this patch and saw no change. I am unsure of how to write an MI specific test for this because the new event is buried in module load events. Here is an example (the new event is in bold):


```
(gdb)
-file-exec-and-symbols a.out
^done
(gdb)
=shlibs-added,shlib-info=[num="1",name="a.out",dyld-addr="-",reason="dyld",path="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/a.out",loaded_addr="-",dsym-objpath="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/a.out.dSYM/Contents/Resources/DWARF/a.out"]
-break-insert -f main.cpp:15
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffffffffffff",func="main",file="main.cpp",fullname="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/main.cpp",line="15",pending=["main.cpp:15"],times="0",original-location="main.cpp:15"}
(gdb)
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffffffffffff",func="main",file="main.cpp",fullname="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/main.cpp",line="15",pending=["main.cpp:15"],times="0",original-location="main.cpp:15"}
-exec-run
^running
=thread-group-started,id="i1",pid="75620"
(gdb)
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
=shlibs-added,shlib-info=[num="2",name="dyld",dyld-addr="0x7fff5fc00000",reason="dyld",path="/usr/lib/dyld",loaded_addr="0x7fff5fc00000"]
(gdb)
=shlibs-added,shlib-info=[num="3",name="dyld",dyld-addr="0x7fff5fc00000",reason="dyld",path="/usr/lib/dyld",loaded_addr="0x7fff5fc00000"]
(gdb)
*running,thread-id="all"
(gdb)
(gdb)
=shlibs-added,shlib-info=[num="4",name="libc++.1.dylib",dyld-addr="0x7fff85dd0000",reason="dyld",path="/usr/lib/libc++.1.dylib",loaded_addr="0x7fff85dd0000"]
(gdb)
=shlibs-added,shlib-info=[num="5",name="libSystem.B.dylib",dyld-addr="0x7fff851ab000",reason="dyld",path="/usr/lib/libSystem.B.dylib",loaded_addr="0x7fff851ab000"]
(gdb)
=shlibs-added,shlib-info=[num="6",name="libc++abi.dylib",dyld-addr="0x7fff81be8000",reason="dyld",path="/usr/lib/libc++abi.dylib",loaded_addr="0x7fff81be8000"]
(gdb)
=shlibs-added,shlib-info=[num="7",name="libcache.dylib",dyld-addr="0x7fff8b975000",reason="dyld",path="/usr/lib/system/libcache.dylib",loaded_addr="0x7fff8b975000"]
(gdb)
=shlibs-added,shlib-info=[num="8",name="libcommonCrypto.dylib",dyld-addr="0x7fff85d14000",reason="dyld",path="/usr/lib/system/libcommonCrypto.dylib",loaded_addr="0x7fff85d14000"]
(gdb)
=shlibs-added,shlib-info=[num="9",name="libcompiler_rt.dylib",dyld-addr="0x7fff86154000",reason="dyld",path="/usr/lib/system/libcompiler_rt.dylib",loaded_addr="0x7fff86154000"]
(gdb)
=shlibs-added,shlib-info=[num="10",name="libcopyfile.dylib",dyld-addr="0x7fff81ac7000",reason="dyld",path="/usr/lib/system/libcopyfile.dylib",loaded_addr="0x7fff81ac7000"]
(gdb)
=shlibs-added,shlib-info=[num="11",name="libcorecrypto.dylib",dyld-addr="0x7fff87d5d000",reason="dyld",path="/usr/lib/system/libcorecrypto.dylib",loaded_addr="0x7fff87d5d000"]
(gdb)
=shlibs-added,shlib-info=[num="12",name="libdispatch.dylib",dyld-addr="0x7fff8ea8c000",reason="dyld",path="/usr/lib/system/libdispatch.dylib",loaded_addr="0x7fff8ea8c000"]
(gdb)
=shlibs-added,shlib-info=[num="13",name="libdyld.dylib",dyld-addr="0x7fff89087000",reason="dyld",path="/usr/lib/system/libdyld.dylib",loaded_addr="0x7fff89087000"]
(gdb)
=shlibs-added,shlib-info=[num="14",name="libkeymgr.dylib",dyld-addr="0x7fff8e818000",reason="dyld",path="/usr/lib/system/libkeymgr.dylib",loaded_addr="0x7fff8e818000"]
(gdb)
=shlibs-added,shlib-info=[num="15",name="liblaunch.dylib",dyld-addr="0x7fff84936000",reason="dyld",path="/usr/lib/system/liblaunch.dylib",loaded_addr="0x7fff84936000"]
(gdb)
=shlibs-added,shlib-info=[num="16",name="libmacho.dylib",dyld-addr="0x7fff8534e000",reason="dyld",path="/usr/lib/system/libmacho.dylib",loaded_addr="0x7fff8534e000"]
(gdb)
=shlibs-added,shlib-info=[num="17",name="libquarantine.dylib",dyld-addr="0x7fff90f97000",reason="dyld",path="/usr/lib/system/libquarantine.dylib",loaded_addr="0x7fff90f97000"]
(gdb)
=shlibs-added,shlib-info=[num="18",name="libremovefile.dylib",dyld-addr="0x7fff8ccb5000",reason="dyld",path="/usr/lib/system/libremovefile.dylib",loaded_addr="0x7fff8ccb5000"]
(gdb)
=shlibs-added,shlib-info=[num="19",name="libsystem_asl.dylib",dyld-addr="0x7fff8df67000",reason="dyld",path="/usr/lib/system/libsystem_asl.dylib",loaded_addr="0x7fff8df67000"]
(gdb)
=shlibs-added,shlib-info=[num="20",name="libsystem_blocks.dylib",dyld-addr="0x7fff8621c000",reason="dyld",path="/usr/lib/system/libsystem_blocks.dylib",loaded_addr="0x7fff8621c000"]
(gdb)
=shlibs-added,shlib-info=[num="21",name="libsystem_c.dylib",dyld-addr="0x7fff83c0f000",reason="dyld",path="/usr/lib/system/libsystem_c.dylib",loaded_addr="0x7fff83c0f000"]
(gdb)
=shlibs-added,shlib-info=[num="22",name="libsystem_configuration.dylib",dyld-addr="0x7fff8fd71000",reason="dyld",path="/usr/lib/system/libsystem_configuration.dylib",loaded_addr="0x7fff8fd71000"]
(gdb)
=shlibs-added,shlib-info=[num="23",name="libsystem_coreservices.dylib",dyld-addr="0x7fff8a028000",reason="dyld",path="/usr/lib/system/libsystem_coreservices.dylib",loaded_addr="0x7fff8a028000"]
(gdb)
=shlibs-added,shlib-info=[num="24",name="libsystem_coretls.dylib",dyld-addr="0x7fff90996000",reason="dyld",path="/usr/lib/system/libsystem_coretls.dylib",loaded_addr="0x7fff90996000"]
(gdb)
=shlibs-added,shlib-info=[num="25",name="libsystem_dnssd.dylib",dyld-addr="0x7fff8b71f000",reason="dyld",path="/usr/lib/system/libsystem_dnssd.dylib",loaded_addr="0x7fff8b71f000"]
(gdb)
=shlibs-added,shlib-info=[num="26",name="libsystem_info.dylib",dyld-addr="0x7fff8b9f2000",reason="dyld",path="/usr/lib/system/libsystem_info.dylib",loaded_addr="0x7fff8b9f2000"]
(gdb)
=shlibs-added,shlib-info=[num="27",name="libsystem_kernel.dylib",dyld-addr="0x7fff81ad0000",reason="dyld",path="/usr/lib/system/libsystem_kernel.dylib",loaded_addr="0x7fff81ad0000"]
(gdb)
=shlibs-added,shlib-info=[num="28",name="libsystem_m.dylib",dyld-addr="0x7fff84953000",reason="dyld",path="/usr/lib/system/libsystem_m.dylib",loaded_addr="0x7fff84953000"]
(gdb)
=shlibs-added,shlib-info=[num="29",name="libsystem_malloc.dylib",dyld-addr="0x7fff887bd000",reason="dyld",path="/usr/lib/system/libsystem_malloc.dylib",loaded_addr="0x7fff887bd000"]
(gdb)
=shlibs-added,shlib-info=[num="30",name="libsystem_network.dylib",dyld-addr="0x7fff88304000",reason="dyld",path="/usr/lib/system/libsystem_network.dylib",loaded_addr="0x7fff88304000"]
(gdb)
=shlibs-added,shlib-info=[num="31",name="libsystem_networkextension.dylib",dyld-addr="0x7fff82085000",reason="dyld",path="/usr/lib/system/libsystem_networkextension.dylib",loaded_addr="0x7fff82085000"]
(gdb)
=shlibs-added,shlib-info=[num="32",name="libsystem_notify.dylib",dyld-addr="0x7fff8eb69000",reason="dyld",path="/usr/lib/system/libsystem_notify.dylib",loaded_addr="0x7fff8eb69000"]
(gdb)
=shlibs-added,shlib-info=[num="33",name="libsystem_platform.dylib",dyld-addr="0x7fff89ac7000",reason="dyld",path="/usr/lib/system/libsystem_platform.dylib",loaded_addr="0x7fff89ac7000"]
(gdb)
=shlibs-added,shlib-info=[num="34",name="libsystem_pthread.dylib",dyld-addr="0x7fff83ff8000",reason="dyld",path="/usr/lib/system/libsystem_pthread.dylib",loaded_addr="0x7fff83ff8000"]
(gdb)
=shlibs-added,shlib-info=[num="35",name="libsystem_sandbox.dylib",dyld-addr="0x7fff89084000",reason="dyld",path="/usr/lib/system/libsystem_sandbox.dylib",loaded_addr="0x7fff89084000"]
(gdb)
=shlibs-added,shlib-info=[num="36",name="libsystem_secinit.dylib",dyld-addr="0x7fff8e816000",reason="dyld",path="/usr/lib/system/libsystem_secinit.dylib",loaded_addr="0x7fff8e816000"]
(gdb)
=shlibs-added,shlib-info=[num="37",name="libsystem_stats.dylib",dyld-addr="0x7fff89eaf000",reason="dyld",path="/usr/lib/system/libsystem_stats.dylib",loaded_addr="0x7fff89eaf000"]
(gdb)
=shlibs-added,shlib-info=[num="38",name="libsystem_trace.dylib",dyld-addr="0x7fff8ead4000",reason="dyld",path="/usr/lib/system/libsystem_trace.dylib",loaded_addr="0x7fff8ead4000"]
(gdb)
=shlibs-added,shlib-info=[num="39",name="libunc.dylib",dyld-addr="0x7fff8ab27000",reason="dyld",path="/usr/lib/system/libunc.dylib",loaded_addr="0x7fff8ab27000"]
(gdb)
=shlibs-added,shlib-info=[num="40",name="libunwind.dylib",dyld-addr="0x7fff85cf3000",reason="dyld",path="/usr/lib/system/libunwind.dylib",loaded_addr="0x7fff85cf3000"]
(gdb)
=shlibs-added,shlib-info=[num="41",name="libxpc.dylib",dyld-addr="0x7fff88896000",reason="dyld",path="/usr/lib/system/libxpc.dylib",loaded_addr="0x7fff88896000"]
(gdb)
=shlibs-added,shlib-info=[num="42",name="libobjc.A.dylib",dyld-addr="0x7fff84f13000",reason="dyld",path="/usr/lib/libobjc.A.dylib",loaded_addr="0x7fff84f13000"]
(gdb)
=shlibs-added,shlib-info=[num="43",name="libauto.dylib",dyld-addr="0x7fff85d89000",reason="dyld",path="/usr/lib/libauto.dylib",loaded_addr="0x7fff85d89000"]
(gdb)
=shlibs-added,shlib-info=[num="44",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff822e1000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff822e1000"]
```
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000f4d",func="main",file="main.cpp",fullname="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/main.cpp",line="15",pending=["main.cpp:15"],times="0",original-location="main.cpp:15"}
```
(gdb)
=shlibs-added,shlib-info=[num="45",name="a.out",dyld-addr="0x100000000",reason="dyld",path="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/a.out",loaded_addr="0x100000000",dsym-objpath="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/a.out.dSYM/Contents/Resources/DWARF/a.out"]
=shlibs-added,shlib-info=[num="46",name="libc++.1.dylib",dyld-addr="0x7fff85dd0000",reason="dyld",path="/usr/lib/libc++.1.dylib",loaded_addr="0x7fff85dd0000"]
=shlibs-added,shlib-info=[num="47",name="libSystem.B.dylib",dyld-addr="0x7fff851ab000",reason="dyld",path="/usr/lib/libSystem.B.dylib",loaded_addr="0x7fff851ab000"]
=shlibs-added,shlib-info=[num="48",name="libc++abi.dylib",dyld-addr="0x7fff81be8000",reason="dyld",path="/usr/lib/libc++abi.dylib",loaded_addr="0x7fff81be8000"]
=shlibs-added,shlib-info=[num="49",name="libcache.dylib",dyld-addr="0x7fff8b975000",reason="dyld",path="/usr/lib/system/libcache.dylib",loaded_addr="0x7fff8b975000"]
=shlibs-added,shlib-info=[num="50",name="libcommonCrypto.dylib",dyld-addr="0x7fff85d14000",reason="dyld",path="/usr/lib/system/libcommonCrypto.dylib",loaded_addr="0x7fff85d14000"]
=shlibs-added,shlib-info=[num="51",name="libcompiler_rt.dylib",dyld-addr="0x7fff86154000",reason="dyld",path="/usr/lib/system/libcompiler_rt.dylib",loaded_addr="0x7fff86154000"]
=shlibs-added,shlib-info=[num="52",name="libcopyfile.dylib",dyld-addr="0x7fff81ac7000",reason="dyld",path="/usr/lib/system/libcopyfile.dylib",loaded_addr="0x7fff81ac7000"]
=shlibs-added,shlib-info=[num="53",name="libcorecrypto.dylib",dyld-addr="0x7fff87d5d000",reason="dyld",path="/usr/lib/system/libcorecrypto.dylib",loaded_addr="0x7fff87d5d000"]
=shlibs-added,shlib-info=[num="54",name="libdispatch.dylib",dyld-addr="0x7fff8ea8c000",reason="dyld",path="/usr/lib/system/libdispatch.dylib",loaded_addr="0x7fff8ea8c000"]
=shlibs-added,shlib-info=[num="55",name="libdyld.dylib",dyld-addr="0x7fff89087000",reason="dyld",path="/usr/lib/system/libdyld.dylib",loaded_addr="0x7fff89087000"]
=shlibs-added,shlib-info=[num="56",name="libkeymgr.dylib",dyld-addr="0x7fff8e818000",reason="dyld",path="/usr/lib/system/libkeymgr.dylib",loaded_addr="0x7fff8e818000"]
=shlibs-added,shlib-info=[num="57",name="liblaunch.dylib",dyld-addr="0x7fff84936000",reason="dyld",path="/usr/lib/system/liblaunch.dylib",loaded_addr="0x7fff84936000"]
=shlibs-added,shlib-info=[num="58",name="libmacho.dylib",dyld-addr="0x7fff8534e000",reason="dyld",path="/usr/lib/system/libmacho.dylib",loaded_addr="0x7fff8534e000"]
=shlibs-added,shlib-info=[num="59",name="libquarantine.dylib",dyld-addr="0x7fff90f97000",reason="dyld",path="/usr/lib/system/libquarantine.dylib",loaded_addr="0x7fff90f97000"]
=shlibs-added,shlib-info=[num="60",name="libremovefile.dylib",dyld-addr="0x7fff8ccb5000",reason="dyld",path="/usr/lib/system/libremovefile.dylib",loaded_addr="0x7fff8ccb5000"]
=shlibs-added,shlib-info=[num="61",name="libsystem_asl.dylib",dyld-addr="0x7fff8df67000",reason="dyld",path="/usr/lib/system/libsystem_asl.dylib",loaded_addr="0x7fff8df67000"]
=shlibs-added,shlib-info=[num="62",name="libsystem_blocks.dylib",dyld-addr="0x7fff8621c000",reason="dyld",path="/usr/lib/system/libsystem_blocks.dylib",loaded_addr="0x7fff8621c000"]
=shlibs-added,shlib-info=[num="63",name="libsystem_c.dylib",dyld-addr="0x7fff83c0f000",reason="dyld",path="/usr/lib/system/libsystem_c.dylib",loaded_addr="0x7fff83c0f000"]
=shlibs-added,shlib-info=[num="64",name="libsystem_configuration.dylib",dyld-addr="0x7fff8fd71000",reason="dyld",path="/usr/lib/system/libsystem_configuration.dylib",loaded_addr="0x7fff8fd71000"]
=shlibs-added,shlib-info=[num="65",name="libsystem_coreservices.dylib",dyld-addr="0x7fff8a028000",reason="dyld",path="/usr/lib/system/libsystem_coreservices.dylib",loaded_addr="0x7fff8a028000"]
=shlibs-added,shlib-info=[num="66",name="libsystem_coretls.dylib",dyld-addr="0x7fff90996000",reason="dyld",path="/usr/lib/system/libsystem_coretls.dylib",loaded_addr="0x7fff90996000"]
=shlibs-added,shlib-info=[num="67",name="libsystem_dnssd.dylib",dyld-addr="0x7fff8b71f000",reason="dyld",path="/usr/lib/system/libsystem_dnssd.dylib",loaded_addr="0x7fff8b71f000"]
=shlibs-added,shlib-info=[num="68",name="libsystem_info.dylib",dyld-addr="0x7fff8b9f2000",reason="dyld",path="/usr/lib/system/libsystem_info.dylib",loaded_addr="0x7fff8b9f2000"]
=shlibs-added,shlib-info=[num="69",name="libsystem_kernel.dylib",dyld-addr="0x7fff81ad0000",reason="dyld",path="/usr/lib/system/libsystem_kernel.dylib",loaded_addr="0x7fff81ad0000"]
=shlibs-added,shlib-info=[num="70",name="libsystem_m.dylib",dyld-addr="0x7fff84953000",reason="dyld",path="/usr/lib/system/libsystem_m.dylib",loaded_addr="0x7fff84953000"]
=shlibs-added,shlib-info=[num="71",name="libsystem_malloc.dylib",dyld-addr="0x7fff887bd000",reason="dyld",path="/usr/lib/system/libsystem_malloc.dylib",loaded_addr="0x7fff887bd000"]
=shlibs-added,shlib-info=[num="72",name="libsystem_network.dylib",dyld-addr="0x7fff88304000",reason="dyld",path="/usr/lib/system/libsystem_network.dylib",loaded_addr="0x7fff88304000"]
=shlibs-added,shlib-info=[num="73",name="libsystem_networkextension.dylib",dyld-addr="0x7fff82085000",reason="dyld",path="/usr/lib/system/libsystem_networkextension.dylib",loaded_addr="0x7fff82085000"]
=shlibs-added,shlib-info=[num="74",name="libsystem_notify.dylib",dyld-addr="0x7fff8eb69000",reason="dyld",path="/usr/lib/system/libsystem_notify.dylib",loaded_addr="0x7fff8eb69000"]
=shlibs-added,shlib-info=[num="75",name="libsystem_platform.dylib",dyld-addr="0x7fff89ac7000",reason="dyld",path="/usr/lib/system/libsystem_platform.dylib",loaded_addr="0x7fff89ac7000"]
=shlibs-added,shlib-info=[num="76",name="libsystem_pthread.dylib",dyld-addr="0x7fff83ff8000",reason="dyld",path="/usr/lib/system/libsystem_pthread.dylib",loaded_addr="0x7fff83ff8000"]
=shlibs-added,shlib-info=[num="77",name="libsystem_sandbox.dylib",dyld-addr="0x7fff89084000",reason="dyld",path="/usr/lib/system/libsystem_sandbox.dylib",loaded_addr="0x7fff89084000"]
=shlibs-added,shlib-info=[num="78",name="libsystem_secinit.dylib",dyld-addr="0x7fff8e816000",reason="dyld",path="/usr/lib/system/libsystem_secinit.dylib",loaded_addr="0x7fff8e816000"]
=shlibs-added,shlib-info=[num="79",name="libsystem_stats.dylib",dyld-addr="0x7fff89eaf000",reason="dyld",path="/usr/lib/system/libsystem_stats.dylib",loaded_addr="0x7fff89eaf000"]
=shlibs-added,shlib-info=[num="80",name="libsystem_trace.dylib",dyld-addr="0x7fff8ead4000",reason="dyld",path="/usr/lib/system/libsystem_trace.dylib",loaded_addr="0x7fff8ead4000"]
=shlibs-added,shlib-info=[num="81",name="libunc.dylib",dyld-addr="0x7fff8ab27000",reason="dyld",path="/usr/lib/system/libunc.dylib",loaded_addr="0x7fff8ab27000"]
=shlibs-added,shlib-info=[num="82",name="libunwind.dylib",dyld-addr="0x7fff85cf3000",reason="dyld",path="/usr/lib/system/libunwind.dylib",loaded_addr="0x7fff85cf3000"]
=shlibs-added,shlib-info=[num="83",name="libxpc.dylib",dyld-addr="0x7fff88896000",reason="dyld",path="/usr/lib/system/libxpc.dylib",loaded_addr="0x7fff88896000"]
=shlibs-added,shlib-info=[num="84",name="libobjc.A.dylib",dyld-addr="0x7fff84f13000",reason="dyld",path="/usr/lib/libobjc.A.dylib",loaded_addr="0x7fff84f13000"]
=shlibs-added,shlib-info=[num="85",name="libauto.dylib",dyld-addr="0x7fff85d89000",reason="dyld",path="/usr/lib/libauto.dylib",loaded_addr="0x7fff85d89000"]
=shlibs-added,shlib-info=[num="86",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff822e1000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff822e1000"]
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x0000000100000f4d",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5fbffed8"}],file="main.cpp",fullname="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/main.cpp",line="15"},thread-id="1",stopped-threads="all"
(gdb)
```

Reviewers: abidh, clayborg, ChuckR, jingham

Subscribers: ki.stfu, paulmaybee, lldb-commits

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

llvm-svn: 234483
2015-04-09 12:55:13 +00:00
Ilia K b49b2d2166 Fix MiGdbSetShowTestCase.test_lldbmi_gdb_set_ouptut_radix after r234476
This includes:
* Add CMICmnLLDBUtilSBValue::IsIntegerType to check integer type
* Improve CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted to handle veVarFormat arg

llvm-svn: 234480
2015-04-09 12:21:56 +00:00
Ilia K 58627321f6 Refactor CMICmnLLDBDebuggerHandleEvents/CMICmnLLDBDebugSessionInfo/CMICmnLLDBDebugSessionInfoVarObj (MI)
Summary:
This patch includes the following changes:

# Refactor GetVariableInfo/GetValueStringFormatted/GetValue to use the same code (MI)
Also it expands the variable value format for strings (aka char*):
was:
```
^done,name="v4",numchild="1",value="0x0000000100000f56",type="const char *",thread-id="1",has_more="0"
```
now:
```
^done,name="v4",numchild="1",value="0x0000000100000f56 \"ab\"",type="const char *",thread-id="1",has_more="0"
```

# Expand the variable value format for arrays (according to GDB)
For example:
was:
```
^done,name="v3",numchild="2",value="{...}",type="char [2]",thread-id="1",has_more="0"
```
now:
```
^done,name="v3",numchild="2",value="[2]",type="char [2]",thread-id="1",has_more="0"
```

# Rename MiGdbSetShowTestCase.test_lldbmi_gdb_show_process_stopatentry_default to test_lldbmi_gdb_show_process_stopatentry (MI)

# Fix a comment in MiGdbSetShowTestCase.test_lldbmi_gdb_show_process_stopatentry (MI)

# Refactor CMICmnLLDBUtilSBValue
## Add CMICmnLLDBUtilSBValue::IsPointerType/IsArrayType
## Refactor CMICmnLLDBUtilSBValue::GetValue
## Fix CMICmnLLDBUtilSBValue::IsChildCharType to ignore a number of childs
## Rename CMICmnLLDBUtilSBValue::IsChildCharType to IsFirstChildCharType
## Fix CMICmnLLDBUtilSBValue::GetValueCString to accept char[]

# Minor changes in CMICmnLLDBUtilSBValue::GetValue

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo family functions (MI)

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo family functions (MI)
## Remove CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo2
## Improve CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo to accept args

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo family functions (MI)
## Add vArgInfo arg to CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo
## Move CMICmnLLDBDebugSessionInfo::GetFrameInfo/MIResponseFormFrameInfo to private namespace

# Refactor CMICmnLLDBDebugSessionInfo::GetThreadFrames family functions (MI)
## Remove CMICmnLLDBDebugSessionInfo::GetThreadFrames2
## Improve CMICmnLLDBDebugSessionInfo::GetThreadFrames to accept vnMaxDepth

# Fix vnMaxDepth arg name in CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo (MI)

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo family functions (MI)
## Merge CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo functions into one

# Don't modify fnName in CMICmnLLDBDebugSessionInfo::GetThreadFrames (MI)

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo family functions (MI)
## Remove CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo3
## Improve -CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo to accept vnMaxDepth

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo family functions (MI)
## Remove CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo2
## Add CMICmnLLDBDebugSessionInfo::ThreadInfoFormat_e enum to specify thread format
## Improve CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo to accept veThreadInfoFormat
## Remove vnMaxDepth arg in CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo (not needed because veThreadInfoFormat was added)

# Move CMICmnLLDBDebugSessionInfo::GetThreadFrames to private namespace (MI)

# Refactor CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo (MI)
## Add CMICmnLLDBDebugSessionInfo::FrameInfoFormat_e enum to specify frame format
## Improve CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo to accept veFrameInfoFormat
## Remove vnMaxDepth arg in CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo (not needed because veFrameInfoFormat was added)

# Remove duplicated level field in CMICmnLLDBDebugSessionInfo::GetThreadFrames (MI)

# Refactor CMICmnLLDBUtilSBValue::GetValue (MI)
## Add CMICmnLLDBUtilSBValue::GetSimpleValue
## Use CMICmnLLDBUtilSBValue::GetSimpleValue in GetVlaue

# Fix CMICmnLLDBDebugSessionInfo::GetThreadFrames (MI)
## Add CMICmnLLDBDebugSessionInfo::FrameInfoFormat_e::eFrameInfoFormat_AllArgumentsInSimpleForm which is used to get stack-args in simple form (i.e. show {...} for composite types). It can be done by calling MIResponseFormVariableInfo with vnMaxDepth=0.
## Improve CMICmnLLDBDebugSessionInfo::GetThreadFrames to accept veFrameInfoFormat
## Remove vnMaxDepth from CMICmnLLDBDebugSessionInfo::GetThreadFrames (we should use veFrameInfoFormat instead)

# Refactor CMICmnLLDBUtilSBValue::GetValue to expand composite types (MI)
## Add CMICmnLLDBUtilSBValue::GetCompositeValue to expand composite types
## Add CMICmnLLDBUtilSBValue::m_pComposite to avoid multiple {...} in the code
## Improve CMICmnLLDBUtilSBValue::GetValue to accept vbExpandAggregates option (default=false)
## Clean up CMICmnLLDBDebugSessionInfo::GetVariableInfo to use CMICmnLLDBUtilSBValue::GetValue
## Remove the wrapping into {} in CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo
## Fix MiStackTestCase.test_lldbmi_stack_list_locals test to expect result without superfluous space ' ' around the '{' or '}' brackets:
was:
```
{name=\"var_c\",value=\"{var_a = 10,var_b = 97 'a',inner_ = { var_d = 30 }}
```
now:
```
{name=\"var_c\",value=\"{var_a = 10,var_b = 97 'a',inner_ = {var_d = 30}}
```
## Fix vwrValue arg name in CMICmnLLDBUtilSBValue::GetSimpleValue (was vrValue)

# Refactor CMICmnLLDBDebugSessionInfo::GetVariableInfo (MI)
## Remove vnMaxDepth/vbIsChildValue/vnDepth args in CMICmnLLDBDebugSessionInfo::GetVariableInfo
## Improve CMICmnLLDBDebugSessionInfo::GetVariableInfo to accept vwrStrValue
## Remove vwrMiValueList arg in CMICmnLLDBDebugSessionInfo::GetVariableInfo (we should use vwrStrValue instead)
## Fix CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo to Escape values
was:
```
{name="p",value="0x0000000000000000 """}
```
now:
```
{name="p",value="0x0000000000000000 \"\""}
```

# Refactor CMICmnLLDBUtilSBValue
## Improve CMICmnLLDBUtilSBValue::GetValue to handle PrintExpandAggregates
## Improve CMICmnLLDBUtilSBValue::GetSimpleValue to handle vbHandleArrayType (use it to specify that array should be represented as simple type, i.e. value="[2]")

# Add spacing between fields in CMICmnLLDBUtilSBValue::GetCompositeValue (MI)
For example:
was:
```
^done,name="var3",numchild="3",value="{i = 3,inner = {l = 3},complex_ptr = 0x00007fff5fbff848}",type="complex_type",thread-id="1",has_more="0"
```
now:
```
^done,name="var3",numchild="3",value="{i = 3, inner = {l = 3}, complex_ptr = 0x00007fff5fbff848}",type="complex_type",thread-id="1",has_more="0"
```

# Fix spacing in MiStackTestCase.test_lldbmi_stack_list_locals test (MI)

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/

Reviewers: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 234476
2015-04-09 11:17:54 +00:00
Sylvestre Ledru 5a1a7ebe53 Force the inclusion of the LLVMSupport lib. Otherwise, the build (might?) fails with an undefined reference to 'llvm::llvm_is_multithreaded()'
llvm-svn: 234407
2015-04-08 14:09:36 +00:00
Ilia K 68757ed2e9 implement gdb-set output-radix
Summary: Patch from chuckr@microsoft.com

Reviewers: abidh, ChuckR

Reviewed By: abidh

Subscribers: paulmaybee, ki.stfu, greggm, scarroll, lldb-commits

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

llvm-svn: 234305
2015-04-07 09:47:23 +00:00
Greg Clayton f55ec07b38 Don't export a ton of lldb_private symbols from argdumper.
llvm-svn: 233825
2015-04-01 17:38:08 +00:00
Zachary Turner e6e2bb3842 Rework LLDB system initialization.
In an effort to reduce binary size for components not wishing to
link against all of LLDB, as well as a parallel effort to reduce
link dependencies on Python, this patch splits out the notion of
LLDB initialization into "full" and "common" initialization.

All code related to initializing the full LLDB suite lives directly
in API now.  Previously it was only referenced from API, but because
it was defined in lldbCore, it would get implicitly linked against
by everything including lldb-server, causing a considerable
increase in binary size.

By moving this to the API layer, it also creates a better layering
for the ongoing effort to make the embedded interpreter replacable
with one from a different language (or even be completely removeable).

One semantic change necessary to get this all working was to remove
the notion of a shared debugger refcount.  The debugger is either
initialized or uninitialized now, and calling Initialize() multiple
times will simply have no effect, while the first Terminate() will
now shut it down no matter how many times Initialize() was called.
This behaves nicely with all of our supported usage patterns though,
and allows us to fix a number of nasty hacks from before.

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

llvm-svn: 233758
2015-03-31 21:03:22 +00:00
Greg Clayton 1988ac60a6 Silence a compiler warning about "bAsyncMode" possibly being used uninitialized.
llvm-svn: 233754
2015-03-31 20:55:50 +00:00
Hafiz Abid Qadeer 0e1f11ffe0 Changed a function to static.
A temp object was being created to call StripOffFileName. This function
is not dependent on class members so I am making it static.
No regression on testsuite on Linux.

llvm-svn: 233703
2015-03-31 16:30:29 +00:00
Tamas Berghammer db264a6d09 Move several plugin to its own namespace
Affected paths:
* Plugins/Platform/Android/*
* Plugins/Platform/Linux/*
* Plugins/Platform/gdb-server/*
* Plugins/Process/Linux/*
* Plugins/Process/gdb-remote/*

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

llvm-svn: 233679
2015-03-31 09:52:22 +00:00
Vince Harron 33aea9001a Increate backlog of lldb-platform's listener socket
lldb-platform's listener socket only had a backlog of one connection.
That means that if more than one client connected simultaneously, the
connection would be refused. The test suite can be run remotely with
dozens of threads connecting simultaneously. Raised this limit to 100
to effectively eliminate lost connections.

Test Plan:
run tests against a remote target

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

llvm-svn: 233652
2015-03-31 00:27:10 +00:00
Vince Harron f1e6999cec Fix socket leak in lldb-server platform
lldb-server server process was holding on to a connection to every
client that connected. This continued until the process hit it's
file limit and exited.

lldb-server p --listen *:5432 --server

run remote tests against that server more than 1000 times

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

llvm-svn: 233651
2015-03-31 00:24:51 +00:00
Adrian McCarthy e704c4ffd9 Work around lack of %zd printf format specifier in MSVC libs.
llvm-svn: 233569
2015-03-30 17:46:36 +00:00
Ilia K 5704347c29 Fix infinite loop when ^D was pressed (MI)
llvm-svn: 233278
2015-03-26 15:10:32 +00:00
Ilia K c248ec2c29 Use std::vector::iterator in CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges to fix build on Linux after r233260 (MI)
llvm-svn: 233265
2015-03-26 09:43:23 +00:00
Ilia K 23536d92c7 Use std::vector::const_iterator and std::vector::cbegin/cend in CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges (MI)
llvm-svn: 233260
2015-03-26 08:16:18 +00:00
Ilia K 490500a7e8 Fix =thread-exited message (MI)
Summary:
This patch includes:
# Fix invalid thread id in =thread-exited message
# Remove invalid threads from cache

All tests pass on OS X.

Test Plan:
now
```
=thread-exited,id="3",group-id="i1"
=thread-exited,id="4",group-id="i1"
=thread-exited,id="5",group-id="i1"
```

was
```
=thread-exited,id="4294967295",group-id="i1"
=thread-exited,id="4294967295",group-id="i1"
...
=thread-exited,id="4294967295",group-id="i1"
=thread-exited,id="4294967295",group-id="i1"
```

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 233256
2015-03-26 07:11:31 +00:00
Ilia K fcc89a079f Fix -gdb-exit to detach if was attached or destroy otherwise (MI)
Summary:
This patch fixes -gdb-exit for locally target. It includes the following changes:
# Fix Process::Finalize
# Use SBProcess::Destroy in -gdb-exit

Reviewers: abidh, zturner, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 233255
2015-03-26 07:08:47 +00:00
Robert Flack a0e70cd4b6 Allow multiple simultaneous connections to platform.
Adds the --server argument to lldb-server platform which when specified will allow multiple simultaneous connections by forking off to handle each individual connection. This will allow us to run the remote tests in parallel.

Test Plan:
Run: lldb-server platform --listen *:1234 --server
Connect from multiple lldb clients simultaneously.
I will also test running the test suite remotely with multiple simultaneous jobs.

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

llvm-svn: 233185
2015-03-25 12:51:31 +00:00
Ilia K d0aa59f77f Add -gdb-show and target-async option in -gdb-show command (MI)
Summary:
This path adds -gdb-show command with 1 option: target-async.

Also it adds tests for -gdb-set and -gdb-show commands.

All tests pass on OS X.

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb -f MiGdbSetShowTestCase

Reviewers: clayborg, abidh

Reviewed By: clayborg, abidh

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 233114
2015-03-24 21:15:42 +00:00
Ilia K 689dda1c67 Add support for CLI commands in lldb-mi
Summary:
This patch adds support for CLI command in lldb-mi. It's useful ability which also was implemented in gdb.

All tests pass on OS X.

Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/interpreter/

Reviewers: ted, clayborg, abidh

Reviewed By: clayborg, abidh

Subscribers: jingham, lldb-commits, ted, clayborg, abidh

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

llvm-svn: 233112
2015-03-24 20:59:38 +00:00
Hafiz Abid Qadeer 112b2622df Remove redundant code from lldb-mi.
After removing the ability of using lldb-mi as 'lldb', a lot of code has become redundant. This commit removes some of that code.
Note: Some files are being removed. The cmake file has been updated. Please update xcode project accordingly.

llvm-svn: 233083
2015-03-24 14:07:25 +00:00
Ilia K acf28bea84 Turn off 'quit' confirmation in lldb-mi
Summary:
# Turn off interpreter.prompt-on-quit on startup (MI)
# Add CommandInterpreter::SetPromptOnQuit
# Add SBCommandInterpreter::GetPromptOnQuit/SetPromptOnQuit

All tests pass on OS X.

Test Plan:
```
-file-exec-and-symbols ~/p/hello
-break-insert -f main
-exec-run
-interpreter-exec console quit
```

Reviewers: abidh, clayborg

Reviewed By: abidh, clayborg

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 233034
2015-03-23 22:45:13 +00:00
Ilia K fd77f8cf80 Add target-async option in -gdb-set command (MI)
llvm-svn: 233018
2015-03-23 20:49:51 +00:00
Ilia K e771b59017 Fix/Add comments in CMICmdCmdGdbSet (MI)
llvm-svn: 233017
2015-03-23 20:46:10 +00:00
Ilia K af10e1ce6f Fix handling of CommandInterpreter's events in lldb-mi
Summary:
Previously lldb-mi contains a stub for that but it didn't work and all CommanInterpreter's events were ignored.
This commit adds a handling of CommandInterpreter's events in lldb-mi.

Steps:
# Fix CMICmnLLDBDebugger::InitSBListener
# Add SBCommandInterpreter::EventIsCommandInterpreterEvent
# Exit on lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived

All tests pass on OS X.

In further we can remove "quit" hack in lldb-mi.

Test Plan:
# Create start_script file:
```
target create ~/p/hello
b main
r
quit
```

# Run lldb-mi --interpreter
# Execute start_script file by following command:
```
-interpreter-exec console "command source start_script"
```

Log:
```
$ bin/lldb-mi --interpreter
(gdb)
-interpreter-exec console "command source start_script"
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) b main
Breakpoint 1: where = hello`main + 29 at hello.cpp:12, address = 0x0000000100000e2d
(lldb) r
Process 1582 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) quit
^done
(gdb)
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
...
=shlibs-added,shlib-info=[num="132",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff91705000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff91705000"]
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x100000e2d",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5fbffc88"}],file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="12"},thread-id="1",stopped-threads="all"
(gdb)<press Enter>



MI: Program exited OK
```

Reviewers: abidh, clayborg

Reviewed By: abidh

Subscribers: jingham, lldb-commits, clayborg, abidh

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

llvm-svn: 232891
2015-03-21 10:53:37 +00:00
Zachary Turner 3a00691f3d Move LLDB initialization/shutdown to Initialization.
This creates a new top-level folder called Initialization which
is intended to hold code specific to LLDB system initialization.
Currently this holds the Initialize() and Terminate() functions,
as well as the fatal error handler.

This provides a means to break the massive dependency cycle which
is caused by the fact that Debugger depends on Initialize and
Terminate which then depends on the entire LLDB project.  With
this structure, it will be possible for applications to invoke
lldb_private::Initialize() directly, and have that invoke
Debugger::Initialize.

llvm-svn: 232768
2015-03-19 22:00:21 +00:00
Ilia K bb7002d751 Remove IDE_MI_APP_EXIT_OK msg on exit (MI)
Summary: Remove IDE_MI_APP_EXIT_OK msg on exit (MI)

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 232738
2015-03-19 17:40:15 +00:00
Ilia K 7690fc5428 expose 64 bit addresses through MI
Summary:
This changes all reporting of addresses from lldb-mi to be 64 bit capable. There could have been cases where a 64 bit address was getting truncated to 32 bit format.

Patch from chuckr@microsoft.com

Reviewers: abidh, ChuckR

Reviewed By: abidh

Subscribers: paulmaybee, ki.stfu, zturner, lldb-commits

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

llvm-svn: 232736
2015-03-19 17:27:23 +00:00
Ilia K 4c5a0b40de Fix memory allocating inside signal handler (MI)
Summary:
This patch fixes a memory allocating inside signal handler.

This bug was found by @vharron:
> Hi all,
> 
> I noticed these thread sanitizer warnings while running lldb-mi tests on
> Linux.
> 
> WARNING: ThreadSanitizer: signal-unsafe call inside of a signal (pid=39721)
> 
>     #0 operator new(unsigned long) <null>:0 (lldb-mi-3.7.0+0x000000092b9d)
> 
>     #1 std::string::_Rep::_S_create(unsigned long, unsigned long,
> std::allocator<char> const&) <null>:0 (libstdc++.so.6+0x0000000ba3b8)
> 
>     #2 CMICmnResources::GetStringFromResource(unsigned int, CMIUtilString&)
> const
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MICmnResources.cpp:434
> (lldb-mi-3.7.0+0x00000014ddd8)
> 
>     #3 CMICmnResources::GetString(unsigned int) const
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MICmnResources.cpp:371
> (lldb-mi-3.7.0+0x00000014db81)
> 
>     #4 sigwinch_handler(int)
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriverMain.cpp:99
> (lldb-mi-3.7.0+0x0000001589ff)
> 
>     #5 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, int,
> my_siginfo_t*, void*) tsan_interceptors.o:0 (lldb-mi-3.7.0+0x00000009f25f)
> 
>     #6 void std::this_thread::sleep_for<long, std::ratio<1l, 1000l>
> >(std::chrono::duration<long, std::ratio<1l, 1000l> > const&)
> /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/thread:279
> (lldb-mi-3.7.0+0x00000013243e)
> 
>     #7 CMIDriver::ReadStdinLineQueue()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriver.cpp:710
> (lldb-mi-3.7.0+0x000000155e62)
> 
>     #8 CMIDriver::DoMainLoop()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriver.cpp:631
> (lldb-mi-3.7.0+0x000000155d37)
> 
>     #9 non-virtual thunk to CMIDriver::DoMainLoop()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriver.cpp:648
> (lldb-mi-3.7.0+0x000000155fbd)
> 
>     #10 CMIDriverMgr::DriverMainLoop()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriverMgr.cpp:340
> (lldb-mi-3.7.0+0x000000159ee6)
> 
>     #11 main
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriverMain.cpp:364
> (lldb-mi-3.7.0+0x000000158f60)

Reviewers: vharron, abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh, vharron

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

llvm-svn: 232735
2015-03-19 17:17:26 +00:00
Ilia K 641f027d82 Fix -break-insert for system functions (MI)
Summary:
# Fix -break-insert for system functions
# Fix MiExecTestCase to use -break-insert instead of CLI "b"
# Improve MiBreakTestCase: now it uses printf() instead of in-house function

All tests pass on OS X.

Test Plan:
```
$ bin/lldb-mi --interpreter
(gdb)
-file-exec-and-symbols ~/p/hello
^done
(gdb)
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
-break-insert -f printf
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"}
(gdb)
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"}
-exec-run
^running
...
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x7fff8a476910",func="printf",args=[],file="??",fullname="??",line="-1"},thread-id="1",stopped-threads="all"
(gdb)
```

Reviewers: abidh, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 232734
2015-03-19 17:13:20 +00:00
Ilia K aa27aadb14 Fix double (gdb) prompt when command doesn't exist
llvm-svn: 232715
2015-03-19 09:17:06 +00:00
Ilia K 30a4ba1721 Fix error handling in CMIDriver::DoMainLoop after r215223 (MI)
llvm-svn: 232713
2015-03-19 08:54:17 +00:00
Zachary Turner 3294de270e Move lldb-log.cpp to core/Logging.cpp
So that we don't have to update every single #include in the entire
codebase to #include this new header (which used to get included by
lldb-private-log.h, we automatically #include "Logging.h" from
within "Log.h".

llvm-svn: 232653
2015-03-18 18:20:42 +00:00
Ilia K 5d8b145d70 Fix comment in tools/lldb-mi/MIDriver.cpp
llvm-svn: 232633
2015-03-18 13:08:52 +00:00
Hafiz Abid Qadeer 4a7baeab14 Make lldb-mi handle only MI commands
Summary:
Previously lldb-mi can also act as a driver like normal lldb. It needed a lot
of redundant code in the lldb-mi for that. I think that if a user wants command
line lldb driver then he/she should use the lldb for it. This change will cleanup
the code a lot. When this change goes in, it will allow us to remove some more
redundant code too.

All tests pass on Linux. Did some sanity testing on command line and with eclipse.

Reviewers: ki.stfu

Reviewed By: ki.stfu

Subscribers: lldb-commits

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

llvm-svn: 232621
2015-03-18 10:07:46 +00:00
Jason Molenda 1bffc64a46 Build fix for building debugserver for ios.
llvm-svn: 232563
2015-03-17 23:16:42 +00:00
Hafiz Abid Qadeer 7658b2be16 Cleanup the MIReadMe.txt after the recent changes in lldb-mi.
This commit removed the redundant and out of date stuff from the file.

llvm-svn: 232477
2015-03-17 14:12:03 +00:00
Hafiz Abid Qadeer a40780e36c Remove redundant comments from lldb-mi source files.
Most of lldb-mi files have comments about environement, copyright etc which were neither needed nor uptodate.
This commit removes those comments.

llvm-svn: 232396
2015-03-16 18:18:18 +00:00
Hafiz Abid Qadeer 943483f451 Check that RestartedFromEvent flag before processing the state changed event.
Not checking for this flags caused lldb-mi to issue stop notification when target
has started running again. It also tried to get stack when target was running and
this caused randon failure.

Approved in http://lists.cs.uiuc.edu/pipermail/lldb-dev/2015-March/006953.html

llvm-svn: 232370
2015-03-16 11:47:24 +00:00
Hafiz Abid Qadeer 5f86f216c3 Add -p and -r options to lldb-mi command -file-exec-file-and-symbols to support iOS debugging on macOS.
The patch adds 2 options which are not present in the GDB MI. Those have been described in MIExtensions.txt.

Patch from Chuck Ries.

llvm-svn: 232077
2015-03-12 18:35:54 +00:00
Ilia K 02e55ef3fb Add low-frame/high-frame options to -stack-list-arguments (MI)
Summary:
Add low-frame/high-frame options to -stack-list-arguments

All tests pass on OS X.

Reviewers: clayborg, abidh

Reviewed By: abidh

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 232048
2015-03-12 15:35:58 +00:00
Hafiz Abid Qadeer d5d496a55d Removed an unused global variable.
This variable "g_debugger_name" is not used anywhere. It also causes a warning.
I was first going to change its type to fix the warning then noticed that it 
is not being used. So removing it.

Committed as Obvious. 

llvm-svn: 232043
2015-03-12 14:54:44 +00:00
Ilia K 299819c458 Fix PATH_MAX definition after remarks in r231917 (MI)
llvm-svn: 232008
2015-03-12 04:18:47 +00:00
Robert Flack 5f4b6c7c9e Initialize ProcessGDBRemoteLog for LLGS to fix remote platform logging
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
2015-03-11 21:14:22 +00:00
Ilia K 654e1c2c1a Fix build on Windows (PATH_MAX was undefined) after r231858
llvm-svn: 231917
2015-03-11 11:24:10 +00:00
Ilia K eb2c19a549 Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}

All tests pass on OS X.

Reviewers: abidh, zturner, jingham, clayborg

Reviewed By: clayborg

Subscribers: jingham, zturner, lldb-commits, clayborg, abidh

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

llvm-svn: 231858
2015-03-10 21:59:55 +00:00
Robert Flack f196c93172 Add Debugger::InitializeForLLGS to allow ref counted LLGS initialization.
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
2015-03-10 18:07:47 +00:00
Greg Clayton ee2ed52584 Fix debugserver warnings on MacOSX.
llvm-svn: 231692
2015-03-09 19:45:23 +00:00
Ilia K 6ec9ba5a97 Fix -var-create and -var-update (MI)
Summary:
This patch includes:
* Fix -var-create command for global/static variables
* Fix -var-update command: remove m_strValueName/m_eVarInfoFormat/m_bValueChanged{Array,Composite,Normal}Type;  clean CMICmdCmdVarUpdate::Execute and CMICmdCmdVarUpdate::Acknowledge; improve CMICmdCmdVarUpdate::MIFormResponse; Complete the value after -var-create using the CMICmdCmdVarCreate::CompleteSBValue to get SBValue::GetValueDidChange work.
* Add non-constant version of CMICmnLLDBDebugSessionInfoVarObj::GetValue
* Add MiVarTestCase.test_lldbmi_var_update test

All tests pass on OS X.

Reviewers: abidh, emaste, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, emaste, clayborg, abidh

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

llvm-svn: 231525
2015-03-06 22:25:12 +00:00
Tamas Berghammer 6ad63744b3 Initialize ProcessPOSIXLog by NativeProcessLinux
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
2015-03-06 15:47:23 +00:00
Robert Flack 8cc4cf178c Rename test/tools/lldb-gdbserver to test/tools/lldb-server
As requested in http://reviews.llvm.org/D7545 this change moves test/tools/lldb-gdbserver to test/tools/lldb-server ot match the name of the target being tested.

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

llvm-svn: 231479
2015-03-06 14:36:33 +00:00
Jason Molenda 07e51cc72d Bump major vers # in xcode project file from 330 to 340.
llvm-svn: 231441
2015-03-06 00:45:01 +00:00
Pavel Labath aa1ae6f660 Correctly quote arguments in LLDB driver
Summary:
LLDB driver was simply tacking quotes around the strings in lldb commands, hoping that will work.
This changes it to properly escape quotes and backslashes.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 231394
2015-03-05 19:17:56 +00:00
Jim Ingham cfae0b23b9 Fix a thinko in the case where we return a launch error with no error
string.  Return "<unknown error>" rather than the empty launch error...

<rdar://problem/20026469>

llvm-svn: 231287
2015-03-04 21:28:55 +00:00
Ilia K 53d33368c4 Added long 'print-values' option for var-update MI command.
Summary:
The -var-update MI command should take the same print-values options as var-list children, however currently only the integer versions are supported.
Added --no-values, --all-values, and --simple-values long options. 

See:
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html#GDB_002fMI-Variable-Objects

Patch from ewan@codeplay.com

Reviewers: EwanCrawford

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 231233
2015-03-04 11:21:18 +00:00
Ilia K c6c716ac9d Allow to pass an executable file via lldb-mi arguments (MI)
Summary:
# Allow to pass an executable file via lldb-mi arguments
# Add tests
# Fix (gdb) prompt in CMIDriver::LocalDebugSessionStartupExecuteCommands
# Fix prompt in CMIDriver::InterpretCommandThisDriver: use the lldb-mi prompt instead of a hard-coded value.

All tests pass on OS X.

Reviewers: abidh, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 231070
2015-03-03 15:14:32 +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
Ilia K f1115fe0c5 Rename CMIDriver::LocalDebugSessionStartupInjectCommands to CMIDriver::LocalDebugSessionStartupExecuteCommands after r230003
llvm-svn: 230944
2015-03-02 10:58:02 +00:00
Ilia K 69b95f49f1 Fix handling of double quotes (MI)
Summary:
* Clean CMICmdArgValString::Validate: now it's based on CMIUtilString::SplitConsiderQuotes method:
A bit of introduction:
# Command line is wrapped into CMICmdArgContext.
# CMICmdArgSet is a set of arguments to be parsed. This class contains CMICmdArgContext as a private member.
# MI command is class which is inhereted from CMICmdBase. It contains CMICmdArgSet as a private member.

When command is executed CMICmdBase::ParseArgs() is called. This method adds args for parsing using CMICmdArgSet::Add(). Then CMICmdBase::ParseValidateCmdOptions() is called, which calls CMICmdArgSet::Validate(). Then it gets a number of arguments (using SplitConsiderQuotes().array_length) and for each arguments registered in ParseArgs() tries to validate it using CMICmdArgValBase::Validate(). Every user commands parses this string again (first time it was made in SplitConsiderQuotes) and in case of CMICmdArgValString it was made incorrectly. It searches the first and last quotes (but it should be first and next after first). Besides, it was splitted into 4 cases. 
I'm just using SplitConsiderQuotes directly, and I don't split them by hand again. 

Actually, I think we should do so in every CMICmdArgVal_XXX::Validate() method.

* Enable MiInterpreterExecTestCase.test_lldbmi_target_create test
* Fix MiExecTestCase.test_lldbmi_exec_arguments_set test

All tests pass on OS X.

Reviewers: abidh, emaste, zturner, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, zturner, emaste, clayborg, abidh

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

llvm-svn: 230654
2015-02-26 18:21:22 +00:00
Ilia K da86749a92 Fix process's output to stdout/stderr (MI)
Summary:
* Add CMIUtilString::Escape/Unescape methods (MI)
* Fix process's output to stdout/stderr (MI):
lldb-mi escapes process's output to show it in the following format:
```
~"..."
```

But previously not all characters were escaped by CMICmnLLDBDebuggerHandleEvents::ConvertPrintfCtrlCodeToString and output of
```
printf("'\n` - it's \\n\x12\"\\\"")
```
looked like:
```
~"'\r\n` - it's \n"\""
```

This patch fixes it by using CMIUtilString::Escape method and now it looks like:
```
~"'\r\n` - it's \\n\x12\"\\\""
```

Reviewers: abidh, emaste, clayborg

Reviewed By: clayborg

Subscribers: zturner, lldb-commits, emaste, clayborg, abidh

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

llvm-svn: 230652
2015-02-26 18:14:30 +00:00
Ilia K b791226136 Fix comments in tools/lldb-mi/MIDriver.h
llvm-svn: 230648
2015-02-26 17:59:44 +00:00
Ilia K 48fd3f62b9 Fix usage of shared_ptr for array which may cause a undefined behaviour (use unique_ptr instead)
llvm-svn: 230630
2015-02-26 13:28:58 +00:00
Ilia K 4dc4ed0a2a Add extra acceptable characters to CMICmdArgValFile (MI)
Summary:
Improve CMICmdArgValFile::IsValidChars to accept extra characters that can be in file name:
```
.'\"`@#$%^&*()_+-={}[]| 
```

Enable MiSyntaxTestCase.test_lldbmi_specialchars test.

All test pass on OS X.

Reviewers: abidh, emaste, zturner, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, zturner, emaste, clayborg, abidh

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

llvm-svn: 230468
2015-02-25 06:34:05 +00:00
Zachary Turner d64412beb8 [CMake] Clean up lldb-mi CMakeLists.txt.
It was maintaining two huge file lists that are identical except
for 1 file.  Make this work the proper way.

llvm-svn: 230398
2015-02-24 23:36:12 +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
Hafiz Abid Qadeer 04b1b5dc9d Remove redundant code from lldb-mi.
Summary:
After recent changes, some code has become redundant. This revision tries to remove
the un-used code and tidy up the rest.

Following 4 files have been removed. I have updated CMake files and checked that it builds
fine on Linux and Windows. Can somebody update the xcode related file accordingly?

tools/lldb-mi/MICmnStreamStdinLinux.cpp
tools/lldb-mi/MICmnStreamStdinLinux.h
tools/lldb-mi/MICmnStreamStdinWindows.cpp
tools/lldb-mi/MICmnStreamStdinWindows.h

Reviewers: clayborg, ki.stfu

Reviewed By: clayborg, ki.stfu

Subscribers: lldb-commits

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

llvm-svn: 230345
2015-02-24 17:08:20 +00:00
Ilia K 2f85244553 Add -exec-abort command (MI); Don't exit on eStateExited
Summary:
Add -exec-abort command + test.

Also, I had fixed an error, when lldb-mi exits on eStateExited. With current patch we can re-run target:
```
-file-exec-and-symbols hello
^done
-exec-run
^running
*stopped,reason="breakpoint-hit"...
-exec-abort
^done
*stopped,reason="exited-normally"...    <- program exits
-exec-run                               <- run again
^running
*stopped,reason="breakpoint-hit"...
```

All tests pass on OS X.

Reviewers: zturner, emaste, abidh, clayborg

Reviewed By: abidh, clayborg

Subscribers: lldb-commits, emaste, zturner, clayborg, abidh

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

llvm-svn: 230321
2015-02-24 10:40:45 +00:00
Chaoren Lin e4bb0b3551 Newline after usage string for lldb-server.
llvm-svn: 230266
2015-02-23 21:48:42 +00:00
Hafiz Abid Qadeer cf0698987b Fix a problem where lldb-mi would not stop the debuggee after -exec-interrupt command.
Summary:
This revision fixes a problem where lldb-mi would not stop the execution after exec-interrupt call.
On Linux, SIGSTOP is used to stop the debuggee process. LLDB stopped the debuggee alright. But when
lldb-mi received the notification of stopping with reason as SIGSTOP, it would resume the process.
This was heppening in CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal. This function aslo
used hard coded numbers for signal istead of symbolic names.

This revision changes code to treat SIGSTOP reason as SIGINT. Also used symbolic names for signals
instead of numbers.

Reviewers: ki.stfu, clayborg

Reviewed By: ki.stfu, clayborg

Subscribers: zturner, lldb-commits

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

llvm-svn: 230237
2015-02-23 18:27:17 +00:00
Greg Clayton ee1b391275 Don't use:
#include <lldb/API/*>"

Please use:

#include "lldb/API/*"

llvm-svn: 230106
2015-02-21 00:39:13 +00:00
Ilia K b6f705b6ed Minor changes after r229901: move the CMICmdCmdStackSelectFrame to the end of header file
llvm-svn: 230028
2015-02-20 17:56:05 +00:00
Ilia K c12d88dc8f Add -symbol-list-lines command (MI)
Summary:
Add -symbol-list-lines command + test.

All test passed on OS X.

Reviewers: emaste, abidh, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, abidh, emaste

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

llvm-svn: 230008
2015-02-20 13:07:41 +00:00
Hafiz Abid Qadeer 6d87a9c09e Reduce number of threads in lldb-mi.
LLDB-mi have 3 threads.

1. Wait for input.
2. Process commands.
3. Process events.
This revision merges 1 & 2. Same thread waits on input and then process the
command. This way, no synchronization is needed between first and 2nd. Also it is
easy to check when to exit.

A lot of code will redundant and will be cleaned up gradually.

All lldb-mi tests pass with gcc and clang as test compiler. Also did minimal testing
on command line and works ok. The "quit" and "-gdb-exit" command close the application
without needing any further return.

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

llvm-svn: 230003
2015-02-20 10:20:05 +00:00
Ilia K db9050fd49 Add -stack-select-frame command (MI)
Summary:
Add -stack-select-frame command + test.

All tests pass on OS X.

Reviewers: abidh, emaste, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, emaste, clayborg, abidh

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

llvm-svn: 229901
2015-02-19 19:26:52 +00:00
Ilia K be5680f985 Fix usage of m_bThreadInvalid in -thread-info (MI)
llvm-svn: 229868
2015-02-19 16:33:16 +00:00
Ilia K b7bc561ac2 Add -stack-info-frame command (MI)
Summary:
Add -stack-info-frame command + test.

All tests pass on OS X.

Reviewers: emaste, clayborg, abidh

Reviewed By: abidh

Subscribers: lldb-commits, clayborg, emaste, abidh

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

llvm-svn: 229857
2015-02-19 15:14:17 +00:00
Tamas Berghammer 62ef8a5a88 Add missing exports file and remove unused ones
These files required by the excode project

Patch from: flackr <flackr@google.com>

llvm-svn: 229691
2015-02-18 16:14:02 +00:00
Tamas Berghammer c2c3d7185d Merge lldb-platform and lldb-gdbserver into a single binary
This commit merges lldb-platform and lldb-gdbserver into a single binary
of the same size as each of the previous individual binaries. Execution
mode is controlled by the first argument being either platform or
gdbserver.

Patch from: flackr <flackr@google.com>

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

llvm-svn: 229683
2015-02-18 15:39:41 +00:00
Hafiz Abid Qadeer 5de6192e12 Fix line crossing 80 column border.
llvm-svn: 229681
2015-02-18 15:25:25 +00:00
Hafiz Abid Qadeer 019ea8a7c0 Fix some warnings in MSVC build.
Platform.h was causing soem warning due to multiple defined maros.
It already has a define that excludes the singal.h but that was not being
used at correct place. It has been fixed now.

Tested by building on Windows(MSVC) and Linux(gcc).

llvm-svn: 229664
2015-02-18 11:12:11 +00:00
Hafiz Abid Qadeer dfbe605985 Fix a typo.
llvm-svn: 229663
2015-02-18 11:04:17 +00:00
Ilia K bb0d5aba8e Fix argdumper build in cmake (OS X) after r228636
Previos version of this patch (see r229148) contained two errors:
* make_symlink_darwin_debug passes 2 arguments into make_symlink, but it required 4 arguments (was fixed by r229159)
* make_symlink doesn't work on OS X

As a quick fix, the r229148 and the r229159 were reverted. Now these errors are fixed.

Summary:
This patch fixes the following tests on OS X:

```
  FAIL: test_with_dsym (TestLaunchWithGlob.LaunchWithGlobTestCase)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 456, in wrapper
      return func(self, *args, **kwargs)
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 21, in test_with_dsym
      self.do_test ()
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 42, in do_test
      self.runCmd("process launch -G true -w %s -- fi*.tx?" % (os.getcwd()))
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 1953, in runCmd
      msg if msg else CMD_MSG(cmd))
  AssertionError: False is not True : Command 'process launch -G true -w /Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob -- fi*.tx?' returns successfully
  Config=x86_64-clang
  ======================================================================
  FAIL: test_with_dwarf (TestLaunchWithGlob.LaunchWithGlobTestCase)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 473, in wrapper
      return func(self, *args, **kwargs)
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 28, in test_with_dwarf
      self.do_test ()
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 42, in do_test
      self.runCmd("process launch -G true -w %s -- fi*.tx?" % (os.getcwd()))
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 1953, in runCmd
      msg if msg else CMD_MSG(cmd))
  AssertionError: False is not True : Command 'process launch -G true -w /Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob -- fi*.tx?' returns successfully
```

Reviewers: epertoso, emaste, abidh, clayborg, zturner

Reviewed By: clayborg

Subscribers: abidh, lldb-commits, emaste, epertoso, zturner, clayborg

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

llvm-svn: 229517
2015-02-17 18:25:27 +00:00
Ilia K a7e79c1b44 Fix build: revert r229148 "Fix argdumper build in cmake (OS X) after r228636" and r229159 "Fix build: make_symlink_darwin_debug passes 2 arguments into make_symlink, but it requires 4 arguments"
llvm-svn: 229166
2015-02-13 22:30:11 +00:00
Ilia K 14a92711ce Fix argdumper build in cmake (OS X) after r228636
Summary:
This patch fixes the following tests on OS X:

```
  FAIL: test_with_dsym (TestLaunchWithGlob.LaunchWithGlobTestCase)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 456, in wrapper
      return func(self, *args, **kwargs)
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 21, in test_with_dsym
      self.do_test ()
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 42, in do_test
      self.runCmd("process launch -G true -w %s -- fi*.tx?" % (os.getcwd()))
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 1953, in runCmd
      msg if msg else CMD_MSG(cmd))
  AssertionError: False is not True : Command 'process launch -G true -w /Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob -- fi*.tx?' returns successfully
  Config=x86_64-clang
  ======================================================================
  FAIL: test_with_dwarf (TestLaunchWithGlob.LaunchWithGlobTestCase)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 473, in wrapper
      return func(self, *args, **kwargs)
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 28, in test_with_dwarf
      self.do_test ()
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob/TestLaunchWithGlob.py", line 42, in do_test
      self.runCmd("process launch -G true -w %s -- fi*.tx?" % (os.getcwd()))
    File "/Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/lldbtest.py", line 1953, in runCmd
      msg if msg else CMD_MSG(cmd))
  AssertionError: False is not True : Command 'process launch -G true -w /Users/testuser/build/workspace/LLDB_master_release_OSX/llvm_master/tools/lldb/test/functionalities/launch_with_glob -- fi*.tx?' returns successfully
```

Reviewers: epertoso, emaste, abidh, clayborg, zturner

Reviewed By: clayborg

Subscribers: abidh, lldb-commits, emaste, epertoso, zturner, clayborg

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

llvm-svn: 229148
2015-02-13 20:28:27 +00:00
Ilia K 576a4a7ea4 Fix test_lldbmi_prompt test by enabling ShowPrompt in CMICmnStreamStdin by default
llvm-svn: 229137
2015-02-13 19:11:39 +00:00
Ilia K b4a110f051 Fix -data-read-memory-bytes command (MI)
Summary:
* Add IsHexadecimalNumber method to CMIUtilString (MI)
* Add number format (dec,hex,auto) to CMICmdArgValNumber (MI)
* Fix -data-read-memory-bytes to pass address in hex format (MI)
* Fix output begin/end/offset fields format in -data-read-memory-bytes
* Fix CMICmdArgValNumber::ExtractNumber to extract 64bit value
* + tests

All tests passed on OS X

Reviewers: abidh, zturner, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, zturner, clayborg, abidh

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

llvm-svn: 229132
2015-02-13 18:42:25 +00:00
Ilia K a4897fe79c Add missing prompt when command doesn't exist (MI)
It fixes the following example:
```
$ bin/lldb-mi --interpreter
(gdb)
-not-found
^error,msg="Driver. Received command '-not-found'. It was not handled. Command 'not-found' not in Command Factory"
-not-found
^error,msg="Driver. Received command '-not-found'. It was not handled. Command 'not-found' not in Command Factory"
```

After the fix it looks like:
```
$ bin/lldb-mi --interpreter
-not-found
^error,msg="Driver. Received command '-not-found'. It was not handled. Command 'not-found' not in Command Factory"
(gdb)
-not-dounf
^error,msg="Driver. Received command '-not-dounf'. It was not handled. Command 'not-dounf' not in Command Factory"
(gdb)
```

llvm-svn: 229131
2015-02-13 18:36:48 +00:00
Ilia K 8f37ca56d6 Add -exec-arguments command
Summary:
This patch adds -exec-arguments command for lldb-mi. -exec-arguments command allows to specify arguments for executable file in MI mode. Also it contains tests for that command.

Btw, new added files was formatted by clang-format.

Reviewers: abidh, zturner, clayborg

Reviewed By: clayborg

Subscribers: zturner, emaste, clayborg, jingham, lldb-commits

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

llvm-svn: 229110
2015-02-13 14:31:06 +00:00
Hafiz Abid Qadeer 095b128671 Fix for http://llvm.org/bugs/show_bug.cgi?id=21744
GetVariableInfo () collected the values of the variable in a list. But it also
tried to generate the name/value pairs for children. This caused generation of
a wrong value string for may items. This function has been fixed to put value in
the list only.

The handling of --print-value related option has been moved to caller.

GetVariableInfo2 and MIResponseFormVariableInfo3 have been removed. They were
almost the duplicate of functions of similar names. I dont see any difference in
the output of -stack-list-locals and -stack-list-arguments. So these functions
just seemed unnecessary.

Char variable was being printed as a string which caused garbage output. This has
been fixed.

Some misc. cleanup.

Test cases have been added that check -stack-list-locals for struct, array and
pointers. Modified other tests which depended on hard coded line numbers.

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

llvm-svn: 229102
2015-02-13 11:53:50 +00:00
Tamas Berghammer e13c2731ba Separate monolithic GDBRemoteCommunicationServer class into 4 part
GDBRemoteCommunicationServer: Basic packet handling, handler registration
LLDBCommonPacketHandler: Common packet handling for lldb-platform and lldb-gdbserver
LLDBPlatformPacketHandler: lldb-platform specific packet handling
LLGSPacketHandler: lldb-gdbserver specific packet handling

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

llvm-svn: 228823
2015-02-11 10:29:30 +00:00
Ilia K 83bdf32cf4 Fix segfault notification in lldb-mi
Summary:
This patch adds system exception handling in lldb-mi + tests.

All tests pass on OS X.

Reviewers: zturner, abidh, clayborg

Reviewed By: clayborg

Subscribers: emaste, lldb-commits, zturner, clayborg, abidh

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

llvm-svn: 228803
2015-02-11 04:58:41 +00:00
Ilia K 98bdc6418f Fix CMIUtilString::SplitConsiderQuotes (MI)
Summary:
This method doesn't work properly. Here is an example:
```
CMIUtilString test("\"hello\" \"\\\" world \\\" !\"");
CMIUtilString::VecString_t res;
test.SplitConsiderQuotes(" ", res);
```

Before this patch the result was as following:
```
(lldb) print res
(CMIUtilString::VecString_t) $1 = size=4 {
  [0] = (std::__1::string = "\"hello\"")
  [1] = (std::__1::string = "\"\\\"")
  [2] = (std::__1::string = "world")
  [3] = (std::__1::string = "\\\" !\"")
}
```

This patch fixes that error and now it looks like following:
```
(lldb) print res
(CMIUtilString::VecString_t) $1 = size=2 {
  [0] = (std::__1::string = "\"hello\"")
  [1] = (std::__1::string = "\"\\\" world \\\" !\"")
}
```

Reviewers: abidh, emaste, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, emaste, clayborg, abidh

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

llvm-svn: 228802
2015-02-11 04:52:54 +00:00
Hafiz Abid Qadeer df70d8460e Fix build on Windows which was broken by a recent commit.
This file MICmnStreamStdinLinux.cpp is wrongly added in the windows build.
It has no use there. CMakeList.txt for lldb-mi needs to be re-factored to
include the right file for each build. This is quick fix to un-break the build.

llvm-svn: 228714
2015-02-10 18:12:44 +00:00
Sylvestre Ledru 57958b5d35 Fix the LLDB build under Debian Kfreebsd
Summary:
I don't know if there is a better way for the change in source/Host/freebsd/ThisThread.cpp


Reviewers: emaste

Subscribers: hansw, emaste, lldb-commits

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

llvm-svn: 228710
2015-02-10 17:16:13 +00:00
Hafiz Abid Qadeer e73e82f2be Fix multiple problems of lldb-mi blocking on input monitoring and needing a return.
Summary:
One of the problem is reported here.
http://llvm.org/bugs/show_bug.cgi?id=22411

A fix was committed for this problem that works only for OSX. This revision
extends that fix to other system. The select system call has some limitation with
multi-threaded application which have been addresses here.

LLDB-mi exits if quit command is given but needs an extra retur if -gdb-exit is
given. That issue has also been addressed.

Reviewers: ki.stfu, emaste

Reviewed By: ki.stfu

Subscribers: lldb-commits

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

llvm-svn: 228709
2015-02-10 17:10:39 +00:00
Ilia K c4f7fdf571 Add thread-id field in *stopped notification (MI)
Summary:
Add thread-id field in *stopped notification (MI) + tests

All tests pass on OS X

Reviewers: zturner, clayborg, abidh

Reviewed By: clayborg

Subscribers: lldb-commits, zturner, clayborg, abidh

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

llvm-svn: 228681
2015-02-10 12:02:03 +00:00
Enrico Granata 89fdc9a61e Add a JSON producer to LLDB - this is a set of classes that encapsulate JSON objects and allow you to write them to a Stream for subsequent processing
Using this JSON producer, write a little tool that expands its own command-line arguments and dumps them to stdout as a JSON array

llvm-svn: 228636
2015-02-10 00:30:07 +00:00
Hafiz Abid Qadeer dc0e4915b0 Fix test case for data-disassemble instruction in lldb-mi.
Previously the offset field showed the offset from the section base.
I have fixed it so that first disassembled instruction has offset of 0.
Also made a little modification in the test case to match the output coming
form the lldb-mi.

llvm-svn: 228577
2015-02-09 14:34:12 +00:00
Hafiz Abid Qadeer 93ad6b31ec Fix a handling of full path in break-insert.
For some time, eclipse (CDT) uses full path of the file in break-insert command
when putting breakpoint on a source line. On windows, a typical command looks
like the following.
56-break-insert -f F:\\work\\ws\\test\\main.c:49

Current implementation in lldb-mi have problem in 2 ways.
1. It was assuming that there will be only one : in the path which is wrong if full
path is supplied.
2. CDT sends out path with double backslashes in windows which gives error on 
resolution.

Fixed the : issue in lldb-mi. Changed FileSpec::Normalize to make sure that it
handles the path with \\ correctly. Added test cases to check for full path in
both lldb-mi and lldb. Also added a test case to check SBFileSpec with double
slashes.

llvm-svn: 228538
2015-02-08 20:21:08 +00:00
Ilia K 56e271568f Fix darwin-debug installation in cmake (OS X)
Summary: Fix darwin-debug installation in cmake (OS X)

Reviewers: zturner, clayborg

Subscribers: lldb-commits, zturner, clayborg

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

llvm-svn: 228416
2015-02-06 18:13:10 +00:00
Ilia K 761a7a4b67 Fix evaluation commands (MI)
Summary:
These changes include:
* Fix -var-create to be able use current frame '*' (MI)
* Fix print-values option in -var-update (MI)
* Fix 'variable doesn't exist' error in -var-show-attributes (MI)
* Mark print-values option as 'handled-by-cmd' in -var-update (MI)
* Fix SBValue::GetValueDidChange if value was changed
* Fix lldb-mi: -data-evaluate-expression shows undef vars. Before this fix -data-evaluate-expression perceives undefined variables as strings:
```
(gdb)
-data-evaluate-expression undef
^done,value="undef"
```
* Minor fix: -data-evaluate-expression uses IsUnknownValue()
* Enable MiEvaluateTestCase test

All test pass on OS X.

Reviewers: abidh, clayborg

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 228414
2015-02-06 18:10:30 +00:00
Ilia K 1a0ec0f15d Fix -stack-list-locals and -stack-list-arguments (MI)
Summary:
These changes include:
* Add eVariableInfoFormat argument for MIResponseFormVariableInfo{,2,3} and GetVariableInfo{,2} functions
* Fix -stack-list-locals and -stack-list-arguments: they ingored print-values
* Enable MiStackTestCase tests for -stack-list-xxx commands

All test pass on OS X.

Reviewers: abidh, clayborg

Reviewed By: abidh

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 228412
2015-02-06 18:08:24 +00:00
Ilia K b792be8e79 Fix -data-list-register-names/-data-disassemble, minor fix in -data-list-register-values (MI)
Summary:
* Fix -data-list-register-names command: previously it ignored regno arguments and always showed all registers
* Add 'size' field to -data-disassemble command: now we are able to get an instruction's size
* Minor fix in -data-list-register-value: fix comments/code style
* Enable all tests in MiDataTestCase
* Fix the GetRegister function that gets an register by its index

These changes were tested on OS X; all MiDataTestCase tests were passed.

Reviewers: clayborg, abidh

Reviewed By: clayborg, abidh

Subscribers: clayborg, abidh, lldb-commits

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

llvm-svn: 228393
2015-02-06 12:43:05 +00:00
Hafiz Abid Qadeer be86bb1e6a Give error on "-inferior-tty-set" command.
This command is not implemented yet. Giving error gives chance to clients to
handle it properly instead of falsely assuming the lldb-mi is supporting it.

llvm-svn: 228389
2015-02-06 11:06:41 +00:00
Ilia K 13f77bdc02 Test commit
llvm-svn: 228315
2015-02-05 17:25:01 +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 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
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
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
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
Hafiz Abid Qadeer 6a4ea636f3 Fix log file generation in lldb-mi.
When it runs, lldb-mi creates a log file. There is an option --noLog
to disable the creation but it does not work and you end up with log 
file. This happens as log is enabled in a few places in the code 
although it has been disabled by this option.

This commit tried to fix the problem in the following way.

Log file generation is disabled by default.
You can enable it by giving --log option. It is the only way to enable
it. Rest of the call have been removed.

So the code basically remove the calls that enable the log 
unconditionally and changes the option --noLog to --log.

llvm-svn: 227810
2015-02-02 17:08:25 +00:00
Hafiz Abid Qadeer 54ba124098 Make --thread argument optional for various commands.
Currently it was marked as mandatory for many commands. Although it
is recommended that fronends generate this argument, it is not
mandatory. GDB seems to treat it as optional too.

llvm-svn: 227798
2015-02-02 12:17:33 +00:00
Zachary Turner 0bf09687fb Fix darwin-debug build in cmake (OS X)
This patch fixes test_launch_in_terminal test which doesn't work
in OS X since the moment as it was added in r225284. The test fails
because Target::Launch returns the following error: "the darwin-debug
executable doesn't exist at
<output_dir>/lib/python2.7/site-packages/lldb/darwin-debug'".

Patch by Ilia K
Differential Revision: http://reviews.llvm.org/D7102

llvm-svn: 227096
2015-01-26 17:23:18 +00:00
Deepak Panickal 9d02a6699d Fix handling of data-disassemble command arguments.
llvm-svn: 226909
2015-01-23 14:31:56 +00:00
Jason Molenda 8122bb0e19 Two fixes for compact unwind decoding for frameless large-stack-size
i386/x86_64 functions.  The stack size was being multiplied by the
pointer size incorrectly.  The register permutation placeholders
(UNWIND_X86_REG_NONE) were decrementing the stack offset of the
saved registers when it should not have been.

<rdar://problem/19570035> 

llvm-svn: 226889
2015-01-23 01:02:32 +00:00
Vince Harron 1b5a74eea7 This patch gets remote-linux platform able to run processes
Make sure the selected platform is always used

Make sure that the host uses the connect://hostname to connect to both
the lldb-platform and the lldb-gdbserver rather than what the platform
reports as the hostname of the lldb-gdbserver

Make sure that lldb-platform uses the IP address on it's connection
back to the host instead of the hostname that the host sends to it
when launching lldb-gdbserver with the remote host information

Tested on OSX and Linux

llvm-svn: 226712
2015-01-21 22:42:49 +00:00
Greg Clayton 6746950645 Add missing case statement to quiet a compiler warning.
llvm-svn: 226617
2015-01-20 22:41:14 +00:00
Greg Clayton ee3626ec16 Added an Xcode target so we build the "lldb-mi" executable as part of the "desktop" and "desktop no xpc" targets.
Include paths were switched to be user include paths, if this breaks the linux build we will need to fix the Makefiles/cmake stuff.

<rdar://problem/19198581> 

llvm-svn: 226530
2015-01-20 00:04:26 +00:00
Jason Molenda 35c998718c Add comments explaining the unwind setup in
ABIMacOSX_i386::CreateFunctionEntryUnwindPlan, 
ABIMacOSX_i386::CreateDefaultUnwindPlan,
ABISysV_x86_64::CreateFunctionEntryUnwindPlan,
ABISysV_x86_64::CreateDefaultUnwindPlan

llvm-svn: 226347
2015-01-16 23:54:15 +00:00
Jason Molenda bcc5785958 Fixes to DNBArchImpl in debugserver to correctly get/set
the register state when debugging AArch32 programs (armv7
programs running on an armv8 processor).  Most notably,
there is no "fpscr" register in the register context -
there is an fpsr and an fpcr.

Also fix a bug where the floating point values could not
be written in armv7 processes.
<rdar://problem/18977767> 

llvm-svn: 226244
2015-01-16 02:31:35 +00:00
Vince Harron 5275aaa0cc Moved Args::StringToXIntYZ to StringConvert::ToXIntYZ
The refactor was motivated by some comments that Greg made
http://reviews.llvm.org/D6918

and also to break a dependency cascade that caused functions linking
in string->int conversion functions to pull in most of lldb

llvm-svn: 226199
2015-01-15 20:08:35 +00:00
Zachary Turner 4f1a39584e Don't try to link libpthread on Windows.
llvm-svn: 226053
2015-01-14 22:58:09 +00:00
Vince Harron 4d2857321d Fixes compilation/run error with BUILD_SHARED_LIBS=TRUE
BUILD_SHARED_LIBS=TRUE currently isn't working for Linux x86_64
This patch fixes the link errors and also some runtime errors

Test Plan:
CC=clang CXX=clang++ cmake -GNinja -DBUILD_SHARED_LIBS=TRUE -DCMAKE_LINKER=ld.gold -DCMAKE_BUILD_TYPE=Debug ../../llvm
ninja
ninja check-lldb

llvm-svn: 226039
2015-01-14 21:01:15 +00:00
Oleksiy Vyalov d5f8b6a6ca Extend PipePosix with support for named pipes/timeout-based IO and integrate it with GDBRemoteCommunication / lldb-gdbserver.
http://reviews.llvm.org/D6954

llvm-svn: 225849
2015-01-13 23:19:40 +00:00
Vince Harron 88f67808ae Fix for lldb-platform linking error on OSX/CMake
Tested on Linux and OSX

Submitted for Bob Campbell

llvm-svn: 225611
2015-01-11 18:38:25 +00:00
Vince Harron 878a2ce554 lldb-platform - static link all llvm dependencies
Differential Revision: http://reviews.llvm.org/D6797

lldb-gdbserver statically links all llvm dependencies. This allows
dead stripping code and reduces total binary size.

This change modifies lldb-plaform to static link llvm dependencies
like lldb-gdbserver.

llvm-svn: 225398
2015-01-07 21:35:07 +00:00
Greg Clayton ad7aa8147a More fixes to ensure if we are asked to launch a x86_64h process on darwin, that darwin-debug knows what to do and how to handle it.
llvm-svn: 225225
2015-01-06 00:25:18 +00:00
Greg Clayton a05569b0b3 Make sure x7 and x8 are treated as argument registers for arm64.
llvm-svn: 225193
2015-01-05 19:23:33 +00:00
Jason Molenda 0f479da711 Temporarily disable CompactUnwindInfo::GetCompactUnwindInfoForFunction.
The compact unwind importer is getting the wrong unwind info for one
case that I found.  I haven't been able to fix the problem tonight 
and I don't want to leave TOT behaving incorrectly, so just ignore
compact unwind until I can get to the bottom of this.

llvm-svn: 224321
2014-12-16 06:20:30 +00:00
Hafiz Abid Qadeer fcbc3cdf3c Replace ioctl with select to reduce processor usage by lldb-mi on OSX.
This saga started with a hang on OSX. 2 solutions were proposed.
1) 'select' based solution works ok on OSX but slows down test completion time
on Linux many times.
2) 'ioctl' base solution also works but it causes heavy processor usage on OSX
as reported by Ilia K.

But as the original hang did not occur on Linux so this commit re-introduces the
'select' in conditional code so that it only runs for OSX. There is no need for
this 'fix' to run on Linux.

Initial patch by Ilia K <ki.stfu@gmail.com>. A few changes were made by me. 

llvm-svn: 224258
2014-12-15 19:09:40 +00:00
Greg Clayton a97c4d2154 Handle thumb IT instructions correctly all the time.
The issue with Thumb IT (if/then) instructions is the IT instruction preceeds up to four instructions that are made conditional. If a breakpoint is placed on one of the conditional instructions, the instruction either needs to match the thumb opcode size (2 or 4 bytes) or a BKPT instruction needs to be used as these are always unconditional (even in a IT instruction). If BKPT instructions are used, then we might end up stopping on an instruction that won't get executed. So if we do stop at a BKPT instruction, we need to continue if the condition is not true.

When using the BKPT isntructions are easy in that you don't need to detect the size of the breakpoint that needs to be used when setting a breakpoint even in a thumb IT instruction. The bad part is you will now always stop at the opcode location and let LLDB determine if it should auto-continue. If the BKPT instruction is used, the BKPT that is used for ARM code should be something that also triggers the BKPT instruction in Thumb in case you set a breakpoint in the middle of code and the code is actually Thumb code. A value of 0xE120BE70 will work since the lower 16 bits being 0xBE70 happens to be a Thumb BKPT instruction. 

The alternative is to use trap or illegal instructions that the kernel will translate into breakpoint hits. On Mac this was 0xE7FFDEFE for ARM and 0xDEFE for Thumb. The darwin kernel currently doesn't recognize any 32 bit Thumb instruction as a instruction that will get turned into a breakpoint exception (EXC_BREAKPOINT), so we had to use the BKPT instruction on Mac. The linux kernel recognizes a 16 and a 32 bit instruction as valid thumb breakpoint opcodes. The benefit of using 16 or 32 bit instructions is you don't stop on opcodes in a IT block when the condition doesn't match. 

To further complicate things, single stepping on ARM is often implemented by modifying the BCR/BVR registers and setting the processor to stop when the PC is not equal to the current value. This means single stepping is another way the ARM target can stop on instructions that won't get executed.

This patch does the following:
1 - Fix the internal debugserver for Apple to use the BKPT instruction for ARM and Thumb
2 - Fix LLDB to catch when we stop in the middle of a Thumb IT instruction and continue if we stop at an instruction that won't execute
3 - Fixes this in a way that will work for any target on any platform as long as it is ARM/Thumb
4 - Adds a patch for ignoring conditions that don't match when in ARM mode (see below)

This patch also provides the code that implements the same thing for ARM instructions, though it is disabled for now. The ARM patch will check the condition of the instruction in ARM mode and continue if the condition isn't true (and therefore the instruction would not be executed). Again, this is not enable, but the code for it has been added.

<rdar://problem/19145455> 

llvm-svn: 223851
2014-12-09 23:31:02 +00:00
Hafiz Abid Qadeer 290ece8278 Fix a bug where global variable can be reported as local.
There was an error in ORing mask which is used for getting a list of variables.
Previously, these constants were unnamed, and possible it become the reason of this
bug. Also added test case for -stack-list-local and -stack-list_arguments.

Patch from Ilia K <ki.stfu@gmail.com>.

llvm-svn: 223674
2014-12-08 18:07:40 +00:00
Jason Molenda e589e7e336 The lldb unwinder can now use the unwind information from the compact-unwind
section for x86_64 and i386 targets on Darwin systems.  Currently only the
compact unwind encoding for normal frame-using functions is supported but it
will be easy handle frameless functions when I have a bit more free time to
test it.  The LSDA and personality routines for functions are also retrieved
correctly for functions from the compact unwind section.

This new code is very fresh -- it passes the lldb testsuite and I've done
by-hand inspection of many functions and am getting correct behavior for all
of them.  There may need to be some bug fixing over the next couple weeks as
I exercise and test it further.  But I think it's fine right now so I'm
committing it.

<rdar://problem/13220837> 

llvm-svn: 223625
2014-12-08 03:09:00 +00:00
Hafiz Abid Qadeer ebbb8f3a41 Cleanup of the fix done recently for a lldb-mi hang on OSX.
It was observed that we dont need to set stdin to unbuffered and setting console
to non-canonical mode.

Patch originally came from "Ilia K <ki.stfu@gmail.com>"

llvm-svn: 223353
2014-12-04 11:05:31 +00:00
Hafiz Abid Qadeer afd188fee4 Remove unnecessary changes committed in r223222.
There were 2 different patches in discussion. One using ioctl
and other using select. We decided to use the ioctl but committed
code also have some changes which were only needed for 'select'.
This patch removes them.

llvm-svn: 223227
2014-12-03 12:48:19 +00:00
Hafiz Abid Qadeer 25383ac01b Fix a hang on OSX while executing -exec-run.
Now we wait for input to become available before blocking in fgets.
More details on problem can be found in 
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20141201/014290.html

Patch from dawn@burble.org.

llvm-svn: 223222
2014-12-03 10:23:06 +00:00
Jason Molenda 5197ba5b01 Add support for 32-bit i386 binaries.
llvm-svn: 222952
2014-11-29 09:17:40 +00:00
Jason Molenda c9acfeb55b The finishing touches on getting the compact unwind dumping completed
for x86_64.  i386, arm, arm64 aren't handled yet but those are minor
variations on this format.

This commit also adds code to read the symbol table out of the
binary and read the LC_FUNCTION_STARTS to augment the symbol table
with the start addresses of all the functions - and print the
function names when showing the unwind info.

llvm-svn: 222951
2014-11-29 07:05:07 +00:00
Jason Molenda a6f75467da Add support for UNWIND_X86_64_MODE_STACK_IND entries.
Correct the function offset computations in UNWIND_SECOND_LEVEL_REGULAR
tables.  A few other small fixes.

llvm-svn: 222910
2014-11-28 03:54:13 +00:00
Oleksiy Vyalov 2f206d6ee4 Make LLGS to open a named pipe and write a listening port to it only when a proper port value is received.
llvm-svn: 222902
2014-11-27 20:51:24 +00:00
Jason Molenda 671001cc66 A little more work on the compact unwind dumper.
UNWIND_X86_64_MODE_STACK_IND mode is almost correct; extra stack
space allocated before the reg saves isn't handled right.  Still a
little wobbily on the file addresses of functions.  Finally understand
how the 6 registers that may be saved are ordered in just 10 its
of space -- the Lehmer code for the registers is derived and then
the sequence is encoded in a variable base number.  Added some
comments with references to what the code is doing so it'll be
easier for others to track down.

llvm-svn: 222884
2014-11-27 13:21:38 +00:00
Jim Ingham 0f17c5570d Make the sourcing of the local .lldbinit file quiet.
<rdar://problem/19065278>

llvm-svn: 222599
2014-11-22 01:33:22 +00:00
Jim Ingham 661f29dde4 Make the option parsing of -k & -K match the help strings.
llvm-svn: 222479
2014-11-20 23:37:13 +00:00
Jim Ingham 4add3b13f0 Add "-k" and "-K" options to the driver, that allow you to register
some commands that will get run if the target crashes.

Also fix the bug where the local .lldbinit file was not getting
sourced before not after the target was created from the file options on the
driver command line.

<rdar://problem/19019843>

llvm-svn: 222295
2014-11-19 01:28:13 +00:00
Zachary Turner 1d6af02e2d Reformat lldb-mi using clang-format.
Courtesy of dawn@burble.org.

llvm-svn: 222150
2014-11-17 18:06:21 +00:00
Jason Molenda b412e529e2 Add a little sketch of a program that can extract unwind
information from the compact unwind section used on darwin
for exception handling, and dump that information..

The UNWIND_X86_64_MODE_RBP_FRAME and UNWIND_X86_64_MODE_DWARF
entries look to be handled correctly.

UNWIND_X86_64_MODE_STACK_IMMD and UNWIND_X86_64_MODE_STACK_IND 
are still a work in progress.

Only x86_64 is supported right now.  Given that this is an
experiment in parsing the section contents, I don't expect to
add other architectures; they are trivial variations on this
arch.  There exists a real dumper included in the Xcode tools, 
unwinddump.

llvm-svn: 222127
2014-11-17 11:43:37 +00:00
Jim Ingham 90556aa757 Fix examine-threads to build for arm64.
llvm-svn: 222059
2014-11-14 22:58:25 +00:00
Shawn Best 8da0bf3b7c LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166
llvm-svn: 221570
2014-11-08 01:41:49 +00:00
Deepak Panickal bc8c68ec02 Fix lldb-mi warnings so that it builds when --enable-werror is set.
llvm-svn: 221452
2014-11-06 13:42:49 +00:00
Eric Christopher 8b1bea8aee Avoid building lldb-mi when --enable-werror is set
as it doesn't build and is optional.

llvm-svn: 221315
2014-11-04 23:30:30 +00:00
Jason Molenda f4c87d69b0 Remove unused service plist.
llvm-svn: 220892
2014-10-30 01:04:59 +00:00
Jason Molenda 0f7828cf6d Clarify the launch style for debugserver to use.
<rdar://problem/18786645> 

llvm-svn: 220761
2014-10-28 03:15:33 +00:00
Jason Molenda b3795a4f5e Enable warnings in the debugserver project file..
llvm-svn: 219917
2014-10-16 08:16:29 +00:00
Jason Molenda ecafcb867a Xcode recommended these changes to the project file. It recommended
a number of warnings to be enabled.  The one making the most noise
across the code base right now is CLANG_WARN_UNREACHABLE_CODE = YES.

llvm-svn: 219910
2014-10-16 08:04:28 +00:00
Jason Molenda 3c86c7e3a2 Remove unused change to argc/argv after long option parsing has been completed.
clang static analyzer fixit.

llvm-svn: 219891
2014-10-16 01:50:14 +00:00
Jason Molenda aeb9a06ff5 Fix unused-variable warnings from the clang static analyzer.
llvm-svn: 219863
2014-10-15 23:13:51 +00:00
Jim Ingham ffc9f1de34 This adds a "batch mode" to lldb kinda like the gdb batch mode. It will quit the debugger
after all the commands have been executed except if one of the commands was an execution control
command that stopped because of a signal or exception.

Also adds a variant of SBCommandInterpreter::HandleCommand that takes an SBExecutionContext.  That
way you can run an lldb command targeted at a particular target, thread or process w/o having to 
select same before running the command.

Also exposes CommandInterpreter::HandleCommandsFromFile to the SBCommandInterpreter API, since that
seemed generally useful.

llvm-svn: 219654
2014-10-14 01:20:07 +00:00
Jim Ingham 26c7bf9312 Rework the way we pass "run multiple command" options to the various API's that
do that (RunCommandInterpreter, HandleCommands, HandleCommandsFromFile) to gather
the options into an options class.  Also expose that to the SB API's.

Change the way the "-o" options to the lldb driver are processed so:
1) They are run synchronously - didn't really make any sense to run the asynchronously.
2) The stop on error
3) "quit" in one of the -o commands will not quit lldb - not the command interpreter
that was running the -o commands.

I added an entry to the run options to stop-on-crash, but I haven't implemented that yet.

llvm-svn: 219553
2014-10-11 00:38:27 +00:00
Zachary Turner 93a66fc13a Move ConnectionFileDescriptor to platform-specific Host directory.
As part of getting ConnectionFileDescriptor working on Windows,
there is going to be alot of platform specific work to be done.
As a result, the implementation is moving into Host.  This patch
performs the code move and fixes up call-sites appropriately.

Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5548

llvm-svn: 219143
2014-10-06 21:22:36 +00:00
Todd Fiala eeb023cf76 Fix codesigning of MacOSX debugserver when built with cmake.
This patch fixes the codesigning of debugserver on OSX when built with
cmake.  Without this you get this error when debugging:
    error: process launch failed: unable to locate debugserver

Note: you also need to set LLDB_DEBUGSERVER_PATH to point to your built debugserver.
e.g. export LLDB_DEBUGSERVER_PATH=`pwd`/bin/debugserver

Change by dawn@burble.org.

Tested on MacOSX 10.9.5 and Xcode 6.1 Beta using cmake/ninja.
Verified no build break on Linux Ubuntu cmake/ninja and Xcode 6.1 canonical build.

llvm-svn: 218890
2014-10-02 16:59:30 +00:00
Todd Fiala cacde7df6d Enable llgs to build against experimental Android AOSP lldb/llvm/clang/compiler-rt repos.
See http://reviews.llvm.org/D5495 for more details.

These are changes that are part of an effort to support building llgs, within the AOSP source tree, using the Android.mk
build system, when using the llvm/clang/lldb git repos from AOSP replaced with the experimental ones currently in
github.com/tfiala/aosp-{llvm,clang,lldb,compiler-rt}.

llvm-svn: 218568
2014-09-27 16:54:22 +00:00
Zachary Turner acee96ae52 Fix up the HostThread interface, making the interface simpler.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5417

llvm-svn: 218325
2014-09-23 18:32:09 +00:00
Todd Fiala 21130fbc04 Fix lldb-gdbserver build.
Build break change by Paul Osmialowski.

Minor changes to argument passing (converted unintentional pass-by-value to pass-by-ref) by Todd.

llvm-svn: 218186
2014-09-20 17:34:48 +00:00
Greg Clayton 615eb7e609 Test suite runs better again after recent fixes that would select a platform if a "file a.out" auto selected a different platform than the selected one.
Changes include:
- fix it so you can select the "host" platform using "platform select host"
- change all callbacks that create platforms to returns shared pointers
- fix TestImageListMultiArchitecture.py to restore the "host" platform by running "platform select host"
- Add a new "PlatformSP Platform::Find(const ConstString &name)" method to get a cached platform
- cache platforms that are created and re-use them instead of always creating a new one

llvm-svn: 218145
2014-09-19 20:11:50 +00:00
Ed Maste def0dae250 Build lldb-mi on all platforms with Makefile builds
CMake builds already do so.

llvm-svn: 217931
2014-09-17 00:28:31 +00:00
Todd Fiala b82ad2a8b8 Fix build break in Xcode build of lldb-tool.
llvm-svn: 217772
2014-09-15 15:17:13 +00:00
Deepak Panickal 428ab6e0ff Fix lldb-mi driver for running on OSX.
llvm-svn: 217668
2014-09-12 12:17:21 +00:00
Zachary Turner 40a069adcd Fix Windows build.
* ssize_t isn't defined by default on Windows.
* New public API files need to be defined in a different file for
  Windows.

llvm-svn: 217624
2014-09-11 20:26:49 +00:00
Zachary Turner 39de311071 Create a HostThread abstraction.
This patch moves creates a thread abstraction that represents a
thread running inside the LLDB process.  This is a replacement for
otherwise using lldb::thread_t, and provides a platform agnostic
interface to managing these threads.

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

Reviewed by: Jim Ingham

llvm-svn: 217460
2014-09-09 20:54:56 +00:00
Eric Christopher 94c13b5779 Remove unused class variable and its initialization.
llvm-svn: 217425
2014-09-09 06:37:18 +00:00
Eric Christopher fa0f79207c Remove a pair of default values from fully covered switches.
llvm-svn: 217424
2014-09-09 06:35:14 +00:00
Eric Christopher e551d183db Add a newline to the end of the file.
llvm-svn: 217423
2014-09-09 06:32:02 +00:00
Eric Christopher db1c183422 Compare against the right size integer.
llvm-svn: 217422
2014-09-09 06:30:09 +00:00
Eric Christopher 13f091af85 Remove two default cases out of fully covered switches.
llvm-svn: 217421
2014-09-09 06:26:36 +00:00
Eric Christopher 2af274e675 Remove two unused class variables.
llvm-svn: 217420
2014-09-09 06:20:57 +00:00
Saleem Abdulrasool 9e5b49831c driver: handle write error better
We would previously simply assume that the write would always succeed.  However,
write(2) may return -1 for error as well as fail to perform a complete write (in
which case the returned number of bytes will be less than the requested bytes).

Explicitly check if an error condition is encountered.  This would previously
not be caught as we default initialized success to true.  Add an assertion that
we always perform a complete write (a continuous retry could be added to ensure
that we finish writing completely).

This was caught by GCC's signed comparison warning and manual inspection.

llvm-svn: 217355
2014-09-08 02:47:13 +00:00
Han Ming Ong cd2d797a79 rdar://problem/18221417
Include compressed memory as part of gauge memory.

llvm-svn: 217084
2014-09-03 22:33:37 +00:00
Todd Fiala 737f43628a llgs: remove all Initialize() calls except for Debugger::Initialize().
See thread here:
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140825/012580.html

The original change I made there was due to a segfault.  That was
caused by me directly calling PluginManager::Initialize (), with
PluginManager::Initialize() depending on HostInfo::Initialize () to
have been called already (which it wasn't).

The call to PluginManager::Initialize () was erroneous (at least at the 
current time) since that method is already called by Debugger::Initialize()'s 
implementation.

We will want to revisit initializing a smaller core of the debugger
suitable for lldb-gdbserver and lldb-platform.

llvm-svn: 216581
2014-08-27 19:56:58 +00:00
Jason Molenda fb700b58cc Bump the verison number in the xcode project files.
llvm-svn: 216245
2014-08-21 23:27:02 +00:00
Todd Fiala 3e9af0dd1d Add missing HostInfo::Initialize() in llgs.
This fixes an llgs segfault on startup.

llvm-svn: 216238
2014-08-21 22:41:25 +00:00
Greg Clayton baac2afccf Cleanup how we listen for process events by using the broadcaster class name instead of having to catch each process instance as it comes alive.
llvm-svn: 215937
2014-08-18 21:09:50 +00:00
Hafiz Abid Qadeer eba7eb7b3f Fix 'pid' and 'executable' fields in the list-thread-group.
The documentation says that these fields should be generated when 
we have proper process or target file. Current implementation did not
check for this. Eclipse seem to use list-thread-group command even
before setting the executable in which case current implementation
can return garbage data.

llvm-svn: 215658
2014-08-14 16:45:50 +00:00
Hafiz Abid Qadeer 6cd101a325 Implementation of exec-run using lldb API.
Previously it was using run command which did not set the process
pointer in the sessionInfo. This commit also sends the proper
out-of-band data.

llvm-svn: 215656
2014-08-14 16:40:27 +00:00
Deepak Panickal f92dc58f0d Fix command "gdb-set" to handle long option --threadgroup and accept --longOption type words as just words for string types.
For example, MI command "17-gdb-set --thread-group i1 args --interpreter" is now acceptable, "--interpreter" was previous not valid.

llvm-svn: 215655
2014-08-14 16:40:15 +00:00
Jason Molenda cfe8fc3e28 Add comment explaining the dwarf v. eh_frame register numbering used
on i386 darwin.

llvm-svn: 215484
2014-08-13 00:21:31 +00:00
Sylvestre Ledru f6102892ef Fix some typos:
* transfered => transferred
* unkown => unknown
* sucessfully => successfully

llvm-svn: 215367
2014-08-11 18:06:28 +00:00
Sylvestre Ledru fca534444b Also build lldb-gdbserver under KFreeBSD
llvm-svn: 215345
2014-08-11 06:29:06 +00:00
Deepak Panickal 7f6edd52c9 Restore some reverted fixes for spelling, newlines and __linux__ macro.
llvm-svn: 215234
2014-08-08 17:39:47 +00:00
Deepak Panickal d249928b84 Add new MI commands, features and fixes to the lldb-mi driver.
- Can now load an executable directly as an argument.
- Fixes towards supporting local debugging.
- Fixes for stack-list-arguments, data-evaluate-expression, environment-cd, stack-list-locals, interpreter-exec.
- Fix breakpoint event handling.
- Support dynamic loading of libraries using the search paths provided by Eclipse.

llvm-svn: 215223
2014-08-08 16:47:42 +00:00
Jim Ingham 5b1fe95dd7 Restore the handling of the --arch argument passed to the Driver that was inadvertently
removed in r214319.

<rdar://problem/17948431>

llvm-svn: 215165
2014-08-07 23:01:31 +00:00
Zachary Turner 98688922b7 Creates a socket host object.
This patch moves the logic of many common socket operations into
its own class lldb_private::Socket.  It then modifies the
ConnectionFileDescriptor class, and a few users of that class,
to use this new Socket class instead of hardcoding socket logic
directly.

Finally, this patch creates a common interface called IOObject for
any objects that support reading and writing, so that endpoints
such as sockets and files can be treated the same.

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

Reviewed by: Todd Fiala, Greg Clayton

llvm-svn: 214984
2014-08-06 18:16:26 +00:00
Greg Clayton 4966876597 Convert over to using pipes for the initial LLDB commands in the Driver.
This will avoid having to use a temp file and adding temp file related calls to the public API.

llvm-svn: 214536
2014-08-01 18:32:07 +00:00
Ed Maste f8314536ec Fix build: remove bogus ./ at end of line
llvm-svn: 214326
2014-07-30 19:26:11 +00:00
Greg Clayton 06357c930c (no commit message)
llvm-svn: 214319
2014-07-30 17:38:47 +00:00
Sylvestre Ledru 3b6c466e96 Use __linux__ macro throughout, instead of ocasional __linux.
__linux is not universally defined across all standards versions, compilers and architectures. Specifically at C99 and up, it's not defined in GCC on powerpc platform.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28314

Bugzilla: http://llvm.org/bugs/show_bug.cgi?id=20380

Patch by Dimitri John Ledkov <dimitri.ledkov@canonical.com>

llvm-svn: 214291
2014-07-30 08:33:21 +00:00
Todd Fiala 31bde322f3 llgs: add --reverse-connect support.
Also includes --reverse-connect tests for llgs and debugserver.

llvm-svn: 214031
2014-07-26 20:39:17 +00:00
Jason Molenda 36a216eefc Increase the gdb-remote packet timeout for the first packet we send
to the remote side (QStartNoAckMode) - it may take a little longer
than normal to get a reply.

In debugserver, hardcode the priority for several threads so they
aren't de-prioritized when a user app is using system resources.
Also, set the names of the threads.

<rdar://problem/17509866>

llvm-svn: 213828
2014-07-24 01:36:24 +00:00
Sean Callanan 2683aca12e Fixed our install-headers script to set version
numbers correctly.

<rdar://problem/17708687>

llvm-svn: 213284
2014-07-17 17:26:38 +00:00
Ed Maste c25d5cc777 Fix lldb-gdbserver build
s_listen_thread had the wrong type.

llvm-svn: 212884
2014-07-12 21:46:39 +00:00