Commit Graph

182 Commits

Author SHA1 Message Date
Adrian McCarthy f6034c4f3d Don't disable stdin buffering on Windows
Disabling buffering exposes a bug in the MS VS 2015 CRT implementation of fgets, where you sometimes have to hit Enter twice, depending on if the input had an odd or even number of characters.

This was hidden until a few days ago by the Python initialization which was re-enabling buffering on the streams. A few days ago, Enrico make the Python initialization on-demand, which exposed this problem.

llvm-svn: 266384
2016-04-14 23:31:17 +00:00
Pavel Labath bb5c39d79e [Driver] Fix a segfault in signal handlers
Summary:
If we recieve a SIGCONT or SIGTSTP, while the driver is shutting down (which, sometimes, we do,
for reasons which are not completely clear to me), we would crash to due a null pointer
dereference. Guard against this situation.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 265958
2016-04-11 16:40:09 +00:00
Jason Molenda 5109bfd165 Update the INFOPLIST_FILE setting in the xcode project file
so that the lldb command line binary's version #'s are updated
correctly.
<rdar://problem/25346711> 

llvm-svn: 264353
2016-03-24 22:27:52 +00:00
Zachary Turner 190fadcdb2 Unicode support on Win32.
Win32 API calls that are Unicode aware require wide character
strings, but LLDB uses UTF8 everywhere.  This patch does conversions
wherever necessary when passing strings into and out of Win32 API
calls.

Patch by Cameron
Differential Revision: http://reviews.llvm.org/D17107
Reviewed By: zturner, amccarth

llvm-svn: 264074
2016-03-22 17:58:09 +00:00
Zachary Turner 29365da0e8 Delete the custom implementation of signal() on Windows.
The Windows SDK provides a version of signal() that is much more
limited compared to other platforms.  It only supports about 5-6
signal values.  LLDB uses signals for a number of things, most
notably to handle Ctrl+C so we can gracefully shut down.  The
portability solution to this on Windows has been to provide a
hand-rolled implementation of `signal` using the name `signal`
so that you could write code that simply calls signal directly
and it would work.

But this introduces a multiply defined symbol with the builtin
version and depending on how you included header files, you could
get yourself into a situation where you had linker errors.  To
make matters worse, it led to a ton of compiler warnings.  Worst
of all though is that this custom implementation of signal was,
in fact, identical for the purposes of handling Ctrl+C as the
builtin implementation of signal.  So it seems to have literally
not been serving any useful purpose.

This patch deletes all the custom signal() functions for Windows,
and includes the signal.h system header, so that any calls to
signal now go to the actual version provided by the Windows SDK.

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

llvm-svn: 263858
2016-03-18 23:47:48 +00:00
Jason Molenda 878ae01889 This patch stops lldb from loading a .lldbinit file from the current
working directory by default -- a typical security problem that we
need to be more conservative about.

It adds a new target setting, target.load-cwd-lldbinit which may
be true (always read $cwd/.lldbinit), false (never read $cwd/.lldbinit)
or warn (warn if there is a $cwd/.lldbinit and don't read it).  The
default is set to warn.  If this is met with unhappiness, we can look
at changing the default to true (to match current behavior) on a 
different platform.

This does not affect reading of ~/.lldbinit - that will still be read,
as before.  If you run lldb in your home directory, it will not warn
about the presence of a .lldbinit file there.

I had to add two SB API - SBHostOS::GetUserHomeDirectory and 
SBFileSpec::AppendPathComponent - for the lldb driver code to be
able to get the home directory path in an OS neutral manner.

The warning text is

There is a .lldbinit file in the current directory which is not being read.
To silence this warning without sourcing in the local .lldbinit,
add the following to the lldbinit file in your home directory:
    settings set target.load-cwd-lldbinit false
To allow lldb to source .lldbinit files in the current working directory,
set the value of this variable to true.  Only do so if you understand and
accept the security risk.

<rdar://problem/24199163> 

llvm-svn: 261280
2016-02-19 00:05:17 +00:00
Saleem Abdulrasool 1ee07253c7 Silence some clang warnings
Silences -Wmissing-brace and -Wformat-pedantic warnings from clang on Linux.  NFC.

llvm-svn: 260914
2016-02-15 21:50:28 +00:00
Eugene Zelenko c33088f41e Remove autoconf support from source directories.
Differential revision: http://reviews.llvm.org/D16662

llvm-svn: 259098
2016-01-28 22:05:24 +00:00
Ed Maste a6b380652d Wrap Notes in --help output to 80 columns
llvm-svn: 255774
2015-12-16 15:49:38 +00:00
Bruce Mitchener b5c891908d Add more autotools/gmake NetBSD glue
Summary: This diff approaches building the project natively on NetBSD with the autoconf/gmake framework.

Patch by Kamil Rytarowski. Thanks!

Reviewers: emaste, clayborg

Subscribers: tberghammer, joerg, brucem, lldb-commits

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

llvm-svn: 253153
2015-11-15 02:00:09 +00:00
Sean Callanan 3e7e915dca Added support for the "--repl" argument to LLDB.
This makes LLDB launch and create a REPL, specifying no target so that the REPL
can create one for itself.  Also added the "--repl-language" option, which
specifies the language to use.  Plumbed the relevant arguments and errors
through the REPL creation mechanism.

llvm-svn: 250773
2015-10-20 00:23:46 +00:00
Todd Fiala 509300d94c cmake fixes for lldb target.
ninja lldb now does the following:
* forces the python post-build step to fire, which sets up the python lldb module properly.
* on Darwin and Linux, requires the lldb-server target to be built.
* on Darwin, requires the debugserver target to be built.

See http://reviews.llvm.org/D12899 for details.

llvm-svn: 247810
2015-09-16 15:34:06 +00:00
Bruce Mitchener db25a7a245 [cmake] Remove LLVM_NO_RTTI.
Summary:
This doesn't exist in other LLVM projects any longer and doesn't
do anything.

Reviewers: chaoren, labath

Subscribers: emaste, tberghammer, lldb-commits, danalbert

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

llvm-svn: 246749
2015-09-03 08:46:55 +00:00
Jim Ingham 22302e5995 Make command files specified to the driver actually print their
results if the -Q option is not provided.  Also took out the quietly
option from AddInitialCommand, we don't use that to set this option,
we use the override set by the -Q option.

<rdar://problem/21232087>

llvm-svn: 241652
2015-07-08 00:59:59 +00:00
Pavel Labath 83a4b3f225 Remove unused editline includes
LLDB included editline in a couple of places, not respecting LLDB_DISABLE_LIBEDIT. As far as I can tell, these includes are not used, so I am removing them.

llvm-svn: 239199
2015-06-05 23:14:14 +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
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
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
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
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 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
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
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
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
Todd Fiala b82ad2a8b8 Fix build break in Xcode build of lldb-tool.
llvm-svn: 217772
2014-09-15 15:17:13 +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
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
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
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
Todd Fiala 7f02cff20d Remove unused defines from lldb driver.
See http://reviews.llvm.org/D3965 for details.

Change by Thiago Farina.

llvm-svn: 210268
2014-06-05 14:46:04 +00:00
Joerg Sonnenberger 2cd8f5245f Use correct readline header on NetBSD.
llvm-svn: 207861
2014-05-02 18:59:49 +00:00
Colin Riley aba2539989 Fixing MSVC windows build. Please respect code order when ifdefing out MSVC specifics :)
llvm-svn: 205211
2014-03-31 15:48:33 +00:00
Hafiz Abid Qadeer d8265d3071 Hide some declarations from mingw.
llvm-svn: 203781
2014-03-13 10:42:28 +00:00
Hafiz Abid Qadeer b4d550a2ca Add Driver to the build for mingw.
llvm-svn: 203653
2014-03-12 10:51:32 +00:00
Hafiz Abid Qadeer 6eff101926 Replace some _MSC_VER with _WIN32.
This allows to use some code for mingw which was previously only
used for MSVC.

llvm-svn: 203651
2014-03-12 10:45:23 +00:00
Hafiz Abid Qadeer bdb515916c Added some missing header files.
They help fix mingw build.

llvm-svn: 203650
2014-03-12 10:39:46 +00:00
Hafiz Abid Qadeer a667875fb9 Fix Mingw build error by using lower case name for windows header files.
llvm-svn: 203505
2014-03-10 22:31:39 +00:00
Deepak Panickal 627f4ae811 Build liblldb.dll in Windows
llvm-svn: 202724
2014-03-03 15:50:36 +00:00
Deepak Panickal 99fbc07600 Fix Windows build using portable types for formatting the log outputs
llvm-svn: 202723
2014-03-03 15:39:47 +00:00
Greg Clayton 9c0b64c92d The "-n" and "-p" options to the lldb driver no longer worked after recent IOHandler changes, this is now fixed.
<rdar://problem/15962763>

llvm-svn: 200930
2014-02-06 18:22:44 +00:00
Jim Ingham f0c63b97d6 Fix the --source-quietly option to the driver so that it actually works. Clean up the help
output a bit.

llvm-svn: 200878
2014-02-05 21:35:09 +00:00
Deepak Panickal 914b8d989b Fixing the Windows build for the changes brought in from the iohandler merge.
llvm-svn: 200565
2014-01-31 18:48:46 +00:00
Greg Clayton 44d937820b Merging the iohandler branch back into main.
The many many benefits include:
1 - Input/Output/Error streams are now handled as real streams not a push style input
2 - auto completion in python embedded interpreter
3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use
4 - it is now possible to use curses to drive LLDB (please try the "gui" command)

We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases.

llvm-svn: 200263
2014-01-27 23:43:24 +00:00