Commit Graph

917 Commits

Author SHA1 Message Date
Pavel Labath 095d6b8f99 Address post-commit review remarks
Tamas pointed out that the macro name I used in r293282 was too vague.
Rename it to better reflect what it is used for.

llvm-svn: 293287
2017-01-27 15:19:03 +00:00
Pavel Labath ef97630fd2 Refactor the android accept hack
This moves the accept hack from the android toolchain file into
LLDBConfig.cmake. This allows successful lldb android compilation
without relying on our custom toolchain file.

llvm-svn: 293281
2017-01-27 12:23:51 +00:00
Pavel Labath 2d0c5b0297 Replace chdir() usage with the llvm equivalent.
This removes a hack in PosixApi.h, which tends to produce strange
compile errors when it's included in the wrong order.

llvm-svn: 293045
2017-01-25 11:10:52 +00:00
Pavel Labath 68de04e2d2 Fix android build for r292935 (personality.h)
It turns out things are not as simple as I hoped. sys/personality.h
exists on all androids but it does not define the required symbols on
all platform levels.

Add a compile check for platform level to compile against both new and
old android headers.

llvm-svn: 292939
2017-01-24 15:35:53 +00:00
Pavel Labath e9862b607e include linux/personality.h on android
sys/personality.h is present only since android platform level 21. The
linux/ version is present everywhere.

llvm-svn: 292935
2017-01-24 14:24:31 +00:00
Pavel Labath b8ad01559f Include termios.h for definition of struct winsize
On android API level 9 the header does not get included transitively.
Include it directly.

As far as I can see, all non-windows platforms should have this header.
If that turns out to be incorrect, we can add some ifdefs around that.

llvm-svn: 292931
2017-01-24 14:05:23 +00:00
Pavel Labath 1d5855b107 Replace getcwd with the llvm equivalent
Summary:
getcwd() is not available (well.. um.. deprecated?) on windows, and the way
PosixApi.h is providing it causes strange compile errors when it's included in
the wrong order. The best way to avoid that is to just not use chdir.

This replaces all uses of getcwd in generic code. There are still a couple of
more uses, but these are in platform-specific code.

chdir() is causing a similar problem, but for that there is no llvm equivalent
for that (yet).

Reviewers: zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D28858

llvm-svn: 292795
2017-01-23 15:56:45 +00:00
Pavel Labath e5cfc67113 [cmake] Make lldb build with the android ndk toolchain file
Summary:
The NDK cmake toolchain file defines CMAKE_SYSTEM_NAME=Android, so switch the
build to use that. I have also updated the in-tree toolchain file to do that
(instead of defining __ANDROID_NDK__), so it can still be used to build.
After migrating the last bits of non-toolchainy bits out of the in-tree
toolchain, I intend to delete it.

Reviewers: tberghammer, danalbert

Subscribers: srhines, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D28775

llvm-svn: 292212
2017-01-17 11:55:00 +00:00
Pavel Labath 238169db60 Fix windows unit tests
The unit test I added in the previous commit discovered a bug in
PrependPathComponent on windows -- it was calling SetFile with the host native
path syntax, whereas it should be explicitly specifying the path syntax (as
AppendPathComponent does). This fixes it.

llvm-svn: 292106
2017-01-16 12:15:42 +00:00
Pavel Labath 59d725cabf FileSpec: Fix PrependPathComponent("/")
Summary:
PrependPathComponent was unconditionally inserting path separators between the
path components. This is not correct if the prepended path is "/", which caused
problems down the line. Fix the function to use the same algorithm as
AppendPathComponent and add a test. This fixes one part of llvm.org/pr31611.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D28677

llvm-svn: 292100
2017-01-16 10:07:02 +00:00
Pavel Labath bda6fb7389 Attempt to fix windows build for r291198
llvm-svn: 291233
2017-01-06 12:41:15 +00:00
Pavel Labath 927ec4b5ac Consolidate file handle usage in Editline.cpp
Summary:
To implement wide character reading, editline was mixing FILE*-based access with
a Connection-based one (plus it did some selects on the raw FD), which is very
fragile. Here, I replace it with one which uses only a Connection-based reads.
The code is somewhat longer as I had to read characters one by one to detect the
end of the multibyte sequence.

I've verified that international characters still work in lldb command line on
OSX.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D28356

llvm-svn: 291220
2017-01-06 09:27:38 +00:00
David Blaikie a322f36cfd Make lldb -Werror clean for -Wstring-conversion
Also found/fixed one bug identified by this warning in
RenderScriptx86ABIFixups.cpp where a string literal was being used in an
effort to provide a name for an instruction/register, but was instead
being passed as the bool 'isVolatile' parameter.

llvm-svn: 291198
2017-01-06 00:38:06 +00:00
Zachary Turner 827d5d74a5 Add methods to enable using formatv syntax in LLDB.
This adds formatv-backed formatting functions in various
places in LLDB such as StreamString, logging, constructing
error messages, etc.  A couple of callsites are changed
from Printf style syntax to formatv style syntax to
illustrate its usage.  Additionally, a FileSpec formatter
is introduced so that FileSpecs can be formatted natively.

Differential Revision: https://reviews.llvm.org/D27632

llvm-svn: 289922
2016-12-16 04:27:00 +00:00
Hafiz Abid Qadeer f6ee79c926 Fix build for mingw.
Summary: I was building lldb using cross mingw-w64 toolchain on Linux and observed some issues. This is first patch in the series to fix that build. It mostly corrects the case of include files and adjusts some #ifdefs from _MSC_VER to _WIN32 and vice versa. I built lldb on windows with VS after applying this patch to make sure it does not break the build there.

Reviewers: zturner, labath, abidh

Subscribers: ki.stfu, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D27759

llvm-svn: 289821
2016-12-15 15:00:41 +00:00
Sean Callanan 237c3ed95e Adopt PrettyStackTrace in LLDB
LLDB needs some minor changes to adopt PrettyStackTrace after https://reviews.llvm.org/D27683.
We remove our own SetCrashDescription() function and use LLVM-provided RAII objects instead.
We also make sure LLDB doesn't define __crashtracer_info__ which would collide with LLVM's definition.

Differential Revision: https://reviews.llvm.org/D27735

llvm-svn: 289711
2016-12-14 21:31:31 +00:00
Pavel Labath bfd6a75861 Remove superfluous android include
This file is not in the include path when building with a non-standalone
toolchain. In does not seem to be necessary anyway.

llvm-svn: 288674
2016-12-05 14:57:23 +00:00
Pavel Labath e705c8b5e6 Replace __ANDROID_NDK__ with __ANDROID__
Summary:
This replaces all the uses of the __ANDROID_NDK__ define with __ANDROID__. This
is a preparatory step to remove our custom android toolchain file and rely on
the standard android NDK one instead, which does not provide this define.
Instead I rely, on __ANDROID__, which is set by the compiler.

I haven't yet removed the cmake variable with the same name, as we will need to
do something completely different there -- NDK toolchain defines
CMAKE_SYSTEM_NAME to Android, while our current one pretends it's linux.

Reviewers: tberghammer, zturner

Subscribers: danalbert, srhines, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D27305

llvm-svn: 288494
2016-12-02 11:15:15 +00:00
Pavel Labath e6e7e6c348 Fix handling of consecutive slashes in FileSpec::GetNormalizedPath()
The core of the function was actually handling them correctly. However, the
early exit was being too optimistic and did not give the function a chance to
fire if the path did not contain dots as well.

Fix that and add a couple of unit tests.

llvm-svn: 288247
2016-11-30 16:08:45 +00:00
Alexander Shaposhnikov 696bd63550 [lldb] Fix typos in file headers
This diff fixes typos in file headers (incorrect file names).

Test plan:

Under llvm/tools/lldb/source:
find ./* -type f | grep -e '\(cpp\|h\)$' | while read F; do B=$(basename $F); echo $F head -n 1 $F | grep -v $B | wc -l ; done

Differential revision: https://reviews.llvm.org/D27115

llvm-svn: 287966
2016-11-26 05:23:44 +00:00
Pavel Labath ce8d6d9c6c Fix builds Windows and OSX builds after Connection refactor in r287922
Switch various bits of platform-specific code to chrono that I did not notice
when doing a linux build. This exposed a bug that ConnectionGenericFileWindows
did not handle the magic UINT32_MAX timeout value (instead it waited for about an
hour, which is close enough I guess). Fix that as well.

llvm-svn: 287927
2016-11-25 14:43:37 +00:00
Pavel Labath 2f159a5f93 Introduce Chrono to the Connection class. NFCI.
llvm-svn: 287922
2016-11-25 12:22:32 +00:00
Zachary Turner e00e64caa7 Make GetRegisterByName() take a StringRef.
This one is fairly trivial and only really involves changing
function signatures and a few simple call-sites.

llvm-svn: 287266
2016-11-17 21:54:37 +00:00
Zachary Turner 3165945a41 Convert Platform, Process, and Connection functions to StringRef.
All tests pass on Linux and Windows.

llvm-svn: 287259
2016-11-17 21:15:14 +00:00
Zachary Turner c156427ded Don't allow direct access to StreamString's internal buffer.
This is a large API change that removes the two functions from
StreamString that return a std::string& and a const std::string&,
and instead provide one function which returns a StringRef.

Direct access to the underlying buffer violates the concept of
a "stream" which is intended to provide forward only access,
and makes porting to llvm::raw_ostream more difficult in the
future.

Differential Revision: https://reviews.llvm.org/D26698

llvm-svn: 287152
2016-11-16 21:15:24 +00:00
Pavel Labath 8cb1cd9b7b Remove TimeValue class
Summary:
All usages have been replaced by appropriate std::chrono funcionality, and the
class is now unused. The only used part of the cpp file is the DumpTimePoint
function, which I have moved into the only caller (CommandObjectTarget.cpp).

Reviewers: clayborg, zturner

Subscribers: mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D26451

llvm-svn: 287096
2016-11-16 10:54:22 +00:00
Sam McCall 6f43d9df61 Fix uninitialized members.
Summary: Fix uninitialized members.

Reviewers: jingham

Subscribers: jingham, lldb-commits

Differential Revision: https://reviews.llvm.org/D26528

llvm-svn: 286947
2016-11-15 10:58:16 +00:00
Zachary Turner e706c1d9d9 Make OptionParser::Parse() take StringRef.
llvm-svn: 286747
2016-11-13 04:24:38 +00:00
Zachary Turner 8927f23abd Fix some use-after-frees that my last CL introduced.
llvm-svn: 286745
2016-11-13 03:36:01 +00:00
Mehdi Amini 665be50e37 Revert unwanted changes in lldb when updating llvm::Error()
My script updated lldb::Errors, and I failed to fix it entirely
before pushing. This restore everything in lldb as it was before
r286561.

llvm-svn: 286565
2016-11-11 05:07:57 +00:00
Mehdi Amini c1edf566b9 Prevent at compile time converting from Error::success() to Expected<T>
This would trigger an assertion at runtime otherwise.

Differential Revision: https://reviews.llvm.org/D26482

llvm-svn: 286562
2016-11-11 04:29:25 +00:00
Mehdi Amini 41af43092c Make the Error class constructor protected
This is forcing to use Error::success(), which is in a wide majority
of cases a lot more readable.

Differential Revision: https://reviews.llvm.org/D26481

llvm-svn: 286561
2016-11-11 04:28:40 +00:00
Pavel Labath 88d0cbe06d Remove TimeValue usage from lldb/Host
llvm-svn: 286371
2016-11-09 14:53:32 +00:00
Pavel Labath 7e2cfbf0b7 Remove TimeValue usage from Core/Module
Summary:
The only interesting part here is that TimePoint and TimeValue have different
natural string representations, which affects "target modules list" output. It
is now "2016-07-09 04:02:21.000000000", whereas previously in was
"Sat Jul  9 04:02:21 2016". I wanted to check if we're OK with that.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D26275

llvm-svn: 286349
2016-11-09 09:59:18 +00:00
Jason Molenda 73184de2d3 When deciding whether to use the source remapping dictionary from
a dSYM per-uuid plist, only use it when the DBGVersion key has a
value of 2 or greater.

<rdar://problem/28889578> 
<rdar://problem/29131339> 

llvm-svn: 286335
2016-11-09 03:42:12 +00:00
Malcolm Parsons 771ef6d4f1 Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: zturner, labath

Subscribers: tberghammer, danalbert, lldb-commits
    
Differential Revision: https://reviews.llvm.org/D26233

llvm-svn: 285855
2016-11-02 20:34:10 +00:00
Chris Bieneman 5f15a30bb1 Find clang resource directory via *nix-style lookup
Summary:
This patch allows the Darwin build to fall back to to Posix-style lookups for the clang resource directory if the debugger library isn't inside a framework.

The patch also includes a bit of refactoring and cleanup around the *nix resolution of the binary and lib directories to reuse the code instead of duplicating it.

With this patch Darwin builds that don't build a framework only have 3 failing tests on my system (TestExec.py).

Reviewers: zturner, labath, spyffe, tfiala

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D26170

llvm-svn: 285838
2016-11-02 17:19:23 +00:00
Eugene Zelenko a0b67bbed9 Fix RHEL 6 build with missing cerrno and some other Include What You Use warnings.
Differential revision: https://reviews.llvm.org/D26171

llvm-svn: 285710
2016-11-01 17:11:10 +00:00
Pavel Labath 1408bf7231 Remove TimeValue usage from FileSpec.h
Summary:
The only usage there was in GetModificationTime(). I also took the opportunity
to move this function from FileSpec to the FileSystem class - since we are
using FileSpecs to also represent remote files for which we cannot (easily)
retrieve modification time, it makes sense to make the decision to get the
modification time more explicit.

The new function returns a llvm::sys::TimePoint<>. To aid the transition
from TimeValue, I have added a constructor to it which enables implicit
conversion from a time_point.

Reviewers: zturner, clayborg

Subscribers: mehdi_amini, tberghammer, danalbert, beanz, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D25392

llvm-svn: 285702
2016-11-01 16:11:14 +00:00
Pavel Labath 218770b827 Improve ".." handling in FileSpec normalization
Summary:
.. handling for windows path was completely broken because the function was
expecting \ as path separators, but we were passing it normalized file paths,
where these have been replaced by forward slashes. Apart from this, the function
was incorrect for posix paths as well in some corner cases, as well as being
generally hard to follow.

The corner cases were:
- /../bar -> should be same as /bar
- /bar/.. -> should be same as / (slightly dodgy as the former depends on /bar actually
  existing, but since we're doing it in an abstract way, I think the
  transformation is reasonable)

I rewrite the function to fix these corner cases and handle windows paths more
correctly. The function should now handle the posix paths (modulo symlinks, but
we cannot really do anything about that without a real filesystem). For windows
paths, there are a couple of corner cases left, mostly to do with drive letter
handling, which cannot be fixed until the rest of the class understands drive
letters better.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D26081

llvm-svn: 285593
2016-10-31 16:22:07 +00:00
Chris Bieneman b47711ab27 When invoking Terminal, don't assume the default shell
Summary:
If a user has their shell set to a non-POSIX conferment shell the TestTerminal.py tests fail because the shell blurb constructed here may not work in their shell.

In my specific case fish-shell (The Friendly Interactive Shell - http://fishshell.com) does not support $?, it instead uses $status (because it is friendly).

This patch removes the assumption of your default shell by running the constructed bash command via "/bin/bash -c ...". This should be safer for users mutating their shell environment.

Reviewers: tfiala

Subscribers: joerg, lldb-commits

Differential Revision: https://reviews.llvm.org/D25750

llvm-svn: 284552
2016-10-18 23:55:34 +00:00
Zachary Turner eb61f388fa Fix build error on Android again.
This one was my fault since I can't compile Android.

llvm-svn: 283414
2016-10-05 23:51:13 +00:00
Zachary Turner 97d2c4011b Convert some Args index-based iteration to range-style iteration.
This is better for a number of reasons.  Mostly style, but also:

1) Signed-unsigned comparison warnings disappear since there is
   no loop index.
2) Iterating with the range-for style gives you back an entry
   that has more than just a const char*, so it's more efficient
   and more useful.
3) Makes code safter since the type system enforces that it's
   impossible to index out of bounds.

llvm-svn: 283413
2016-10-05 23:40:23 +00:00
Zachary Turner 5a8ad4591b Make lldb -Werror clean on Windows.
Differential Revision: https://reviews.llvm.org/D25247

llvm-svn: 283344
2016-10-05 17:07:34 +00:00
Tamas Berghammer fa262c98f8 Fix FixupEnvironment on Android after the Args refactor
llvm-svn: 283237
2016-10-04 18:35:39 +00:00
Dimitar Vlahovski 17d9caf665 Again fixing windows build breakage like in rL282862
llvm-svn: 282866
2016-09-30 15:41:33 +00:00
Dimitar Vlahovski 7ca05307c9 Fixing windows build breakage caused by rL282822
The breakage was because of the moving of the UTF functions to the llvm
namespace

llvm-svn: 282862
2016-09-30 14:36:17 +00:00
Zachary Turner fe83ad8b0d Update FileSpec's interface to use StringRefs.
Differential Revision: https://reviews.llvm.org/D24936

llvm-svn: 282537
2016-09-27 20:48:37 +00:00
Jim Ingham 100f99a94c Mutatis mutandis for char * -> StringRef.
llvm-svn: 282311
2016-09-23 22:36:00 +00:00
Zachary Turner d4c6dae5c1 Fix build on Ubuntu.
This was in some code that was #ifdef'd out on Windows, so I
didn't see it.

llvm-svn: 282309
2016-09-23 22:27:03 +00:00