[Lldb-commits] [PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-06-09 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: clang/test/ParserHLSL/group_shared.hlsl:14
-// expected-error@+1 {{expected expression}}
 float groupshared [[]] i = 12;
 

philnik wrote:
> beanz wrote:
> > aaron.ballman wrote:
> > > philnik wrote:
> > > > Should this also get an extension warning/should attributes be disabled 
> > > > for HLSL?
> > > CC @beanz 
> > > 
> > > I was wondering the same thing. :-)
> > By bug rather than design DXC allows C++ attribute syntax in some places 
> > for HLSL.
> > 
> > I'm totally fine with (and prefer) following the rest of the languages here 
> > and having HLSL in Clang always allow C++ attributes regardless of language 
> > version.
> Would you like some sort of warning?
Since DXC accepts the syntax without a warning/error I think we're fine without 
one here. There won't be any portability issues with code that use C++ 
attributes in HLSL unless they go back to the _extremely_ old compiler that we 
don't really support anyways.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151683/new/

https://reviews.llvm.org/D151683

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-06-09 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: clang/test/ParserHLSL/group_shared.hlsl:14
-// expected-error@+1 {{expected expression}}
 float groupshared [[]] i = 12;
 

aaron.ballman wrote:
> philnik wrote:
> > Should this also get an extension warning/should attributes be disabled for 
> > HLSL?
> CC @beanz 
> 
> I was wondering the same thing. :-)
By bug rather than design DXC allows C++ attribute syntax in some places for 
HLSL.

I'm totally fine with (and prefer) following the rest of the languages here and 
having HLSL in Clang always allow C++ attributes regardless of language version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151683/new/

https://reviews.llvm.org/D151683

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D117639: [cmake] Make include(GNUInstallDirs) always below project(..)

2022-01-25 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117639/new/

https://reviews.llvm.org/D117639

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D116467: Deprecate `LLVM_LIBRARY_DIRS`

2022-01-01 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

`LLVM_LIBRARY_DIR` and `LLVM_LIBRARY_DIRS` aren’t intended to serve the same 
purpose. The `S` in `DIRS` is intentional to convey that it is a list of 
directories, not necessarily a single value, and it would definitely break many 
uses of `LLVM_LIBRARY_DIR` if it was a list. There are several (not correctly 
handled) build configurations where `LLVM_SHLIB_OUTPUT_INTDIR` and the shared 
library install directory are not the same as the static archive install 
directory. In those cases we _should_ be setting `LLVM_LIBRARY_DIRS` to be an 
array containing both `LLVM_LIBRARY_DIR` and `LLVM_TOOLS_BINARY_DIR`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116467/new/

https://reviews.llvm.org/D116467

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2019-12-18 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

I think this is good, and it has been sitting a while.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70764/new/

https://reviews.llvm.org/D70764



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2019-12-04 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I conferred off-list with @compnerd. He and I talked through my concerns, and I 
believe this patch is fine as-is, so LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70764/new/

https://reviews.llvm.org/D70764



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2019-12-04 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@labath sorry for not replying on-list. I've actually been discussing offline 
with @compnerd. If `llvm-config` is printing an absolute path, I'm concerned 
about how that will interact with binary package distributions for the llvm-dev 
packages. Not sure if @tstellar has any thoughts on that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70764/new/

https://reviews.llvm.org/D70764



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69931: Add cmake variables to specify a python framework to ship with lldb

2019-11-08 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

It is a bit gross that Python does an @rpath install name, that is generally 
against convention. I can see adding an option to add rpaths to liblldb making 
sense. I certainly agree LLDB shouldn't be in the business of packaging 
transitive dependencies.

In a broader sense, Frameworks are dylibs. They can have all the same rpath 
magic that a dylib has. When you link a macho, the static linker pulls the 
install_name from each dylib you link against and embeds those as the dylibs to 
load. Since Python 3.7's install_name is @rpath based, it means that the 
dynamic linker will look for it in all the @rpath-relative locations specified 
by liblldb when linking. The proposed path in this patch, `-rpath 
"@loader_path/../../../"`, uses the @loader_path expansion which is the 
directory containing the binary that the load command is in (in this case 
liblldb's directory). Popping 3 directories up from that is likely not sane in 
most build configurations, but if it works for you meh...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69931/new/

https://reviews.llvm.org/D69931



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D63544: Use object library if cmake supports it

2019-06-20 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I really don't think this is the right solution.

`$` can be passed in as source files in the unit 
test target, which should work just fine on CMake 3.4.x.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63544/new/

https://reviews.llvm.org/D63544



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D56606: [CMake] Export utility targets to the build/install tree depending on LLVM_BUILD/INSTALL_UTILS

2019-01-11 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56606/new/

https://reviews.llvm.org/D56606



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55116: [CMake] llvm_codesign workaround for Xcode double-signing errors

2018-12-13 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Sorry for being behind on this, but I don't think this is the right solution to 
the problem.

I don't think we should ever pass `--force`. To avoid duplicate code signing 
when using the Xcode generator we should set the 
`XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY` target property so that Xcode actually 
knows what signing identity to use and can properly build the target.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55116/new/

https://reviews.llvm.org/D55116



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54443: [CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign

2018-11-16 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D54443



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54443: [CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign

2018-11-13 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: CMakeLists.txt:403
+set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
+  "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
+

sgraenitz wrote:
> Identity should be a string right?
Yep, makes sense.



Comment at: cmake/modules/AddLLVM.cmake:795
 
-  llvm_codesign(${name})
+  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} FORCE)
 endmacro(add_llvm_executable name)

sgraenitz wrote:
> sgraenitz wrote:
> > beanz wrote:
> > > sgraenitz wrote:
> > > > Would we want to pass `FORCE` to `add_llvm_executable` conditionally?
> > > I'm trying to think about the situations in which we need the `FORCE` 
> > > option. Since this is connecting as a post-build event it shouldn't be 
> > > running unless the target re-generates the output, so I'm not sure I 
> > > understand why we ever need it.
> > > 
> > > I did the git blame walk back to when the code was initially added in 
> > > `49dd98a03a`, and there is no explanation. I suspect debugserver doesn't 
> > > actually need the `--force` option because the author of the initial 
> > > patch probably hit errors when re-signing the pre-built binary in his 
> > > build directory.
> > > 
> > > Thoughts?
> > I think you are right, it shouldn't be necessary. In practice, though, I 
> > can imagine situations when we want to make sure this won't fail in any 
> > case.
> > 
> > The options are: remove entirely (most correct) OR allow enable per target 
> > (most flexible) OR allow enable globally.
> > 
> > What about the last one? I could add `LLVM_CODESIGNING_FORCE` which is OFF 
> > by default. In failsafe/debugging situations it could be turned ON 
> > globally. I could remove the `FORCE` parameter here and check the flag in 
> > `llvm_codesign` (similar to `LLVM_CODESIGNING_IDENTITY`).
> Patch updated
My gut is to just remove forcing entirely, and only add it back if we actually 
need it. Short of post-build steps being incorrectly implemented in a CMake 
generator, I can't imagine a situation where it would be needed.


Repository:
  rL LLVM

https://reviews.llvm.org/D54443



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54443: [CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign

2018-11-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: cmake/modules/AddLLVM.cmake:795
 
-  llvm_codesign(${name})
+  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} FORCE)
 endmacro(add_llvm_executable name)

sgraenitz wrote:
> Would we want to pass `FORCE` to `add_llvm_executable` conditionally?
I'm trying to think about the situations in which we need the `FORCE` option. 
Since this is connecting as a post-build event it shouldn't be running unless 
the target re-generates the output, so I'm not sure I understand why we ever 
need it.

I did the git blame walk back to when the code was initially added in 
`49dd98a03a`, and there is no explanation. I suspect debugserver doesn't 
actually need the `--force` option because the author of the initial patch 
probably hit errors when re-signing the pre-built binary in his build directory.

Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D54443



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54352: [CMake] Explicit lldb_codesign function with application in debugserver and lldb-server

2018-11-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I can certainly foresee other LLVM-based projects needing entitlements, so I am 
very much in favor of adding `ENTITLEMENTS` and `FORCE` options onto 
`llvm_codesign`.


https://reviews.llvm.org/D54352



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54352: [CMake] Explicit lldb_codesign function with application in debugserver and lldb-server

2018-11-09 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Why not just add entitlement support to ‘llvm_codesign’? Or feed through extra 
arguments?


https://reviews.llvm.org/D54352



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D36598: cmake + xcode: prevent gtests from using includes from project root

2017-08-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

This LGTM.


https://reviews.llvm.org/D36598



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component

2017-08-04 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@mgorny I want to apologize here but I need to ask you not to commit this until 
@chapuni and I can come to an agreement between this solution and 
https://reviews.llvm.org/D36211. He ping'd me on IRC yesterday after I left for 
the day, I'll try and get in touch with him today to see if we can agree on the 
path forward.


Repository:
  rL LLVM

https://reviews.llvm.org/D31367



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D34322: [lldb] Correctly escape newlines and backslashes in the JSON serializer

2017-06-19 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I get your perspective, but holding up this relatively small patch that fixes a 
bug in existing code on an architectural disagreement seems like excessive bike 
shedding. If we assume that JSON is required for the use case would you have 
Kuba write a full JSON parser in LLVM to satisfy your distaste over the fact 
that we have multiple JSON parsers already? That seems like an unreasonable 
request just to fix a few small bugs in existing code.

Fundamentally I think we probably should migrate toward having a single JSON 
parser implemented in LLVMSupport, but I don't think this is the patch review 
to pick that fight over.


https://reviews.llvm.org/D34322



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D34322: [lldb] Correctly escape newlines and backslashes in the JSON serializer

2017-06-19 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

In https://reviews.llvm.org/D34322#783532, @joerg wrote:

> My suggestion would be to just use the YAML writer for now and leave a 
> comment to make it clear that this is really JSON only.


Our YAML parser can parse JSON because YAML is a superset of JSON, but I don't 
believe the YAML writer supports writing out inline-style YAML which would be 
compatible with a JSON parser. That might make the LLVM YAML writer unsuitable 
for @kubamracek's use case.


https://reviews.llvm.org/D34322



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32930: New framework for lldb client-server communication tests.

2017-05-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: unittests/tools/CMakeLists.txt:1
+if(UNIX AND NOT APPLE)
+  add_subdirectory(lldb-server)

labath wrote:
> beanz wrote:
> > labath wrote:
> > > This is not what I meant. The only targets (at least until we have 
> > > debugserver support) that can realistically pass these tests are linux, 
> > > android, and netbsd. The other targets (right now, I guess that would 
> > > mean freebsd) don't even pretend to support debugging via lldb-server, so 
> > > we should not fail their build because of that. Check for usages of 
> > > CMAKE_SYSTEM_NAME to see how to discriminate those.
> > Darwin pretends to support lldb-server in several places, it would be nice 
> > to be able to run these tests on Darwin if they work. One of my big goals 
> > for the future of testing on LLDB is to get to the point where the only 
> > differences in test coverage when running tests on different hosts is truly 
> > platform-specific code. Today we are nowhere near that.
> > 
> > Also, as Pavel pointed out in email, the lldb-server tests are also run 
> > against debugserver, so we need to make sure that still works too.
> Which lldb-server support do you refer to here?
> 
> There is some llgs (debugging) support in lldb-server, but I have no idea 
> what's the state of it -- it was added by Todd during his week of code as an 
> "NFC" commit, and it hasn't been touched since. I'd like to avoid this 
> keeping the build red if there is no intention of working on it. 
> 
> The "platform" mode of lldb-server should work on darwin afaik, and we 
> definitely want to be able to run it there. It's not what we are focusing on 
> now though. We'd like to migrate the "debug" tests first (there are no 
> "platform" tests), so the old ones can be removed. 
> 
> In any case, I think of the apple exclusion part as a temporary thing, so we 
> can check this in without breaking the build, we will pretty soon want to 
> include it as well, so that we can run debugserver tests, at least. (At which 
> point we will need a different way of disabling unsupported tests).
I don't know the state of this stuff on Darwin either. I had spent a little 
time a few weeks ago trying to get lldb to use lldb-server on Darwin to see if 
I could answer that question, but I didn't get very far before I had to stop.

As long as the Apple exclusion is temporary I'm fine with this as-is. I'll see 
if I can free up some time this summer to look more closely at lldb-server on 
Darwin and figure out what state it is in.


https://reviews.llvm.org/D32930



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32930: New framework for lldb client-server communication tests.

2017-05-30 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.

One small comment below. In general I agree with the thoughts here, and I think 
that this is a huge step forward for testing the debug server components.

I also agree with Zachary in principal that it would be nice to come up with 
lit-based test harnesses for more parts of LLDB, although I'm skeptical about 
whether or not that is actually the best way to test the debug server pieces. 
Either way, this is a huge step forward from what we have today, so we should 
go with it.




Comment at: unittests/tools/CMakeLists.txt:1
+if(UNIX AND NOT APPLE)
+  add_subdirectory(lldb-server)

labath wrote:
> This is not what I meant. The only targets (at least until we have 
> debugserver support) that can realistically pass these tests are linux, 
> android, and netbsd. The other targets (right now, I guess that would mean 
> freebsd) don't even pretend to support debugging via lldb-server, so we 
> should not fail their build because of that. Check for usages of 
> CMAKE_SYSTEM_NAME to see how to discriminate those.
Darwin pretends to support lldb-server in several places, it would be nice to 
be able to run these tests on Darwin if they work. One of my big goals for the 
future of testing on LLDB is to get to the point where the only differences in 
test coverage when running tests on different hosts is truly platform-specific 
code. Today we are nowhere near that.

Also, as Pavel pointed out in email, the lldb-server tests are also run against 
debugserver, so we need to make sure that still works too.


https://reviews.llvm.org/D32930



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D25886: [Test Suite] Properly respect --framework option

2017-05-08 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py:1418
  "include")),
-'LD_EXTRAS': "-L%s -llldb" % lib_dir}
+'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % 
(lib_dir, lib_dir)}
 elif sys.platform.startswith('win'):

fjricci wrote:
> Why do we need to make this `-L$(lib_dir)/../lib` instead of the original 
> `-L$(lib_dir)`? This breaks cases where `lib_dir` is `lib64` and not `lib`
Basically because this is hack on top of hack on top of hack...

Confusingly `lib_dir` is actually set to the `bin` dir not the correct setting 
for `lib`/`lib64`. Except if lldb supports the `-P` flag, and your host is 
FreeBSD or Linux, in which case we construct the lib path from the python 
path...

So this change was needed to make Darwin or NetBSD work, but broke FreeBSD and 
Linux in lib64 configurations... great...

We *really* need to clean up all of this because the garbled mess of 
platform-specific hacks is a really big problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D25886



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32600: Resurrect pselect MainLoop implementation

2017-04-27 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

This looks like a nice improvement. There are some formatting inconsistencies, 
can you run clang-format?


https://reviews.llvm.org/D32600



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32357: Add more arguments to SocketAddress::GetAddressInfo

2017-04-21 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

This is awesome! Thanks!


https://reviews.llvm.org/D32357



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-18 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

This looks good to me.


https://reviews.llvm.org/D32125



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D32125: [LLVM][MIPS] Fix different definition of off_t in LLDB and LLVM

2017-04-17 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Can you please move this check into `HandleLLVMOptions.cmake`? By putting it 
into a module that is vended as part of LLVM's packaging then LLVM subprojects 
can have consistent settings when building out-of-tree.

This would enable @zturner's request to remove the duplicated code from LLDB.


Repository:
  rL LLVM

https://reviews.llvm.org/D32125



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-17 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 95453.
beanz added a comment.

Removing code I accidentally left in that was from debugging, and moving some 
duplicated code that @labath spotted out of the ifdef.


https://reviews.llvm.org/D31823

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/MainLoop.h
  include/lldb/Host/Socket.h
  include/lldb/Host/common/TCPSocket.h
  include/lldb/Host/common/UDPSocket.h
  include/lldb/Host/linux/AbstractSocket.h
  include/lldb/Host/posix/DomainSocket.h
  include/lldb/Host/posix/MainLoopPosix.h
  lldb.xcodeproj/project.pbxproj
  source/Host/CMakeLists.txt
  source/Host/common/MainLoop.cpp
  source/Host/common/Socket.cpp
  source/Host/common/TCPSocket.cpp
  source/Host/common/UDPSocket.cpp
  source/Host/linux/AbstractSocket.cpp
  source/Host/posix/ConnectionFileDescriptorPosix.cpp
  source/Host/posix/DomainSocket.cpp
  source/Host/posix/MainLoopPosix.cpp
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  tools/lldb-server/Acceptor.cpp
  unittests/Host/SocketTest.cpp
  unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
  unittests/debugserver/RNBSocketTest.cpp

Index: unittests/debugserver/RNBSocketTest.cpp
===
--- unittests/debugserver/RNBSocketTest.cpp
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -96,7 +96,7 @@
 ASSERT_EQ(bye, goodbye);
   } else {
 Socket *connected_socket;
-err = server_socket->Accept(addr_wrap, false, connected_socket);
+err = server_socket->Accept(connected_socket);
 if (err.Fail()) {
   llvm::errs() << err.AsCString();
   abort();
Index: unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
===
--- unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
+++ unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
@@ -33,15 +33,14 @@
 void Connect(GDBRemoteCommunication , GDBRemoteCommunication ) {
   bool child_processes_inherit = false;
   Error error;
-  TCPSocket listen_socket(child_processes_inherit, error);
+  TCPSocket listen_socket(true, child_processes_inherit);
   ASSERT_FALSE(error.Fail());
   error = listen_socket.Listen("127.0.0.1:0", 5);
   ASSERT_FALSE(error.Fail());
 
   Socket *accept_socket;
   std::future accept_error = std::async(std::launch::async, [&] {
-return listen_socket.Accept("127.0.0.1:0", child_processes_inherit,
-accept_socket);
+return listen_socket.Accept(accept_socket);
   });
 
   char connect_remote_address[64];
Index: unittests/Host/SocketTest.cpp
===
--- unittests/Host/SocketTest.cpp
+++ unittests/Host/SocketTest.cpp
@@ -44,8 +44,7 @@
const char *listen_remote_address,
bool child_processes_inherit, Socket **accept_socket,
Error *error) {
-*error = listen_socket->Accept(listen_remote_address,
-   child_processes_inherit, *accept_socket);
+*error = listen_socket->Accept(*accept_socket);
   }
 
   template 
@@ -56,7 +55,7 @@
 bool child_processes_inherit = false;
 Error error;
 std::unique_ptr listen_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = listen_socket_up->Listen(listen_remote_address, 5);
 EXPECT_FALSE(error.Fail());
@@ -70,7 +69,7 @@
 
 std::string connect_remote_address = get_connect_addr(*listen_socket_up);
 std::unique_ptr connect_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = connect_socket_up->Connect(connect_remote_address);
 EXPECT_FALSE(error.Fail());
@@ -141,6 +140,20 @@
   EXPECT_STREQ("65535", port_str.c_str());
   EXPECT_EQ(65535, port);
   EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[::1]:12345", host_str, port_str, port, ));
+  EXPECT_STREQ("::1", host_str.c_str());
+  EXPECT_STREQ("12345", port_str.c_str());
+  EXPECT_EQ(12345, port);
+  EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[abcd:12fg:AF58::1]:12345", host_str, port_str, port, ));
+  EXPECT_STREQ("abcd:12fg:AF58::1", host_str.c_str());
+  EXPECT_STREQ("12345", port_str.c_str());
+  EXPECT_EQ(12345, port);
+  EXPECT_TRUE(error.Success());
 }
 
 #ifndef LLDB_DISABLE_POSIX
Index: tools/lldb-server/Acceptor.cpp
===
--- tools/lldb-server/Acceptor.cpp
+++ tools/lldb-server/Acceptor.cpp
@@ -62,8 +62,7 @@
 
 Error Acceptor::Accept(const bool child_processes_inherit, Connection *) {
   Socket *conn_socket = nullptr;
-  auto error = m_listener_socket_up->Accept(
-  

[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-17 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 95448.
beanz added a comment.

Updating patches to reflect feedback from zturner.


https://reviews.llvm.org/D31823

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/MainLoop.h
  include/lldb/Host/Socket.h
  include/lldb/Host/common/TCPSocket.h
  include/lldb/Host/common/UDPSocket.h
  include/lldb/Host/linux/AbstractSocket.h
  include/lldb/Host/posix/DomainSocket.h
  include/lldb/Host/posix/MainLoopPosix.h
  lldb.xcodeproj/project.pbxproj
  source/Host/CMakeLists.txt
  source/Host/common/MainLoop.cpp
  source/Host/common/Socket.cpp
  source/Host/common/TCPSocket.cpp
  source/Host/common/UDPSocket.cpp
  source/Host/linux/AbstractSocket.cpp
  source/Host/posix/ConnectionFileDescriptorPosix.cpp
  source/Host/posix/DomainSocket.cpp
  source/Host/posix/MainLoopPosix.cpp
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  tools/lldb-server/Acceptor.cpp
  unittests/Host/SocketTest.cpp
  unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
  unittests/debugserver/RNBSocketTest.cpp

Index: unittests/debugserver/RNBSocketTest.cpp
===
--- unittests/debugserver/RNBSocketTest.cpp
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -96,7 +96,7 @@
 ASSERT_EQ(bye, goodbye);
   } else {
 Socket *connected_socket;
-err = server_socket->Accept(addr_wrap, false, connected_socket);
+err = server_socket->Accept(connected_socket);
 if (err.Fail()) {
   llvm::errs() << err.AsCString();
   abort();
Index: unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
===
--- unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
+++ unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
@@ -33,15 +33,14 @@
 void Connect(GDBRemoteCommunication , GDBRemoteCommunication ) {
   bool child_processes_inherit = false;
   Error error;
-  TCPSocket listen_socket(child_processes_inherit, error);
+  TCPSocket listen_socket(true, child_processes_inherit);
   ASSERT_FALSE(error.Fail());
   error = listen_socket.Listen("127.0.0.1:0", 5);
   ASSERT_FALSE(error.Fail());
 
   Socket *accept_socket;
   std::future accept_error = std::async(std::launch::async, [&] {
-return listen_socket.Accept("127.0.0.1:0", child_processes_inherit,
-accept_socket);
+return listen_socket.Accept(accept_socket);
   });
 
   char connect_remote_address[64];
Index: unittests/Host/SocketTest.cpp
===
--- unittests/Host/SocketTest.cpp
+++ unittests/Host/SocketTest.cpp
@@ -44,8 +44,7 @@
const char *listen_remote_address,
bool child_processes_inherit, Socket **accept_socket,
Error *error) {
-*error = listen_socket->Accept(listen_remote_address,
-   child_processes_inherit, *accept_socket);
+*error = listen_socket->Accept(*accept_socket);
   }
 
   template 
@@ -56,7 +55,7 @@
 bool child_processes_inherit = false;
 Error error;
 std::unique_ptr listen_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = listen_socket_up->Listen(listen_remote_address, 5);
 EXPECT_FALSE(error.Fail());
@@ -70,7 +69,7 @@
 
 std::string connect_remote_address = get_connect_addr(*listen_socket_up);
 std::unique_ptr connect_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = connect_socket_up->Connect(connect_remote_address);
 EXPECT_FALSE(error.Fail());
@@ -141,6 +140,20 @@
   EXPECT_STREQ("65535", port_str.c_str());
   EXPECT_EQ(65535, port);
   EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[::1]:12345", host_str, port_str, port, ));
+  EXPECT_STREQ("::1", host_str.c_str());
+  EXPECT_STREQ("12345", port_str.c_str());
+  EXPECT_EQ(12345, port);
+  EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[abcd:12fg:AF58::1]:12345", host_str, port_str, port, ));
+  EXPECT_STREQ("abcd:12fg:AF58::1", host_str.c_str());
+  EXPECT_STREQ("12345", port_str.c_str());
+  EXPECT_EQ(12345, port);
+  EXPECT_TRUE(error.Success());
 }
 
 #ifndef LLDB_DISABLE_POSIX
Index: tools/lldb-server/Acceptor.cpp
===
--- tools/lldb-server/Acceptor.cpp
+++ tools/lldb-server/Acceptor.cpp
@@ -62,8 +62,7 @@
 
 Error Acceptor::Accept(const bool child_processes_inherit, Connection *) {
   Socket *conn_socket = nullptr;
-  auto error = m_listener_socket_up->Accept(
-  StringRef(m_name), child_processes_inherit, conn_socket);
+  auto error = 

[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-14 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 95355.
beanz added a comment.
Herald added a subscriber: mgorny.

Updating to use MainLoop class, and refactor MainLoop class to operate on 
Windows.

I've added error cases to the MainLoop class for functionality that is not 
supported. Specifically non-socket IOObjects are not supported on Windows, and 
signal handling requires either kqueue or ppoll. In practice that means signal 
handling is not supported on Windows, older Linux OSs and some BSD variants. 
That is all controlled by proper configure-time checks.


https://reviews.llvm.org/D31823

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/MainLoop.h
  include/lldb/Host/Socket.h
  include/lldb/Host/common/TCPSocket.h
  include/lldb/Host/common/UDPSocket.h
  include/lldb/Host/linux/AbstractSocket.h
  include/lldb/Host/posix/DomainSocket.h
  include/lldb/Host/posix/MainLoopPosix.h
  lldb.xcodeproj/project.pbxproj
  source/Host/CMakeLists.txt
  source/Host/common/MainLoop.cpp
  source/Host/common/Socket.cpp
  source/Host/common/TCPSocket.cpp
  source/Host/common/UDPSocket.cpp
  source/Host/linux/AbstractSocket.cpp
  source/Host/posix/ConnectionFileDescriptorPosix.cpp
  source/Host/posix/DomainSocket.cpp
  source/Host/posix/MainLoopPosix.cpp
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  tools/lldb-server/Acceptor.cpp
  unittests/Host/SocketTest.cpp
  unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
  unittests/debugserver/RNBSocketTest.cpp

Index: unittests/debugserver/RNBSocketTest.cpp
===
--- unittests/debugserver/RNBSocketTest.cpp
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -96,7 +96,7 @@
 ASSERT_EQ(bye, goodbye);
   } else {
 Socket *connected_socket;
-err = server_socket->Accept(addr_wrap, false, connected_socket);
+err = server_socket->Accept(connected_socket);
 if (err.Fail()) {
   llvm::errs() << err.AsCString();
   abort();
Index: unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
===
--- unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
+++ unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
@@ -33,15 +33,14 @@
 void Connect(GDBRemoteCommunication , GDBRemoteCommunication ) {
   bool child_processes_inherit = false;
   Error error;
-  TCPSocket listen_socket(child_processes_inherit, error);
+  TCPSocket listen_socket(true, child_processes_inherit);
   ASSERT_FALSE(error.Fail());
   error = listen_socket.Listen("127.0.0.1:0", 5);
   ASSERT_FALSE(error.Fail());
 
   Socket *accept_socket;
   std::future accept_error = std::async(std::launch::async, [&] {
-return listen_socket.Accept("127.0.0.1:0", child_processes_inherit,
-accept_socket);
+return listen_socket.Accept(accept_socket);
   });
 
   char connect_remote_address[64];
Index: unittests/Host/SocketTest.cpp
===
--- unittests/Host/SocketTest.cpp
+++ unittests/Host/SocketTest.cpp
@@ -44,8 +44,7 @@
const char *listen_remote_address,
bool child_processes_inherit, Socket **accept_socket,
Error *error) {
-*error = listen_socket->Accept(listen_remote_address,
-   child_processes_inherit, *accept_socket);
+*error = listen_socket->Accept(*accept_socket);
   }
 
   template 
@@ -56,7 +55,7 @@
 bool child_processes_inherit = false;
 Error error;
 std::unique_ptr listen_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = listen_socket_up->Listen(listen_remote_address, 5);
 EXPECT_FALSE(error.Fail());
@@ -70,7 +69,7 @@
 
 std::string connect_remote_address = get_connect_addr(*listen_socket_up);
 std::unique_ptr connect_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = connect_socket_up->Connect(connect_remote_address);
 EXPECT_FALSE(error.Fail());
@@ -141,6 +140,20 @@
   EXPECT_STREQ("65535", port_str.c_str());
   EXPECT_EQ(65535, port);
   EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[::1]:12345", host_str, port_str, port, ));
+  EXPECT_STREQ("::1", host_str.c_str());
+  EXPECT_STREQ("12345", port_str.c_str());
+  EXPECT_EQ(12345, port);
+  EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[abcd:12fg:AF58::1]:12345", host_str, port_str, port, ));
+  EXPECT_STREQ("abcd:12fg:AF58::1", host_str.c_str());
+  EXPECT_STREQ("12345", port_str.c_str());
+  EXPECT_EQ(12345, port);
+  EXPECT_TRUE(error.Success());
 }
 
 #ifndef LLDB_DISABLE_POSIX
Index: 

[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a reviewer: clayborg.
beanz added a comment.

Adding Greg to the reviewers list.


https://reviews.llvm.org/D31823



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31824: Update DebugServer to support IPv6 over TCP

2017-04-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a reviewer: clayborg.
beanz added a comment.

Adding Greg to the reviewers.


https://reviews.llvm.org/D31824



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31822: [NFC] Adding a new wrapper for getaddrinfo

2017-04-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added inline comments.



Comment at: include/lldb/Host/SocketAddress.h:44-45
+  
//
+  static std::vector GetAddressInfo(const char *hostname,
+ const char *servname);
+

zturner wrote:
> What about using `Twine` here instead of `const char *` literals?
I don't want to use `Twine` for this because in other patches I'm pulling this 
into debugserver which doesn't have any dependency on LLVM.


https://reviews.llvm.org/D31822



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 95024.
beanz added a comment.

Fixing up the include guard as per feedback from zturner, and fixing up an 
install logic error that I spoted.


https://reviews.llvm.org/D31969

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/android/Config.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/Config.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/mingw/Config.h
  include/lldb/Host/msvc/Config.h
  include/lldb/Host/netbsd/Config.h
  include/lldb/Host/openbsd/Config.h
  source/Host/common/File.cpp

Index: source/Host/common/File.cpp
===
--- source/Host/common/File.cpp
+++ source/Host/common/File.cpp
@@ -307,7 +307,7 @@
 
 Error File::GetFileSpec(FileSpec _spec) const {
   Error error;
-#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+#ifdef F_GETPATH
   if (IsValid()) {
 char path[PATH_MAX];
 if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
Index: include/lldb/Host/openbsd/Config.h
===
--- include/lldb/Host/openbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/netbsd/Config.h
===
--- include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/msvc/Config.h
===
--- include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/mingw/Config.h
===
--- include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -1,30 

[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-12 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

My intention in this patch is not in any way to adversely impact the Xcode 
project, which is the supported and documented way to build LLDB on OS X 
(http://lldb.llvm.org/build.html#BuildingLldbOnMacOSX).

The goal of this patch is to support configuration time capabilities inspection 
to aid in porting LLDB to other platforms via the CMake build system. By 
leaving the Host/Config.h header in LLDB's source tree we continue supporting 
the Xcode project, and we don't require changing the LLDB sources which include 
lldb/Host/Config.h. This seems like the best solution to me.




Comment at: cmake/modules/LLDBConfig.cmake:287-293
+  install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
+COMPONENT lldb_headers
+DESTINATION include
+FILES_MATCHING
+PATTERN "*.h"
+PATTERN ".svn" EXCLUDE
+PATTERN ".cmake" EXCLUDE

zturner wrote:
> Is this necessary?
CMake's documentation does not specify the order in which directories may be 
processed, and since the source and build directories will have an overlapping 
Config.h file we need to make sure the right one gets picked every time 
regardless of any changes to how CMake might handle the underlying 
implementation of the install command.


https://reviews.llvm.org/D31969



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-11 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 94928.
beanz added a comment.

Updating the hard coded Config.h


https://reviews.llvm.org/D31969

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/android/Config.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/Config.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/mingw/Config.h
  include/lldb/Host/msvc/Config.h
  include/lldb/Host/netbsd/Config.h
  include/lldb/Host/openbsd/Config.h
  source/Host/common/File.cpp

Index: source/Host/common/File.cpp
===
--- source/Host/common/File.cpp
+++ source/Host/common/File.cpp
@@ -307,7 +307,7 @@
 
 Error File::GetFileSpec(FileSpec _spec) const {
   Error error;
-#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+#ifdef F_GETPATH
   if (IsValid()) {
 char path[PATH_MAX];
 if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
Index: include/lldb/Host/openbsd/Config.h
===
--- include/lldb/Host/openbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/netbsd/Config.h
===
--- include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/msvc/Config.h
===
--- include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/mingw/Config.h
===
--- include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ 

[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-11 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 94925.
beanz added a comment.

Actually uploading the updates this time...


https://reviews.llvm.org/D31969

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/android/Config.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/Config.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/mingw/Config.h
  include/lldb/Host/msvc/Config.h
  include/lldb/Host/netbsd/Config.h
  include/lldb/Host/openbsd/Config.h
  source/Host/common/File.cpp

Index: source/Host/common/File.cpp
===
--- source/Host/common/File.cpp
+++ source/Host/common/File.cpp
@@ -307,7 +307,7 @@
 
 Error File::GetFileSpec(FileSpec _spec) const {
   Error error;
-#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+#ifdef F_GETPATH
   if (IsValid()) {
 char path[PATH_MAX];
 if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
Index: include/lldb/Host/openbsd/Config.h
===
--- include/lldb/Host/openbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/netbsd/Config.h
===
--- include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/msvc/Config.h
===
--- include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/mingw/Config.h
===
--- include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h 

[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-11 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 94924.
beanz added a comment.

- Fixing installation to make sure CMake always installs the generated Config.h
- Removing LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED becasue we really don't need it


https://reviews.llvm.org/D31969

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/android/Config.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/Config.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/mingw/Config.h
  include/lldb/Host/msvc/Config.h
  include/lldb/Host/netbsd/Config.h
  include/lldb/Host/openbsd/Config.h

Index: include/lldb/Host/openbsd/Config.h
===
--- include/lldb/Host/openbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/netbsd/Config.h
===
--- include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/msvc/Config.h
===
--- include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/mingw/Config.h
===
--- include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-

[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-11 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added subscribers: mgorny, srhines, emaste.

This patch removes the hand maintained config files in favor of auto-generating 
the config file. We will still need to maintain the defines for the Xcode 
builds on Mac, but all CMake builds use the generated header instead.

This will enable finer grained platform support tests and enable supporting 
LLDB on more platforms with less manual maintenance.

I have only tested this patch on Darwin, and any help testing it out on other 
platforms would be greatly appreciated. I've probably messed something up 
somewhere.


https://reviews.llvm.org/D31969

Files:
  cmake/modules/LLDBConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/android/Config.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/Config.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/mingw/Config.h
  include/lldb/Host/msvc/Config.h
  include/lldb/Host/netbsd/Config.h
  include/lldb/Host/openbsd/Config.h

Index: include/lldb/Host/openbsd/Config.h
===
--- include/lldb/Host/openbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/netbsd/Config.h
===
--- include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/msvc/Config.h
===
--- include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: include/lldb/Host/mingw/Config.h
===
--- include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h 

[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-11 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@labath, I could adapt this into the `MainLoop` class, but I would actually 
want to change how that class hierarchy is implemented. Regardless of the event 
handling/polling model you use much of the code is identical between the 
classes. I'd rather get rid of `MainLoopPosix` and `MainLoopBase` and instead 
just implement a portable `MainLoop` class.

In particular the difference between Windows `WSAPoll` and posix `poll(2)` is 
the name of two functions, which makes the idea of having separate Windows and 
Posix implementations just seem overly complicated to me, although neither 
Darwin nor Windows have `ppoll` because it isn't POSIX, and Windows doesn't 
have `pselect`, so there isn't a remotely portable way to wait on file 
descriptors and signals... This is why we can't have nice things.

I'm going to dig into the `MainLoop` code. At first glance I do think that is a 
better way to fit this all together, but I'm going to need to think on it and 
experiment a bit.


https://reviews.llvm.org/D31823



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-10 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added a subscriber: emaste.

This patch adds IPv6 support to LLDB/Host's TCP socket implementation. 
Supporting IPv6 involved a few significant changes to the implementation of the 
socket layers, and I have performed some significant code cleanup along the way.

This patch changes the Socket constructors for all types of sockets to not 
create sockets until first use. This is required for IPv6 support because the 
socket type will vary based on the address you are connecting to. This also has 
the benefit of removing code that could have errors from the Socket subclass 
constructors (which seems like a win to me).

The patch also slightly changes the API and behaviors of the Listen/Accept 
pattern. Previously both Listen and Accept calls took an address specified as a 
string. Now only listen does. This change was made because the Listen call can 
result in opening more than one socket. In order to support listening for both 
IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 
socket. During the listen call we construct a map of file descriptors to addrin 
structures which represent the allowable incoming connection address. This map 
removes the need for taking an address into the Accept call.

This does have a change in functionality. Previously you could Listen for 
connections based on one address, and Accept connections from a different 
address. This is no longer supported. I could not find anywhere in LLDB where 
we actually used the APIs in that way. The new API does still support AnyAddr 
for allowing incoming connections from any address.

The Listen implementation is implemented using kqueue on FreeBSD and Darwin, 
WSAPoll on Windows and poll(2) everywhere else.


https://reviews.llvm.org/D31823

Files:
  include/lldb/Host/Socket.h
  include/lldb/Host/common/TCPSocket.h
  include/lldb/Host/common/UDPSocket.h
  include/lldb/Host/freebsd/Config.h
  include/lldb/Host/linux/AbstractSocket.h
  include/lldb/Host/macosx/Config.h
  include/lldb/Host/posix/DomainSocket.h
  source/Host/common/Socket.cpp
  source/Host/common/TCPSocket.cpp
  source/Host/common/UDPSocket.cpp
  source/Host/linux/AbstractSocket.cpp
  source/Host/posix/ConnectionFileDescriptorPosix.cpp
  source/Host/posix/DomainSocket.cpp
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  tools/lldb-server/Acceptor.cpp
  unittests/Host/SocketTest.cpp
  unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp

Index: unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
===
--- unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
+++ unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
@@ -33,15 +33,14 @@
 void Connect(GDBRemoteCommunication , GDBRemoteCommunication ) {
   bool child_processes_inherit = false;
   Error error;
-  TCPSocket listen_socket(child_processes_inherit, error);
+  TCPSocket listen_socket(true, child_processes_inherit);
   ASSERT_FALSE(error.Fail());
   error = listen_socket.Listen("127.0.0.1:0", 5);
   ASSERT_FALSE(error.Fail());
 
   Socket *accept_socket;
   std::future accept_error = std::async(std::launch::async, [&] {
-return listen_socket.Accept("127.0.0.1:0", child_processes_inherit,
-accept_socket);
+return listen_socket.Accept(accept_socket);
   });
 
   char connect_remote_address[64];
Index: unittests/Host/SocketTest.cpp
===
--- unittests/Host/SocketTest.cpp
+++ unittests/Host/SocketTest.cpp
@@ -44,8 +44,7 @@
const char *listen_remote_address,
bool child_processes_inherit, Socket **accept_socket,
Error *error) {
-*error = listen_socket->Accept(listen_remote_address,
-   child_processes_inherit, *accept_socket);
+*error = listen_socket->Accept(*accept_socket);
   }
 
   template 
@@ -56,7 +55,7 @@
 bool child_processes_inherit = false;
 Error error;
 std::unique_ptr listen_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = listen_socket_up->Listen(listen_remote_address, 5);
 EXPECT_FALSE(error.Fail());
@@ -70,7 +69,7 @@
 
 std::string connect_remote_address = get_connect_addr(*listen_socket_up);
 std::unique_ptr connect_socket_up(
-new SocketType(child_processes_inherit, error));
+new SocketType(true, child_processes_inherit));
 EXPECT_FALSE(error.Fail());
 error = connect_socket_up->Connect(connect_remote_address);
 EXPECT_FALSE(error.Fail());
@@ -141,6 +140,20 @@
   EXPECT_STREQ("65535", port_str.c_str());
   EXPECT_EQ(65535, port);
   EXPECT_TRUE(error.Success());
+
+  EXPECT_TRUE(
+  Socket::DecodeHostAndPort("[::1]:12345", host_str, port_str, port, ));
+  

[Lldb-commits] [PATCH] D31822: [NFC] Adding a new wrapper for getaddrinfo

2017-04-10 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.

This patch adds a new wrapper for getaddrinfo which returns a std::vector of 
SocketAddresses. While this patch doesn't add any uses of the new function, I 
have two separable patches that are dependent on this, so I put it in its own 
patch.


https://reviews.llvm.org/D31822

Files:
  include/lldb/Host/SocketAddress.h
  source/Host/common/SocketAddress.cpp

Index: source/Host/common/SocketAddress.cpp
===
--- source/Host/common/SocketAddress.cpp
+++ source/Host/common/SocketAddress.cpp
@@ -89,6 +89,10 @@
   m_socket_addr.sa_storage = s;
 }
 
+SocketAddress::SocketAddress(const struct addrinfo *addr_info) {
+  *this = addr_info;
+}
+
 //--
 // SocketAddress copy constructor
 //--
@@ -244,6 +248,24 @@
   return result;
 }
 
+std::vector SocketAddress::GetAddressInfo(const char *hostname,
+   const char *servname) {
+  std::vector addr_list;
+
+  struct addrinfo *service_info_list = NULL;
+  int err = ::getaddrinfo(hostname, servname, NULL, _info_list);
+  if (err == 0 && service_info_list) {
+for (struct addrinfo *service_ptr = service_info_list; service_ptr != NULL;
+ service_ptr = service_ptr->ai_next) {
+  addr_list.push_back(SocketAddress(service_ptr));
+}
+  }
+
+  if (service_info_list)
+::freeaddrinfo(service_info_list);
+  return addr_list;
+}
+
 bool SocketAddress::SetToLocalhost(sa_family_t family, uint16_t port) {
   switch (family) {
   case AF_INET:
@@ -287,3 +309,29 @@
   Clear();
   return false;
 }
+
+bool SocketAddress::IsAnyAddr() const {
+  return (GetFamily() == AF_INET)
+ ? m_socket_addr.sa_ipv4.sin_addr.s_addr == htonl(INADDR_ANY)
+ : 0 == memcmp(_socket_addr.sa_ipv6.sin6_addr, _any, 16);
+}
+
+bool SocketAddress::operator==(const SocketAddress ) const {
+  if (GetFamily() != rhs.GetFamily())
+return false;
+  if (GetLength() != rhs.GetLength())
+return false;
+  switch (GetFamily()) {
+  case AF_INET:
+return m_socket_addr.sa_ipv4.sin_addr.s_addr ==
+   rhs.m_socket_addr.sa_ipv4.sin_addr.s_addr;
+  case AF_INET6:
+return 0 == memcmp(_socket_addr.sa_ipv6.sin6_addr,
+   _socket_addr.sa_ipv6.sin6_addr, 16);
+  }
+  return false;
+}
+
+bool SocketAddress::operator!=(const SocketAddress ) const {
+  return !(*this == rhs);
+}
Index: include/lldb/Host/SocketAddress.h
===
--- include/lldb/Host/SocketAddress.h
+++ include/lldb/Host/SocketAddress.h
@@ -32,15 +32,23 @@
 // Other libraries and framework includes
 // Project includes
 #include 
+#include 
 
 namespace lldb_private {
 
 class SocketAddress {
 public:
+  //
+  // Static method to get all address information for a host and/or service
+  //
+  static std::vector GetAddressInfo(const char *hostname,
+ const char *servname);
+
   //--
   // Constructors and Destructors
   //--
   SocketAddress();
+  SocketAddress(const struct addrinfo *addr_info);
   SocketAddress(const struct sockaddr );
   SocketAddress(const struct sockaddr_in );
   SocketAddress(const struct sockaddr_in6 );
@@ -63,6 +71,9 @@
 
   const SocketAddress =(const struct sockaddr_storage );
 
+  bool operator==(const SocketAddress ) const;
+  bool operator!=(const SocketAddress ) const;
+
   //--
   // Clear the contents of this socket address
   //--
@@ -135,6 +146,11 @@
   bool IsValid() const;
 
   //--
+  // Returns true if the socket is INADDR_ANY
+  //--
+  bool IsAnyAddr() const;
+
+  //--
   // Direct access to all of the sockaddr structures
   //--
   struct sockaddr () {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-10 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 94526.
beanz added a comment.

Fixing variable naming conventions


https://reviews.llvm.org/D31357

Files:
  tools/debugserver/source/CMakeLists.txt
  tools/debugserver/source/MacOSX/CMakeLists.txt
  unittests/CMakeLists.txt
  unittests/debugserver/CMakeLists.txt
  unittests/debugserver/RNBSocketTest.cpp
  unittests/debugserver/debugserver_LogCallback.cpp

Index: unittests/debugserver/debugserver_LogCallback.cpp
===
--- /dev/null
+++ unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+//--
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//--
+
+#include 
+#include 
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
Index: unittests/debugserver/RNBSocketTest.cpp
===
--- /dev/null
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,133 @@
+//===-- RNBSocketTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+
+#include "RNBDefs.h"
+#include "RNBSocket.h"
+#include "lldb/Host/Socket.h"
+#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/common/TCPSocket.h"
+
+using namespace lldb_private;
+
+std::string hello = "Hello, world!";
+std::string goodbye = "Goodbye!";
+
+static void ServerCallbackv4(const void *baton, in_port_t port) {
+  auto child_pid = fork();
+  if (child_pid == 0) {
+Socket *client_socket;
+char addr_buffer[256];
+sprintf(addr_buffer, "%s:%d", baton, port);
+Error err = Socket::TcpConnect(addr_buffer, false, client_socket);
+if (err.Fail())
+  abort();
+char buffer[32];
+size_t read_size = 32;
+err = client_socket->Read((void *)[0], read_size);
+if (err.Fail())
+  abort();
+std::string Recv([0], read_size);
+if (Recv != hello)
+  abort();
+size_t write_size = goodbye.length();
+err = client_socket->Write(goodbye.c_str(), write_size);
+if (err.Fail())
+  abort();
+if (write_size != goodbye.length())
+  abort();
+delete client_socket;
+exit(0);
+  }
+}
+
+void TestSocketListen(const char *addr) {
+  RNBSocket server_socket;
+  auto result =
+  server_socket.Listen(addr, 0, ServerCallbackv4, (const void *)addr);
+  ASSERT_TRUE(result == rnb_success);
+  result = server_socket.Write(hello.c_str(), hello.length());
+  ASSERT_TRUE(result == rnb_success);
+  std::string bye;
+  result = server_socket.Read(bye);
+  ASSERT_TRUE(result == rnb_success);
+  ASSERT_EQ(bye, goodbye);
+
+  int exit_status;
+  wait(_status);
+  ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackListenIPv4) { TestSocketListen("127.0.0.1"); }
+
+void TestSocketConnect(const char *addr) {
+  char addr_wrap[256];
+  sprintf(addr_wrap, "%s:0", addr);
+
+  Socket *server_socket;
+  Predicate port_predicate;
+  port_predicate.SetValue(0, eBroadcastNever);
+  Error err =
+  Socket::TcpListen(addr_wrap, false, server_socket, _predicate);
+  ASSERT_FALSE(err.Fail());
+
+  auto port = ((TCPSocket *)server_socket)->GetLocalPortNumber();
+  auto child_pid = fork();
+  if (child_pid != 0) {
+RNBSocket client_socket;
+auto result = client_socket.Connect(addr, port);
+ASSERT_TRUE(result == rnb_success);
+result = client_socket.Write(hello.c_str(), hello.length());
+ASSERT_TRUE(result == rnb_success);
+std::string bye;
+result = client_socket.Read(bye);
+ASSERT_TRUE(result == rnb_success);
+ASSERT_EQ(bye, goodbye);
+  } else {
+Socket *connected_socket;
+err = server_socket->Accept(connected_socket);
+if (err.Fail()) {
+  llvm::errs() << err.AsCString();
+  abort();
+}
+char buffer[32];
+size_t read_size = 32;
+err = connected_socket->Read((void *)[0], read_size);
+if (err.Fail()) {
+  llvm::errs() << err.AsCString();
+  abort();
+}
+std::string Recv([0], read_size);
+if (Recv != hello) {
+  llvm::errs() << err.AsCString();
+  abort();
+}
+ 

[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I will fix up the naming conventions. Switching back and forth between LLVM and 
LLDB conventions has done a number on my brain.

The test cases only abort on the child process side of the fork calls. This 
results in printing a stack trace, but it also will get captured as a failure 
because the parent process side checks the exit status of the child.


https://reviews.llvm.org/D31357



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a reviewer: jingham.
beanz added a comment.

Adding Jim as a reviewer.

Jim, with the added comment about debugserver being Darwin-only, are you happy 
with this patch?


https://reviews.llvm.org/D31357



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 94374.
beanz added a comment.

Some cleanup to the test case:

- Auto-select a port, which will make this more reliable
- Open listening sockets before the fork() so that the sockets are ready for 
connection (this avoids a race)
- Put test logic into reusable functions so that test logic can be reused for 
IPv6 tests when I add them


https://reviews.llvm.org/D31357

Files:
  tools/debugserver/source/CMakeLists.txt
  tools/debugserver/source/MacOSX/CMakeLists.txt
  unittests/CMakeLists.txt
  unittests/debugserver/CMakeLists.txt
  unittests/debugserver/RNBSocketTest.cpp
  unittests/debugserver/debugserver_LogCallback.cpp

Index: unittests/debugserver/debugserver_LogCallback.cpp
===
--- /dev/null
+++ unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+//--
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//--
+
+#include 
+#include 
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
Index: unittests/debugserver/RNBSocketTest.cpp
===
--- /dev/null
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,137 @@
+//===-- RNBSocketTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+
+#include "RNBSocket.h"
+#include "RNBDefs.h"
+#include "lldb/Host/Socket.h"
+#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/common/TCPSocket.h"
+
+using namespace lldb_private;
+
+std::string Hello = "Hello, world!";
+std::string Goodbye = "Goodbye!";
+
+static void ServerCallbackv4(const void *baton, in_port_t port) {
+  auto ChildPID = fork();
+  if (ChildPID == 0) {
+Socket *ClientSocket;
+char AddrBuffer[256];
+sprintf(AddrBuffer, "%s:%d", baton, port);
+Error Err = Socket::TcpConnect(AddrBuffer, false, ClientSocket);
+if (Err.Fail())
+  abort();
+char Buffer[32];
+size_t ReadSize = 32;
+Err = ClientSocket->Read((void *)[0], ReadSize);
+if (Err.Fail())
+  abort();
+std::string Recv([0], ReadSize);
+if (Recv != Hello)
+  abort();
+size_t WriteSize = Goodbye.length();
+Err = ClientSocket->Write(Goodbye.c_str(), WriteSize);
+if (Err.Fail())
+  abort();
+if (WriteSize != Goodbye.length())
+  abort();
+delete ClientSocket;
+exit(0);
+  }
+}
+
+void TestSocketListen(const char * addr) {
+  RNBSocket ServerSocket;
+  auto result =
+  ServerSocket.Listen(addr, 0, ServerCallbackv4, (const void *)addr);
+  ASSERT_TRUE(result == rnb_success);
+  result = ServerSocket.Write(Hello.c_str(), Hello.length());
+  ASSERT_TRUE(result == rnb_success);
+  std::string Bye;
+  result = ServerSocket.Read(Bye);
+  ASSERT_TRUE(result == rnb_success);
+  ASSERT_EQ(Bye, Goodbye);
+
+  int exit_status;
+  wait(_status);
+  ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  TestSocketListen("127.0.0.1");
+}
+
+void TestSocketConnect(const char *addr) {
+  char addr_wrap[256];
+  sprintf(addr_wrap, "%s:0", addr);
+  
+  Socket *ServerSocket;
+  Predicate PortPredicate;
+  PortPredicate.SetValue(0, eBroadcastNever);
+  Error Err =
+  Socket::TcpListen(addr_wrap, false, ServerSocket, );
+  ASSERT_FALSE(Err.Fail());
+
+  auto port = ((TCPSocket*)ServerSocket)->GetLocalPortNumber();
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ClientSocket;
+auto result = ClientSocket.Connect(addr, port);
+ASSERT_TRUE(result == rnb_success);
+result = ClientSocket.Write(Hello.c_str(), Hello.length());
+ASSERT_TRUE(result == rnb_success);
+std::string Bye;
+result = ClientSocket.Read(Bye);
+ASSERT_TRUE(result == rnb_success);
+ASSERT_EQ(Bye, Goodbye);
+  } else {
+Socket *ConnectedSocket;
+Err = ServerSocket->Accept(addr_wrap, false, ConnectedSocket);
+if (Err.Fail()) {
+  llvm::errs() << Err.AsCString();
+  abort();
+}
+char Buffer[32];
+size_t ReadSize = 32;
+Err = 

[Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component

2017-04-03 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a subscriber: lhames.
beanz added a comment.

@mgorny, because of differences in linker semantics between Darwin and ELF, I 
can't reproduce the failure you have locally. I think that the patch below 
works around it in a more-portable way.

I've engaged with @lhames about an architectural solution to the problem, 
because I think we do need to change how the ExecutionEngine sub-libraries are 
intertwined, but that is a longer-term problem.

Can you please test this patch and see if it resolves your problem?

  diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
  index 7f7608cff33..1f27517c2df 100644
  --- a/cmake/modules/AddLLVM.cmake
  +++ b/cmake/modules/AddLLVM.cmake
  @@ -342,7 +342,7 @@ endfunction(set_windows_version_resource_properties)
   function(llvm_add_library name)
 cmake_parse_arguments(ARG
   "MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
  -"OUTPUT_NAME;PLUGIN_TOOL"
  +"OUTPUT_NAME;PLUGIN_TOOL;DEPENDENCY_LINK_TYPE"
   "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
   ${ARGN})
 list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
  @@ -520,14 +520,16 @@ function(llvm_add_library name)
   get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
 endif()
   
  -  if(ARG_STATIC)
  -set(libtype INTERFACE)
  -  else()
  -# We can use PRIVATE since SO knows its dependent libs.
  -set(libtype PRIVATE)
  +  if(NOT ARG_DEPENDENCY_LINK_TYPE)
  +if(ARG_STATIC)
  +  set(ARG_DEPENDENCY_LINK_TYPE INTERFACE)
  +else()
  +  # We can use PRIVATE since SO knows its dependent libs.
  +  set(ARG_DEPENDENCY_LINK_TYPE PRIVATE)
  +endif()
 endif()
   
  -  target_link_libraries(${name} ${libtype}
  +  target_link_libraries(${name} ${ARG_DEPENDENCY_LINK_TYPE}
 ${ARG_LINK_LIBS}
 ${lib_deps}
 ${llvm_libs}
  diff --git a/lib/ExecutionEngine/CMakeLists.txt 
b/lib/ExecutionEngine/CMakeLists.txt
  index 2d9337bbefd..37a57eeaa79 100644
  --- a/lib/ExecutionEngine/CMakeLists.txt
  +++ b/lib/ExecutionEngine/CMakeLists.txt
  @@ -1,4 +1,9 @@
  -
  +# Execution engine is not neat and contained like other LLVM libraries. To 
work
  +# around this if BUILD_SHARED_LIBS is set we need to force the linkage type 
of
  +# LLVMExecutionEngine's dependencies to PUBLIC.
  +if(BUILD_SHARED_LIBS)
  +  set(dependency_hack DEPENDENCY_LINK_TYPE PUBLIC)
  +endif()
   
   add_llvm_library(LLVMExecutionEngine
 ExecutionEngine.cpp
  @@ -12,6 +17,7 @@ add_llvm_library(LLVMExecutionEngine
   
 DEPENDS
 intrinsics_gen
  +  ${dependency_hack}
 )
   
   add_subdirectory(Interpreter)


Repository:
  rL LLVM

https://reviews.llvm.org/D31367



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component

2017-03-30 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Please revert your patch. It is *not* the right solution and is masking 
underlying problems.

ExecutionEngine headers directly reference symbols from RuntimeDyld, so we 
should enforce a requirement that anyone using ExeuctionEngine also link 
RuntimeDyld. This works today as expected for static archive builds. It is only 
broken with `BUILD_SHARED_LIBS`. I suspect the problem is that when built as a 
DSO ExecutionEngine has no unresolved symbols against RuntimeDyld, and the 
linker probably isn't including the reference to RuntimeDyld in the produced 
ExecutionEngine DSO.

Regardless of the underlying cause, this is not the correct solution, it merely 
hides a problem that could occur in other consumers of ExecutionEngine.


Repository:
  rL LLVM

https://reviews.llvm.org/D31367



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31367: Expression: add missing linkage to RuntimeDyld component

2017-03-30 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

This is definitely not the right fix. Please revert.

ExecutionEngine's LLVMBuild.txt file explicitly lists that RuntimeDyld is a 
required library of ExecutionEngine (as well as a few others). LLVM's CMake 
should be connecting that as an explicit dependency, and for some reason it 
isn't. Adding over-specified dependencies in LLDB to workaround bugs in LLVM is 
not the right approach, and masks problems instead of resolving them.


Repository:
  rL LLVM

https://reviews.llvm.org/D31367



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-03-27 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@jingham I put the unit tests at the top because they depend on LLDB's Host 
library (at least the current tests do). I'm attempting to write tests which 
cover the socket communication between LLDB and debugserver by sending data 
between the two using each side of the API.


https://reviews.llvm.org/D31357



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-03-27 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 93165.
beanz added a comment.

Fleshed out the unit test logic to be more meaningful.


https://reviews.llvm.org/D31357

Files:
  tools/debugserver/source/CMakeLists.txt
  tools/debugserver/source/MacOSX/CMakeLists.txt
  unittests/CMakeLists.txt
  unittests/debugserver/CMakeLists.txt
  unittests/debugserver/RNBSocketTest.cpp
  unittests/debugserver/debugserver_LogCallback.cpp

Index: unittests/debugserver/debugserver_LogCallback.cpp
===
--- /dev/null
+++ unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+//--
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//--
+
+#include 
+#include 
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
Index: unittests/debugserver/RNBSocketTest.cpp
===
--- /dev/null
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,109 @@
+//===-- RNBSocketTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include 
+#include 
+
+#include "RNBSocket.h"
+#include "RNBDefs.h"
+#include "lldb/Host/Socket.h"
+
+using namespace lldb_private;
+
+static void ServerCallback(const void *baton, in_port_t port) {}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  std::string Hello = "Hello, world!";
+  std::string Goodbye = "Goodbye!";
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ServerSocket;
+auto result = ServerSocket.Listen("localhost", 4242, ServerCallback, NULL);
+ASSERT_TRUE(result == rnb_success);
+result = ServerSocket.Write(Hello.c_str(), Hello.length());
+ASSERT_TRUE(result == rnb_success);
+std::string Bye;
+result = ServerSocket.Read(Bye);
+ASSERT_TRUE(result == rnb_success);
+ASSERT_EQ(Bye, Goodbye);
+  } else {
+Socket *ClientSocket;
+Error Err = Socket::TcpConnect("localhost:4242", false, ClientSocket);
+if (Err.Fail())
+  abort();
+char Buffer[32];
+size_t ReadSize = 32;
+Err = ClientSocket->Read((void*)[0], ReadSize);
+if (Err.Fail())
+  abort();
+std::string Recv([0], ReadSize);
+if (Recv != Hello)
+  abort();
+size_t WriteSize = Goodbye.length();
+Err = ClientSocket->Write(Goodbye.c_str(), WriteSize);
+if (Err.Fail())
+  abort();
+if (WriteSize != Goodbye.length())
+  abort();
+exit(0);
+  }
+  int exit_status;
+  wait(_status);
+  ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackConnectIPv4) {
+  Socket *ServerSocket;
+  Predicate PortPredicate;
+  PortPredicate.SetValue(0, eBroadcastNever);
+  Error Err = Socket::TcpListen("localhost:4242", false, ServerSocket,
+);
+  ASSERT_FALSE(Err.Fail());
+
+  std::string Hello = "Hello, world!";
+  std::string Goodbye = "Goodbye!";
+
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ClientSocket;
+auto result = ClientSocket.Connect("localhost", 4242);
+ASSERT_TRUE(result == rnb_success);
+result = ClientSocket.Write(Hello.c_str(), Hello.length());
+ASSERT_TRUE(result == rnb_success);
+std::string Bye;
+result = ClientSocket.Read(Bye);
+ASSERT_TRUE(result == rnb_success);
+ASSERT_EQ(Bye, Goodbye);
+  } else {
+Socket *ConnectedSocket;
+Err = ServerSocket->Accept("localhost:4242", false, ConnectedSocket);
+if (Err.Fail())
+  abort();
+char Buffer[32];
+size_t ReadSize = 32;
+Err = ConnectedSocket->Read((void*)[0], ReadSize);
+if (Err.Fail())
+  abort();
+std::string Recv([0], ReadSize);
+if (Recv != Hello)
+  abort();
+size_t WriteSize = Goodbye.length();
+Err = ConnectedSocket->Write(Goodbye.c_str(), WriteSize);
+if (Err.Fail())
+  abort();
+if (WriteSize != Goodbye.length())
+  abort();
+exit(0);
+  }
+  int exit_status;
+  wait(_status);
+  ASSERT_EQ(exit_status, 0);
+}
Index: unittests/debugserver/CMakeLists.txt
===
--- /dev/null
+++ 

[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-03-24 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Xcode is pretty magic to me. I don't know how to do much of anything in it 
other than build. I think the right solution would be to take most of the 
source files out of the debugserver target and generate a static archive from 
them, then have debugserver and the debugserverTest target link the static 
archive.

I don't know how to do that and not screw up the Xcode target settings on the 
archive target.


https://reviews.llvm.org/D31357



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-03-24 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added a subscriber: mgorny.

This patch refactors the CMake build system's support for building debugserver 
to allow us to build the majority of debugserver's sources into the 
debugserverCommon library which can then be reused by unit tests.

The first unit test I've written tests debug server's ability to accept 
incoming connections from LLDB. The test forks the process, and one side 
creates a listening socket using debugserver's socket API, the other side 
creates a transmitting socket using LLDB's TCPSocket class.

I have no clue where to even start getting this connected into the LLDB Xcode 
project, so for now these tests are CMake-only.


https://reviews.llvm.org/D31357

Files:
  tools/debugserver/source/CMakeLists.txt
  tools/debugserver/source/MacOSX/CMakeLists.txt
  unittests/CMakeLists.txt
  unittests/debugserver/CMakeLists.txt
  unittests/debugserver/RNBSocketTest.cpp
  unittests/debugserver/debugserver_LogCallback.cpp

Index: unittests/debugserver/debugserver_LogCallback.cpp
===
--- /dev/null
+++ unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+//--
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//--
+
+#include 
+#include 
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
\ No newline at end of file
Index: unittests/debugserver/RNBSocketTest.cpp
===
--- /dev/null
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,35 @@
+//===-- RNBSocketTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include 
+#include 
+
+#include "RNBSocket.h"
+#include "lldb/Host/Socket.h"
+
+using namespace lldb_private;
+
+static void ServerCallback(const void *baton, in_port_t port) {}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ServerSocket;
+auto result = ServerSocket.Listen("localhost", 4242, ServerCallback, NULL);
+ASSERT_FALSE(result);
+  } else {
+Socket *ClientSocket;
+Error Err = Socket::TcpConnect("localhost:4242", false, ClientSocket);
+if (Err.Fail())
+  abort();
+exit(0);
+  }
+}
Index: unittests/debugserver/CMakeLists.txt
===
--- /dev/null
+++ unittests/debugserver/CMakeLists.txt
@@ -0,0 +1,13 @@
+include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source
+${LLDB_SOURCE_DIR}/tools/debugserver/source/MacOSX)
+
+add_lldb_unittest(debugserverTests
+  RNBSocketTest.cpp
+  debugserver_LogCallback.cpp
+
+  LINK_LIBS
+lldbDebugserverCommon
+lldbHost
+  LINK_COMPONENTS
+Support
+  )
Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -70,3 +70,7 @@
 add_subdirectory(Target)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
+
+if(LLDB_CAN_USE_DEBUGSERVER)
+  add_subdirectory(debugserver)
+endif()
\ No newline at end of file
Index: tools/debugserver/source/MacOSX/CMakeLists.txt
===
--- tools/debugserver/source/MacOSX/CMakeLists.txt
+++ tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -6,70 +6,3 @@
 add_subdirectory(DarwinLog)
 
 include_directories(..)
-
-set(generated_mach_interfaces
-  ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
-  ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
-  ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
-  )
-add_custom_command(OUTPUT ${generated_mach_interfaces}
-  COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
-  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
-  )
-
-set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
-
-add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
-  COMMAND 

[Lldb-commits] [PATCH] D30918: [debugserver] This is a small cleanup patch to AVX support detection

2017-03-13 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 91643.
beanz added a comment.

Updates based on feedback from Jason and Zachary.


https://reviews.llvm.org/D30918

Files:
  tools/debugserver/debugserver.xcodeproj/project.pbxproj
  tools/debugserver/source/MacOSX/CMakeLists.txt
  tools/debugserver/source/MacOSX/HasAVX.h
  tools/debugserver/source/MacOSX/HasAVX.s
  tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
  tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Index: tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
===
--- tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include "../HasAVX.h"
 #include "DNBLog.h"
 #include "MacOSX/x86_64/DNBArchImplX86_64.h"
 #include "MachProcess.h"
@@ -60,42 +59,64 @@
 #define FORCE_AVX_REGS (0)
 #endif
 
-extern "C" bool CPUHasAVX() {
-  enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+bool DetectHardwareFeature(const char *feature) {
+  int answer = 0;
+  size_t answer_size = sizeof(answer);
+  int error = ::sysctlbyname(feature, , _size, NULL, 0);
+  return error != 0 && answer != 0
+}
+
+enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
 
+bool LogAVXAndReturn(AVXPresence has_avx, int err, const char * os_ver) {
+  DNBLogThreadedIf(LOG_THREAD,
+   "CPUHasAVX(): g_has_avx = %i (err = %i, os_ver = %s)",
+   has_avx, err, os_ver);
+  return (has_avx == eAVXPresent);
+}
+
+extern "C" bool CPUHasAVX() {
   static AVXPresence g_has_avx = eAVXUnknown;
-  if (g_has_avx == eAVXUnknown) {
-g_has_avx = eAVXNotPresent;
-
-// Only xnu-2020 or later has AVX support, any versions before
-// this have a busted thread_get_state RPC where it would truncate
-// the thread state buffer (). So we need to
-// verify the kernel version number manually or disable AVX support.
-int mib[2];
-char buffer[1024];
-size_t length = sizeof(buffer);
-uint64_t xnu_version = 0;
-mib[0] = CTL_KERN;
-mib[1] = KERN_VERSION;
-int err = ::sysctl(mib, 2, , , NULL, 0);
-if (err == 0) {
-  const char *xnu = strstr(buffer, "xnu-");
-  if (xnu) {
-const char *xnu_version_cstr = xnu + 4;
-xnu_version = strtoull(xnu_version_cstr, NULL, 0);
-if (xnu_version >= 2020 && xnu_version != ULLONG_MAX) {
-  if (::HasAVX()) {
-g_has_avx = eAVXPresent;
-  }
-}
-  }
-}
-DNBLogThreadedIf(LOG_THREAD, "CPUHasAVX(): g_has_avx = %i (err = %i, errno "
- "= %i, xnu_version = %llu)",
- g_has_avx, err, errno, xnu_version);
+  if (g_has_avx != eAVXUnknown)
+return LogAVXAndReturn(g_has_avx, 0, "");
+
+  g_has_avx = eAVXNotPresent;
+
+  // OS X 10.7.3 and earlier have a bug in thread_get_state that truncated the
+  // size of the return. To work around this we have to disable AVX debugging
+  // on hosts prior to 10.7.3 ().
+  int mib[2];
+  char buffer[1024];
+  size_t length = sizeof(buffer);
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_OSVERSION;
+
+  // KERN_OSVERSION returns the build number which is a number signifying the
+  // major version, a capitol letter signifying the minor version, and numbers
+  // signifying the build (ex: on 10.12.3, the returned value is 16D32).
+  int err = ::sysctl(mib, 2, , , NULL, 0);
+  if (err != 0)
+return LogAVXAndReturn(g_has_avx, err, "");
+
+  size_t first_letter = 0;
+  for (; first_letter < length; ++first_letter) {
+// This is looking for the first uppercase letter
+if (buffer[first_letter] >= 'A')
+  break;
   }
-
-  return (g_has_avx == eAVXPresent);
+  char letter = buffer[first_letter];
+  buffer[first_letter] = '\0';
+  auto major_ver = strtoull(buffer, NULL, 0);
+  buffer[first_letter] = letter;
+
+  // In this check we're looking to see that our major and minor version numer
+  // was >= 11E, which is the 10.7.4 release.
+  if (major_ver < 11 || (major_ver == 11 && letter < 'E'))
+return LogAVXAndReturn(g_has_avx, err, buffer);
+  if (DetectHardwareFeature("hw.optional.avx1_0"))
+g_has_avx = eAVXPresent;
+
+  return LogAVXAndReturn(g_has_avx, err, buffer);
 }
 
 uint64_t DNBArchImplX86_64::GetPC(uint64_t failValue) {
Index: tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
===
--- tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
+++ tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
@@ -16,7 +16,6 @@
 
 #if defined(__i386__) || defined(__x86_64__)
 
-#include "../HasAVX.h"
 #include "DNBArch.h"
 #include "MachRegisterStatesI386.h"
 
Index: tools/debugserver/source/MacOSX/HasAVX.s
===
--- tools/debugserver/source/MacOSX/HasAVX.s
+++ /dev/null
@@ -1,50 

[Lldb-commits] [PATCH] D30918: [debugserver] This is a small cleanup patch to AVX support detection

2017-03-13 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 91640.
beanz added a comment.

Removing some extra changes that accidentally came along for the ride in my 
initial upload.


https://reviews.llvm.org/D30918

Files:
  tools/debugserver/debugserver.xcodeproj/project.pbxproj
  tools/debugserver/source/MacOSX/CMakeLists.txt
  tools/debugserver/source/MacOSX/HasAVX.h
  tools/debugserver/source/MacOSX/HasAVX.s
  tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
  tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Index: tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
===
--- tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include "../HasAVX.h"
 #include "DNBLog.h"
 #include "MacOSX/x86_64/DNBArchImplX86_64.h"
 #include "MachProcess.h"
@@ -60,42 +59,56 @@
 #define FORCE_AVX_REGS (0)
 #endif
 
-extern "C" bool CPUHasAVX() {
-  enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+bool DetectHardwareFeature(const char *feature) {
+  int answer = 0;
+  size_t answer_size = sizeof(answer);
+  int error = ::sysctlbyname(feature, , _size, NULL, 0);
+  return !error & answer;
+}
+
+enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
 
+bool LogAVXAndReturn(AVXPresence has_avx, int err, const char * os_ver) {
+  DNBLogThreadedIf(LOG_THREAD,
+   "CPUHasAVX(): g_has_avx = %i (err = %i, os_ver = %s)",
+   has_avx, err, os_ver);
+  return (has_avx == eAVXPresent);
+}
+
+extern "C" bool CPUHasAVX() {
   static AVXPresence g_has_avx = eAVXUnknown;
-  if (g_has_avx == eAVXUnknown) {
-g_has_avx = eAVXNotPresent;
-
-// Only xnu-2020 or later has AVX support, any versions before
-// this have a busted thread_get_state RPC where it would truncate
-// the thread state buffer (). So we need to
-// verify the kernel version number manually or disable AVX support.
-int mib[2];
-char buffer[1024];
-size_t length = sizeof(buffer);
-uint64_t xnu_version = 0;
-mib[0] = CTL_KERN;
-mib[1] = KERN_VERSION;
-int err = ::sysctl(mib, 2, , , NULL, 0);
-if (err == 0) {
-  const char *xnu = strstr(buffer, "xnu-");
-  if (xnu) {
-const char *xnu_version_cstr = xnu + 4;
-xnu_version = strtoull(xnu_version_cstr, NULL, 0);
-if (xnu_version >= 2020 && xnu_version != ULLONG_MAX) {
-  if (::HasAVX()) {
-g_has_avx = eAVXPresent;
-  }
-}
-  }
-}
-DNBLogThreadedIf(LOG_THREAD, "CPUHasAVX(): g_has_avx = %i (err = %i, errno "
- "= %i, xnu_version = %llu)",
- g_has_avx, err, errno, xnu_version);
+  if (g_has_avx != eAVXUnknown)
+return LogAVXAndReturn(g_has_avx, 0, "");
+
+  g_has_avx = eAVXNotPresent;
+
+  // OS X 10.7.3 and earlier have a bug in thread_get_state that truncated the
+  // size of the return. To work around this we have to disable AVX debugging
+  // on hosts prior to 10.7.3 ().
+  int mib[2];
+  char buffer[1024];
+  size_t length = sizeof(buffer);
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_OSVERSION;
+  int err = ::sysctl(mib, 2, , , NULL, 0);
+  if (err != 0)
+return LogAVXAndReturn(g_has_avx, err, "");
+
+  size_t first_letter = 0;
+  for (; first_letter < length; ++first_letter) {
+if (buffer[first_letter] & 0x40)
+  break;
   }
-
-  return (g_has_avx == eAVXPresent);
+  char letter = buffer[first_letter];
+  buffer[first_letter] = 0;
+  auto major_ver = strtoull(buffer, NULL, 0);
+  buffer[first_letter] = letter;
+  if (major_ver < 11 || (major_ver == 11 && letter < 'E'))
+return LogAVXAndReturn(g_has_avx, err, buffer);
+  if (DetectHardwareFeature("hw.optional.avx1_0"))
+g_has_avx = eAVXPresent;
+
+  return LogAVXAndReturn(g_has_avx, err, buffer);
 }
 
 uint64_t DNBArchImplX86_64::GetPC(uint64_t failValue) {
Index: tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
===
--- tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
+++ tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
@@ -16,7 +16,6 @@
 
 #if defined(__i386__) || defined(__x86_64__)
 
-#include "../HasAVX.h"
 #include "DNBArch.h"
 #include "MachRegisterStatesI386.h"
 
Index: tools/debugserver/source/MacOSX/HasAVX.s
===
--- tools/debugserver/source/MacOSX/HasAVX.s
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- HasAVX.s ---*- x86 Assembly -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#if defined (__i386__) || 

[Lldb-commits] [PATCH] D30918: [debugserver] This is a small cleanup patch to AVX support detection

2017-03-13 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added a subscriber: mgorny.

The first Sandybridge iMacs with AVX support shipped in Spring 2011 with Snow 
Leopard as their OS. Unfortunately due to a kernel bug debugging AVX code was 
not really possible until 10.7.4.

The old code here checked the kernel build number to determine when to support 
AVX, but that code was incorrect. It verified that the kernel build number was 
greater than xnu-2020, which is the build of the kernel that had the fix for 
10.8. The fix was also back ported to 10.7.4. Which means all publicly 
available OS builds 10.7.4 and later have working AVX support.

This new patch verifies that the host OS is greater than or equal to 10.7.4 by 
checking that the build number is greater than or equal to 11Exx.

The patch also removes the HasAVX assembly blob in favor of querying the kernel 
via sysctl for the hardware features.

Using sysctl is slower, however since the code is executed once and the result 
cached it is a better approach because it is possible for the kernel to disable 
AVX support on hardware that supports it, so listening to the kernel is a 
better approach for the debugger to take.


https://reviews.llvm.org/D30918

Files:
  cmake/caches/LLDBFramework.cmake
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/dotest_args.py
  test/CMakeLists.txt
  tools/debugserver/debugserver.xcodeproj/project.pbxproj
  tools/debugserver/source/MacOSX/CMakeLists.txt
  tools/debugserver/source/MacOSX/HasAVX.h
  tools/debugserver/source/MacOSX/HasAVX.s
  tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
  tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Index: tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
===
--- tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include "../HasAVX.h"
 #include "DNBLog.h"
 #include "MacOSX/x86_64/DNBArchImplX86_64.h"
 #include "MachProcess.h"
@@ -60,42 +59,56 @@
 #define FORCE_AVX_REGS (0)
 #endif
 
-extern "C" bool CPUHasAVX() {
-  enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+bool DetectHardwareFeature(const char *feature) {
+  int answer = 0;
+  size_t answer_size = sizeof(answer);
+  int error = ::sysctlbyname(feature, , _size, NULL, 0);
+  return !error & answer;
+}
+
+enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
 
+bool LogAVXAndReturn(AVXPresence has_avx, int err, const char * os_ver) {
+  DNBLogThreadedIf(LOG_THREAD,
+   "CPUHasAVX(): g_has_avx = %i (err = %i, os_ver = %s)",
+   has_avx, err, os_ver);
+  return (has_avx == eAVXPresent);
+}
+
+extern "C" bool CPUHasAVX() {
   static AVXPresence g_has_avx = eAVXUnknown;
-  if (g_has_avx == eAVXUnknown) {
-g_has_avx = eAVXNotPresent;
-
-// Only xnu-2020 or later has AVX support, any versions before
-// this have a busted thread_get_state RPC where it would truncate
-// the thread state buffer (). So we need to
-// verify the kernel version number manually or disable AVX support.
-int mib[2];
-char buffer[1024];
-size_t length = sizeof(buffer);
-uint64_t xnu_version = 0;
-mib[0] = CTL_KERN;
-mib[1] = KERN_VERSION;
-int err = ::sysctl(mib, 2, , , NULL, 0);
-if (err == 0) {
-  const char *xnu = strstr(buffer, "xnu-");
-  if (xnu) {
-const char *xnu_version_cstr = xnu + 4;
-xnu_version = strtoull(xnu_version_cstr, NULL, 0);
-if (xnu_version >= 2020 && xnu_version != ULLONG_MAX) {
-  if (::HasAVX()) {
-g_has_avx = eAVXPresent;
-  }
-}
-  }
-}
-DNBLogThreadedIf(LOG_THREAD, "CPUHasAVX(): g_has_avx = %i (err = %i, errno "
- "= %i, xnu_version = %llu)",
- g_has_avx, err, errno, xnu_version);
+  if (g_has_avx != eAVXUnknown)
+return LogAVXAndReturn(g_has_avx, 0, "");
+
+  g_has_avx = eAVXNotPresent;
+
+  // OS X 10.7.3 and earlier have a bug in thread_get_state that truncated the
+  // size of the return. To work around this we have to disable AVX debugging
+  // on hosts prior to 10.7.3 ().
+  int mib[2];
+  char buffer[1024];
+  size_t length = sizeof(buffer);
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_OSVERSION;
+  int err = ::sysctl(mib, 2, , , NULL, 0);
+  if (err != 0)
+return LogAVXAndReturn(g_has_avx, err, "");
+
+  size_t first_letter = 0;
+  for (; first_letter < length; ++first_letter) {
+if (buffer[first_letter] & 0x40)
+  break;
   }
-
-  return (g_has_avx == eAVXPresent);
+  char letter = buffer[first_letter];
+  buffer[first_letter] = 0;
+  auto major_ver = strtoull(buffer, NULL, 0);
+  buffer[first_letter] = letter;
+  if (major_ver < 11 || (major_ver == 11 && letter < 'E'))
+return LogAVXAndReturn(g_has_avx, err, buffer);
+  if 

[Lldb-commits] [PATCH] D29352: [CMake] Final dependency cleanup patch!

2017-02-07 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Ok. I think this patch is fully ready to go now. I added the missing 
dependencies in the ObjectFileELF tests in https://reviews.llvm.org/rL294372.

Thank you @labath for all your patience and help testing this patch. I've 
tested it on Darwin and FreeBSD in the current incarnation. I'm going to try 
and land it tomorrow, and I will resolve any issues the bots encounter.


https://reviews.llvm.org/D29352



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29352: [CMake] Final dependency cleanup patch!

2017-02-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 87265.
beanz added a comment.

Rebasing patch


https://reviews.llvm.org/D29352

Files:
  cmake/LLDBDependencies.cmake
  cmake/modules/AddLLDB.cmake
  source/API/CMakeLists.txt
  source/Initialization/CMakeLists.txt
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/Windows/Common/CMakeLists.txt
  tools/intel-mpx/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -39,7 +39,6 @@
 POST_BUILD
 COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
 
-  lldb_link_common_libs(${test_name} EXE)
   target_link_libraries(${test_name} ${ARG_LINK_LIBS} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
 endfunction()
 
Index: tools/lldb-server/CMakeLists.txt
===
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -23,90 +23,6 @@
 
 include_directories(../../source)
 
-
-set( LLDB_USED_LIBS
-  lldbBase
-  lldbBreakpoint
-  lldbCommands
-  lldbDataFormatters
-  lldbHost
-  lldbCore
-  lldbExpression
-  lldbInitialization
-  lldbInterpreter
-  lldbSymbol
-  lldbTarget
-  lldbUtility
-
-  # Plugins
-  lldbPluginDisassemblerLLVM
-  lldbPluginSymbolFileDWARF
-  lldbPluginSymbolFilePDB
-  lldbPluginSymbolFileSymtab
-  lldbPluginDynamicLoaderPosixDYLD
-
-  lldbPluginCPlusPlusLanguage
-  lldbPluginGoLanguage
-  lldbPluginJavaLanguage
-  lldbPluginObjCLanguage
-  lldbPluginObjCPlusPlusLanguage
-  lldbPluginOCamlLanguage
-
-  lldbPluginObjectFileELF
-  lldbPluginObjectFileJIT
-  lldbPluginSymbolVendorELF
-  lldbPluginPlatformPOSIX
-  lldbPluginObjectContainerBSDArchive
-  lldbPluginObjectContainerMachOArchive
-  lldbPluginProcessGDBRemote
-  lldbPluginProcessUtility
-  lldbPluginObjectContainerMachOArchive
-  lldbPluginObjectContainerBSDArchive
-  lldbPluginPlatformMacOSX
-  lldbPluginUnwindAssemblyInstEmulation
-  lldbPluginUnwindAssemblyX86
-  lldbPluginAppleObjCRuntime
-  lldbPluginCXXItaniumABI
-  lldbPluginInstructionARM
-  lldbPluginInstructionARM64
-  lldbPluginInstructionMIPS
-  lldbPluginInstructionMIPS64
-  lldbPluginObjectFilePECOFF
-  lldbPluginExpressionParserClang
-  lldbPluginExpressionParserGo
-  )
-
-# Linux-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginProcessLinux
-lldbPluginProcessPOSIX
-   )
-endif ()
-
-# Darwin-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginObjectFileMachO
-)
-endif()
-
-set( CLANG_USED_LIBS
-  clangAnalysis
-  clangAST
-  clangBasic
-  clangCodeGen
-  clangDriver
-  clangEdit
-  clangFrontend
-  clangLex
-  clangParse
-  clangRewrite
-  clangRewriteFrontend
-  clangSema
-  clangSerialization
-  )
-
 set(LLDB_SYSTEM_LIBS)
 if (NOT LLDB_DISABLE_LIBEDIT)
   list(APPEND LLDB_SYSTEM_LIBS edit)
@@ -142,53 +58,24 @@
   endif()
 endif()
 
-set(LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  interpreter
-  asmparser
-  bitreader
-  bitwriter
-  codegen
-  demangle
-  ipo
-  selectiondag
-  bitreader
-  mc
-  mcjit
-  core
-  mcdisassembler
-  executionengine
-  runtimedyld
-  option
-  support
-  coverage
-  target
-  )
-
 add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
 Acceptor.cpp
 lldb-gdbserver.cpp
 lldb-platform.cpp
 lldb-server.cpp
 LLDBServerUtilities.cpp
-)
 
-# The Darwin linker doesn't understand --start-group/--end-group.
-if (LLDB_LINKER_SUPPORTS_GROUPS)
-  target_link_libraries(lldb-server
--Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
-  target_link_libraries(lldb-server
--Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
-else()
-  target_link_libraries(lldb-server ${LLDB_USED_LIBS})
-  target_link_libraries(lldb-server ${CLANG_USED_LIBS})
-endif()
-if(NOT LLVM_LINK_LLVM_DYLIB)
-  # This is necessary in !LLVM_LINK_LLVM_DYLIB as LLDB's libs do not track their
-  # dependencies properly. It is conditional because in a LLVM_LINK_LLVM_DYLIB
-  # build it would introduce duplicate symbols (add_lldb_tool links to libLLVM,
-  # and this would add the individual .a files as well).
-  llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
-endif()
+LINK_LIBS
+  lldbBase
+  lldbCore
+  lldbHost
+  lldbInitialization
+  lldbInterpreter
+  ${EXTRA_LLDB_LIBS}
+  ${LLDB_SYSTEM_LIBS}
+
+LINK_COMPONENTS
+  Support
+)
 
 target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
Index: tools/intel-mpx/CMakeLists.txt
===
--- tools/intel-mpx/CMakeLists.txt
+++ tools/intel-mpx/CMakeLists.txt
@@ -8,16 +8,8 @@
   IntelMPXTablePlugin.cpp
   )
 
-target_link_libraries(lldb-intel-mpxtable PUBLIC liblldb)
-
-if (LLDB_LINKER_SUPPORTS_GROUPS)
-  

[Lldb-commits] [PATCH] D29352: [CMake] Final dependency cleanup patch!

2017-02-01 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Ah! I forgot to update the unittest directory. I'll get a patch in today that 
updates the unittests following the pattern from the libraries.


https://reviews.llvm.org/D29352



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29352: [CMake] Final dependency cleanup patch!

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 86509.
beanz added a comment.

Fixing the issue labath reported in the review. Generally speaking we shouldn't 
be configuring or compiling plugins that can't be used.


https://reviews.llvm.org/D29352

Files:
  cmake/LLDBDependencies.cmake
  cmake/modules/AddLLDB.cmake
  source/API/CMakeLists.txt
  source/Initialization/CMakeLists.txt
  source/Plugins/Process/CMakeLists.txt
  source/Plugins/Process/Windows/Common/CMakeLists.txt
  tools/intel-mpx/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -31,8 +31,7 @@
 POST_BUILD
 COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
 
-  lldb_link_common_libs(${test_name} EXE)
-  target_link_libraries(${test_name} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
+  target_link_libraries(${test_name} ${LLDB_SYSTEM_LIBS})
   llvm_config(${test_name} ${LLVM_LINK_COMPONENTS})
 endfunction()
 
Index: tools/lldb-server/CMakeLists.txt
===
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -23,90 +23,6 @@
 
 include_directories(../../source)
 
-
-set( LLDB_USED_LIBS
-  lldbBase
-  lldbBreakpoint
-  lldbCommands
-  lldbDataFormatters
-  lldbHost
-  lldbCore
-  lldbExpression
-  lldbInitialization
-  lldbInterpreter
-  lldbSymbol
-  lldbTarget
-  lldbUtility
-
-  # Plugins
-  lldbPluginDisassemblerLLVM
-  lldbPluginSymbolFileDWARF
-  lldbPluginSymbolFilePDB
-  lldbPluginSymbolFileSymtab
-  lldbPluginDynamicLoaderPosixDYLD
-
-  lldbPluginCPlusPlusLanguage
-  lldbPluginGoLanguage
-  lldbPluginJavaLanguage
-  lldbPluginObjCLanguage
-  lldbPluginObjCPlusPlusLanguage
-  lldbPluginOCamlLanguage
-
-  lldbPluginObjectFileELF
-  lldbPluginObjectFileJIT
-  lldbPluginSymbolVendorELF
-  lldbPluginPlatformPOSIX
-  lldbPluginObjectContainerBSDArchive
-  lldbPluginObjectContainerMachOArchive
-  lldbPluginProcessGDBRemote
-  lldbPluginProcessUtility
-  lldbPluginObjectContainerMachOArchive
-  lldbPluginObjectContainerBSDArchive
-  lldbPluginPlatformMacOSX
-  lldbPluginUnwindAssemblyInstEmulation
-  lldbPluginUnwindAssemblyX86
-  lldbPluginAppleObjCRuntime
-  lldbPluginCXXItaniumABI
-  lldbPluginInstructionARM
-  lldbPluginInstructionARM64
-  lldbPluginInstructionMIPS
-  lldbPluginInstructionMIPS64
-  lldbPluginObjectFilePECOFF
-  lldbPluginExpressionParserClang
-  lldbPluginExpressionParserGo
-  )
-
-# Linux-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginProcessLinux
-lldbPluginProcessPOSIX
-   )
-endif ()
-
-# Darwin-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginObjectFileMachO
-)
-endif()
-
-set( CLANG_USED_LIBS
-  clangAnalysis
-  clangAST
-  clangBasic
-  clangCodeGen
-  clangDriver
-  clangEdit
-  clangFrontend
-  clangLex
-  clangParse
-  clangRewrite
-  clangRewriteFrontend
-  clangSema
-  clangSerialization
-  )
-
 set(LLDB_SYSTEM_LIBS)
 if (NOT LLDB_DISABLE_LIBEDIT)
   list(APPEND LLDB_SYSTEM_LIBS edit)
@@ -142,54 +58,25 @@
   endif()
 endif()
 
-set(LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  interpreter
-  asmparser
-  bitreader
-  bitwriter
-  codegen
-  demangle
-  ipo
-  selectiondag
-  bitreader
-  mc
-  mcjit
-  core
-  mcdisassembler
-  executionengine
-  runtimedyld
-  option
-  support
-  coverage
-  target
-  )
-
 add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
 Acceptor.cpp
 lldb-gdbserver.cpp
 lldb-platform.cpp
 lldb-server.cpp
 LLDBServerUtilities.cpp
-)
 
-# The Darwin linker doesn't understand --start-group/--end-group.
-if (LLDB_LINKER_SUPPORTS_GROUPS)
-  target_link_libraries(lldb-server
--Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
-  target_link_libraries(lldb-server
--Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
-else()
-  target_link_libraries(lldb-server ${LLDB_USED_LIBS})
-  target_link_libraries(lldb-server ${CLANG_USED_LIBS})
-endif()
-if(NOT LLVM_LINK_LLVM_DYLIB)
-  # This is necessary in !LLVM_LINK_LLVM_DYLIB as LLDB's libs do not track their
-  # dependencies properly. It is conditional because in a LLVM_LINK_LLVM_DYLIB
-  # build it would introduce duplicate symbols (add_lldb_tool links to libLLVM,
-  # and this would add the individual .a files as well).
-  llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
-endif()
+LINK_LIBS
+  lldbBase
+  lldbCore
+  lldbHost
+  lldbInitialization
+  lldbInterpreter
+  ${EXTRA_LLDB_LIBS}
+  ${LLDB_SYSTEM_LIBS}
+
+LINK_COMPONENTS
+  Support
+)
 
 target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
 
Index: tools/intel-mpx/CMakeLists.txt
===
--- 

[Lldb-commits] [PATCH] D29352: [CMake] Final dependency cleanup patch!

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added subscribers: jgosnell, mgorny, srhines, danalbert.

This patch removes the over-specified dependencies from LLDBDependencies and 
instead relies on the dependencies as expressed in each library and tool.

This also removes the library looping in favor of allowing CMake to do its 
thing. I've tested this patch on Darwin, and found no issues, but since linker 
semantics vary by system I'll also work on testing it on other platforms too.

Help testing would be greatly appreciated.


https://reviews.llvm.org/D29352

Files:
  cmake/LLDBDependencies.cmake
  cmake/modules/AddLLDB.cmake
  source/API/CMakeLists.txt
  source/Initialization/CMakeLists.txt
  source/Plugins/Process/Windows/Common/CMakeLists.txt
  tools/intel-mpx/CMakeLists.txt
  tools/lldb-server/CMakeLists.txt
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -31,8 +31,7 @@
 POST_BUILD
 COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
 
-  lldb_link_common_libs(${test_name} EXE)
-  target_link_libraries(${test_name} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
+  target_link_libraries(${test_name} ${LLDB_SYSTEM_LIBS})
   llvm_config(${test_name} ${LLVM_LINK_COMPONENTS})
 endfunction()
 
Index: tools/lldb-server/CMakeLists.txt
===
--- tools/lldb-server/CMakeLists.txt
+++ tools/lldb-server/CMakeLists.txt
@@ -23,90 +23,6 @@
 
 include_directories(../../source)
 
-
-set( LLDB_USED_LIBS
-  lldbBase
-  lldbBreakpoint
-  lldbCommands
-  lldbDataFormatters
-  lldbHost
-  lldbCore
-  lldbExpression
-  lldbInitialization
-  lldbInterpreter
-  lldbSymbol
-  lldbTarget
-  lldbUtility
-
-  # Plugins
-  lldbPluginDisassemblerLLVM
-  lldbPluginSymbolFileDWARF
-  lldbPluginSymbolFilePDB
-  lldbPluginSymbolFileSymtab
-  lldbPluginDynamicLoaderPosixDYLD
-
-  lldbPluginCPlusPlusLanguage
-  lldbPluginGoLanguage
-  lldbPluginJavaLanguage
-  lldbPluginObjCLanguage
-  lldbPluginObjCPlusPlusLanguage
-  lldbPluginOCamlLanguage
-
-  lldbPluginObjectFileELF
-  lldbPluginObjectFileJIT
-  lldbPluginSymbolVendorELF
-  lldbPluginPlatformPOSIX
-  lldbPluginObjectContainerBSDArchive
-  lldbPluginObjectContainerMachOArchive
-  lldbPluginProcessGDBRemote
-  lldbPluginProcessUtility
-  lldbPluginObjectContainerMachOArchive
-  lldbPluginObjectContainerBSDArchive
-  lldbPluginPlatformMacOSX
-  lldbPluginUnwindAssemblyInstEmulation
-  lldbPluginUnwindAssemblyX86
-  lldbPluginAppleObjCRuntime
-  lldbPluginCXXItaniumABI
-  lldbPluginInstructionARM
-  lldbPluginInstructionARM64
-  lldbPluginInstructionMIPS
-  lldbPluginInstructionMIPS64
-  lldbPluginObjectFilePECOFF
-  lldbPluginExpressionParserClang
-  lldbPluginExpressionParserGo
-  )
-
-# Linux-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginProcessLinux
-lldbPluginProcessPOSIX
-   )
-endif ()
-
-# Darwin-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginObjectFileMachO
-)
-endif()
-
-set( CLANG_USED_LIBS
-  clangAnalysis
-  clangAST
-  clangBasic
-  clangCodeGen
-  clangDriver
-  clangEdit
-  clangFrontend
-  clangLex
-  clangParse
-  clangRewrite
-  clangRewriteFrontend
-  clangSema
-  clangSerialization
-  )
-
 set(LLDB_SYSTEM_LIBS)
 if (NOT LLDB_DISABLE_LIBEDIT)
   list(APPEND LLDB_SYSTEM_LIBS edit)
@@ -142,54 +58,25 @@
   endif()
 endif()
 
-set(LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  interpreter
-  asmparser
-  bitreader
-  bitwriter
-  codegen
-  demangle
-  ipo
-  selectiondag
-  bitreader
-  mc
-  mcjit
-  core
-  mcdisassembler
-  executionengine
-  runtimedyld
-  option
-  support
-  coverage
-  target
-  )
-
 add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
 Acceptor.cpp
 lldb-gdbserver.cpp
 lldb-platform.cpp
 lldb-server.cpp
 LLDBServerUtilities.cpp
-)
 
-# The Darwin linker doesn't understand --start-group/--end-group.
-if (LLDB_LINKER_SUPPORTS_GROUPS)
-  target_link_libraries(lldb-server
--Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
-  target_link_libraries(lldb-server
--Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
-else()
-  target_link_libraries(lldb-server ${LLDB_USED_LIBS})
-  target_link_libraries(lldb-server ${CLANG_USED_LIBS})
-endif()
-if(NOT LLVM_LINK_LLVM_DYLIB)
-  # This is necessary in !LLVM_LINK_LLVM_DYLIB as LLDB's libs do not track their
-  # dependencies properly. It is conditional because in a LLVM_LINK_LLVM_DYLIB
-  # build it would introduce duplicate symbols (add_lldb_tool links to libLLVM,
-  # and this would add the individual .a files as well).
-  llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
-endif()
+LINK_LIBS
+  lldbBase
+  lldbCore
+  lldbHost
+  lldbInitialization
+  lldbInterpreter

[Lldb-commits] [PATCH] D29348: [CMake] Add explicit dependencies to plugins

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added subscribers: jgosnell, mgorny, nemanjai.

This patch does two things. First it updates all the ABI plugins with accurate 
dependencies, and second it adds a tracking mechanism for add_lldb_library to 
denote plugin libraries, allowing us to build up a list of all the configured 
plugins.

This list of generated plugins will be used during generating liblldb so that 
we can link all the plugins into the library.

If this patch looks good I will update all the other plugins in subsequent 
patches.


https://reviews.llvm.org/D29348

Files:
  cmake/modules/AddLLDB.cmake
  source/Plugins/ABI/MacOSX-arm/CMakeLists.txt
  source/Plugins/ABI/MacOSX-arm64/CMakeLists.txt
  source/Plugins/ABI/MacOSX-i386/CMakeLists.txt
  source/Plugins/ABI/SysV-arm/CMakeLists.txt
  source/Plugins/ABI/SysV-arm64/CMakeLists.txt
  source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
  source/Plugins/ABI/SysV-i386/CMakeLists.txt
  source/Plugins/ABI/SysV-mips/CMakeLists.txt
  source/Plugins/ABI/SysV-mips64/CMakeLists.txt
  source/Plugins/ABI/SysV-ppc/CMakeLists.txt
  source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
  source/Plugins/ABI/SysV-s390x/CMakeLists.txt
  source/Plugins/ABI/SysV-x86_64/CMakeLists.txt

Index: source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
+++ source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_x86_64
+add_lldb_library(lldbPluginABISysV_x86_64 PLUGIN
   ABISysV_x86_64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-s390x/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-s390x/CMakeLists.txt
+++ source/Plugins/ABI/SysV-s390x/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_s390x
+add_lldb_library(lldbPluginABISysV_s390x PLUGIN
   ABISysV_s390x.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
+++ source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_ppc64
+add_lldb_library(lldbPluginABISysV_ppc64 PLUGIN
   ABISysV_ppc64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-ppc/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-ppc/CMakeLists.txt
+++ source/Plugins/ABI/SysV-ppc/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_ppc
+add_lldb_library(lldbPluginABISysV_ppc PLUGIN
   ABISysV_ppc.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-mips64/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-mips64/CMakeLists.txt
+++ source/Plugins/ABI/SysV-mips64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_mips64
+add_lldb_library(lldbPluginABISysV_mips64 PLUGIN
   ABISysV_mips64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-mips/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-mips/CMakeLists.txt
+++ source/Plugins/ABI/SysV-mips/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_mips
+add_lldb_library(lldbPluginABISysV_mips PLUGIN
   ABISysV_mips.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-i386/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-i386/CMakeLists.txt
+++ source/Plugins/ABI/SysV-i386/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_i386
+add_lldb_library(lldbPluginABISysV_i386 PLUGIN
   ABISysV_i386.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
+++ source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_hexagon
+add_lldb_library(lldbPluginABISysV_hexagon PLUGIN
   ABISysV_hexagon.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
   )
Index: source/Plugins/ABI/SysV-arm64/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-arm64/CMakeLists.txt
+++ 

[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@labath, we'll have to see if CMake's handling is good enough. What CMake 
actually does is repeat the full chain of the cycle, so it would be something 
like adding `-lX -lY -lX -lY` in your example. This doesn't work for certain 
pathological cases, but CMake actually has mechanisms to help deal with that 
too if we need them:

https://cmake.org/cmake/help/v3.4/command/target_link_libraries.html#cyclic-dependencies-of-static-libraries


https://reviews.llvm.org/D29333



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

In https://reviews.llvm.org/D29333#661979, @labath wrote:

> I was thinking about that as well. I am not sure if it will work if we 
> actually need multiple iterations of the loop to get all the dependencies 
> converging, but it may be worth trying out.


The way it is supposed to work, CMake will duplicate the libraries on the 
command line in the right order to avoid the need for looping at all.

> I am hoping we will be able to reduce the loops in the future. My plan is 
> that after finishing with the Log class,  to move it to a new module, with 
> clean and well defined dependencies (I need to remove all ConstStrings and 
> LLDB Streams from it first), After that I want start moving other low level 
> functionalities there as well. That got a bit delayed now, but I should be 
> back to that in a week or two.

This would be great!


https://reviews.llvm.org/D29333



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@zturner, absolutely! Thanks!

I expect this patch and the next one to be pretty safe because I'm not actually 
removing the existing dependency specifications, just adding new explicit ones.


https://reviews.llvm.org/D29333



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Thankfully CMake will not complain about circular dependencies in static 
archive targets. If it did, we'd really be in trouble because the LLDB 
dependencies graph has *lots* of circular dependencies. Actually, I think CMake 
even handles them properly on Linux, which should eliminate our need to add 
`--start-group` and `--end-group` to the linker command lines.


https://reviews.llvm.org/D29333



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications

2017-01-31 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@zturner That mechanism does work, however I generally find that it is cleaner 
to pass named parameters into CMake functions which provides a bit of a 
self-documenting API, as opposed to relying on known named variables. The 
named-parameter was introduced for LLD, and I think is the more-modern way of 
handling this. Eventually I think LLVM should be updated to do the same.


https://reviews.llvm.org/D29333



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D28155: Force the installation of lldb-server and lldb-argdumper

2017-01-09 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I think I fixed this in https://reviews.llvm.org/rL290934.


https://reviews.llvm.org/D28155



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D23977: Support of lldb on Kfreebsd

2016-12-16 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

Looks fine to me.


https://reviews.llvm.org/D23977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits