[Lldb-commits] [PATCH] D69880: [lldb] Fix exception breakpoint not being resolved when set on dummy target

2019-11-06 Thread Martin Svensson via Phabricator via lldb-commits
poya created this revision.
poya added a reviewer: jingham.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

Ensure that breakpoint ivar is properly set in exception breakpoint resolver so 
that exception breakpoints set on dummy targets are resolved once real targets 
are created and run.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69880

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
  lldb/source/Target/LanguageRuntime.cpp


Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -155,8 +155,10 @@
 
 protected:
   BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
-return BreakpointResolverSP(
+BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
+ret_sp->SetBreakpoint(&breakpoint);
+return ret_sp;
   }
 
   bool SetActualResolver() {
Index: 
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
@@ -24,6 +24,14 @@
 self.build()
 self.do_cpp_exception_bkpt()
 
+@add_test_categories(['pyapi'])
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538")
+@expectedFailureNetBSD
+def test_dummy_target_cpp_exception_breakpoint(self):
+"""Test setting and hitting the C++ exception breakpoint from dummy 
target."""
+self.build()
+self.do_dummy_target_cpp_exception_bkpt()
+
 def setUp(self):
 TestBase.setUp(self)
 self.main_source = "main.c"
@@ -50,3 +58,30 @@
 process, exception_bkpt)
 self.assertTrue(len(thread_list) == 1,
 "One thread stopped at the exception breakpoint.")
+
+def do_dummy_target_cpp_exception_bkpt(self):
+exe = self.getBuildArtifact("a.out")
+error = lldb.SBError()
+
+dummy_exception_bkpt = 
self.dbg.GetDummyTarget().BreakpointCreateForException(
+lldb.eLanguageTypeC_plus_plus, False, True)
+self.assertTrue(
+dummy_exception_bkpt.IsValid(),
+"Created exception breakpoint in dummy target.")
+
+self.target = self.dbg.CreateTarget(exe)
+self.assertTrue(self.target, VALID_TARGET)
+
+exception_bkpt = self.target.GetBreakpointAtIndex(0)
+self.assertTrue(
+exception_bkpt.IsValid(),
+"Target primed with exception breakpoint from dummy target.")
+
+process = self.target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+thread_list = lldbutil.get_threads_stopped_at_breakpoint(
+   process, exception_bkpt)
+self.assertTrue(len(thread_list) == 1,
+   "One thread stopped at the exception breakpoint.")


Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -155,8 +155,10 @@
 
 protected:
   BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
-return BreakpointResolverSP(
+BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
+ret_sp->SetBreakpoint(&breakpoint);
+return ret_sp;
   }
 
   bool SetActualResolver() {
Index: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
@@ -24,6 +24,14 @@
 self.build()
 self.do_cpp_exception_bkpt()
 
+@add_test_categories(['pyapi'])
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538")
+@expectedFailureNetBSD
+def test_dummy_target_cpp_exception_breakpoint(self):
+"""Test setting and hitting the C++ exception breakpoint from dummy target."""
+self.build()
+self.do_dummy_target_cpp_exception_bkpt()
+
 def setUp(self):
 TestBase.setUp(self)
 self.main_source = "main.c"
@@ -50,3 +58,30 @@
 process, exception_bkpt)
 self.assertTrue(len(thread_list) == 1,
 "One thread stopped at the exception 

[Lldb-commits] [lldb] eb12b3b - Silence warning, PyMODINIT_FUNC already contains extern "C"

2019-11-06 Thread Benjamin Kramer via lldb-commits

Author: Benjamin Kramer
Date: 2019-11-06T12:27:11+01:00
New Revision: eb12b3b8a3e5f41a6ab84f94dfc85551f92bc2ea

URL: 
https://github.com/llvm/llvm-project/commit/eb12b3b8a3e5f41a6ab84f94dfc85551f92bc2ea
DIFF: 
https://github.com/llvm/llvm-project/commit/eb12b3b8a3e5f41a6ab84f94dfc85551f92bc2ea.diff

LOG: Silence warning, PyMODINIT_FUNC already contains extern "C"

PythonReadline.h:22:12: warning: duplicate 'extern' declaration specifier 
[-Wduplicate-decl-specifier]

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h

Removed: 




diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
index faf95bb64486..4f25c46eefa8 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h
@@ -19,7 +19,7 @@
 //
 #define LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE 1
 
-extern "C" PyMODINIT_FUNC initlldb_readline(void);
+PyMODINIT_FUNC initlldb_readline(void);
 
 #endif
 



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


[Lldb-commits] [PATCH] D69843: Expression eval lookup - prune methods without parsing

2019-11-06 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

Thanks for the feedback! We will experiment with filtering in GetFunctions 
sometime next week.

Regarding the FindTypes patch, it would be really nice to have that for Linux, 
as well. I see the type pruning (TypeMap::RemoveMismatchedTypes) taking several 
seconds for some expression evaluations; it is likely to be the same problem 
you are solving.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69843



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


[Lldb-commits] [PATCH] D69873: [lldb-vscode] support the completion request

2019-11-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:948
+actual_column,
+0, 20, matches, descriptions);
+  targets.reserve(matches.GetSize());

max_return_elements isn't implemented, so you can just pass '-1' here. This 
also means you probably want to manually resize the results to no be longer 
than 20.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:955
+llvm::json::Object item;
+EmplaceSafeString(item, "text", match);
+if (description.empty())

I am not sure how VSCode works, but you probably should be aware that the 
results from HandleCompletionWithDescriptions are expected to replace the 
current token. Token is in LLDB is just a string as a list of unescaped 
non-quote non-whitespace characters, where the quotes are not part of the token 
(and will not be included in the match string you get back). You can also quote 
every argument in LLDB, so completions in quotes can happen everywhere.

Some test that might bug out VSCode are for example
```
"com[tab]
'com[tab]
settings "se[tab]
settings 'se[tab]
```

Also the completions you get back from LLDB are *usually* complete tokens (e.g, 
you can safely add a space character behind for the user), but the exception to 
this are file paths (where we only complete the current directory). This isn't 
really exposed in `HandleCompletionWithDescriptions, you can't really know if 
adding a space is correct or not. Anyway, just be aware that if VSCode adds a 
trailing space to the completions, this might give wrong results for file paths.

Also you can get completions in the print/expression command (where users can 
freely use quotes and whitespaces) which means you can get really weird 
situations like this: `expr "";typed[tab]` -> `"";typedef` (at least, I believe 
that's what we return). I think this is currently also broken in LLDB, so it 
might not be a big issue as long as VSCode does anything reasonable when it 
gets weird matches like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69873



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


[Lldb-commits] [lldb] 5840161 - lldb: Skip reproducer+expression evaluation test on linux

2019-11-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-06T15:48:00+01:00
New Revision: 58401612cdc8d2c8e0e8c4103423b5da781199be

URL: 
https://github.com/llvm/llvm-project/commit/58401612cdc8d2c8e0e8c4103423b5da781199be
DIFF: 
https://github.com/llvm/llvm-project/commit/58401612cdc8d2c8e0e8c4103423b5da781199be.diff

LOG: lldb: Skip reproducer+expression evaluation test on linux

It's flaky.

Added: 


Modified: 
lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test

Removed: 




diff  --git 
a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
index d826a47cb245..a185c840ebd3 100644
--- a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
@@ -1,5 +1,8 @@
 # UNSUPPORTED: system-windows, system-freebsd
 
+# Flaky
+# UNSUPPORTED: system-linux
+
 # This tests that expression evaluation continues to work when replaying a
 # reproducer.
 



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


Re: [Lldb-commits] [lldb] 2abcf44 - [Reproducer] Add test case for expression evaluation

2019-11-06 Thread Pavel Labath via lldb-commits
It seems that this test is very flaky (fails ~10% of time) on linux. 
E.g: 
.


It always fails on the same assertion: "Encountered unexpected packet 
during replay". I've done a bit of digging, and the problems seems to be 
down to a nondeterministic $M packet being sent while evaluating one of 
the expressions:

recording:
$M77fcc140,108:06000a0006000c000a00050012000a000500650016000a0009001a000a0005007b001e00010004002b000100040039000a000500950043000a000500b20051000a000500d00062000a000500c200#f7
replay:
$M77fcc140,108:06000a0006000c000a00050012000a000500650016000a0009001a000a0005007c001e00010004002b000100040039000a000500960043000a000500b30051000a000500d10062000a000500c300#fc

It's possible that this is specific to linux, as this particular failure 
happened while evaluating the mmap() helper expression (which we don't 
do on mac), but it's also possible (and more likely, I think) that this 
is a more general problem. Nonetheless, I haven't seen it fail on green 
dragon, so I've disabled in only on linux for now.


pl


On 05/11/2019 21:33, Jonas Devlieghere via lldb-commits wrote:


Author: Jonas Devlieghere
Date: 2019-11-05T12:33:21-08:00
New Revision: 2abcf44f4c91a326d1f4513fb5c25fec51c6ca66

URL: 
https://github.com/llvm/llvm-project/commit/2abcf44f4c91a326d1f4513fb5c25fec51c6ca66
DIFF: 
https://github.com/llvm/llvm-project/commit/2abcf44f4c91a326d1f4513fb5c25fec51c6ca66.diff

LOG: [Reproducer] Add test case for expression evaluation

Added:
 lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
 lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test

Modified:
 


Removed:
 




diff  --git 
a/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in 
b/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
new file mode 100644
index ..8887c201d92e
--- /dev/null
+++ b/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
@@ -0,0 +1,10 @@
+breakpoint set -f foo.cpp -l 11
+run
+p foo
+next
+p Foo(2, 3.33);
+p $1
+p foo = Foo(3, 4.44);
+p foo
+cont
+reproducer generate

diff  --git 
a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test 
b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
new file mode 100644
index ..d826a47cb245
--- /dev/null
+++ b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
@@ -0,0 +1,18 @@
+# UNSUPPORTED: system-windows, system-freebsd
+
+# This tests that expression evaluation continues to work when replaying a
+# reproducer.
+
+# RUN: rm -rf %t.repro
+# RUN: %clangxx_host %S/Inputs/foo.cpp -g -o %t.out
+
+# RUN: %lldb -x -b -s %S/Inputs/ExpressionEvaluation.in --capture 
--capture-path %t.repro %t.out | FileCheck %s
+# RUN: %lldb --replay %t.repro | FileCheck %s
+
+# CHECK: stop reason = breakpoint 1.1
+# CHECK: (Foo) $0 = (m_i = 0, m_d = 0)
+# CHECK: stop reason = step over
+# CHECK: (Foo) $1 = (m_i = 2, m_d = 3)
+# CHECK: (Foo) $1 = (m_i = 2, m_d = 3)
+# CHECK: (Foo) $2 = (m_i = 3, m_d = 4)
+# CHECK: (Foo) $3 = (m_i = 3, m_d = 4)


 
___

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



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


Re: [Lldb-commits] [lldb] 2abcf44 - [Reproducer] Add test case for expression evaluation

2019-11-06 Thread Jonas Devlieghere via lldb-commits
Thanks Pavel, I’ll investigate today.

On Wed, Nov 6, 2019 at 06:54 Pavel Labath  wrote:

> It seems that this test is very flaky (fails ~10% of time) on linux.
> E.g:
> <
> http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/211/steps/test/logs/stdio
> >.
>
> It always fails on the same assertion: "Encountered unexpected packet
> during replay". I've done a bit of digging, and the problems seems to be
> down to a nondeterministic $M packet being sent while evaluating one of
> the expressions:
> recording:
>
> $M77fcc140,108:06000a0006000c000a00050012000a000500650016000a0009001a000a0005007b001e00010004002b000100040039000a000500950043000a000500b20051000a000500d00062000a000500c200#f7
> replay:
>
> $M77fcc140,108:06000a0006000c000a00050012000a000500650016000a0009001a000a0005007c001e00010004002b000100040039000a000500960043000a000500b30051000a000500d10062000a000500c300#fc
>
> It's possible that this is specific to linux, as this particular failure
> happened while evaluating the mmap() helper expression (which we don't
> do on mac), but it's also possible (and more likely, I think) that this
> is a more general problem. Nonetheless, I haven't seen it fail on green
> dragon, so I've disabled in only on linux for now.
>
> pl
>
>
> On 05/11/2019 21:33, Jonas Devlieghere via lldb-commits wrote:
> >
> > Author: Jonas Devlieghere
> > Date: 2019-11-05T12:33:21-08:00
> > New Revision: 2abcf44f4c91a326d1f4513fb5c25fec51c6ca66
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/2abcf44f4c91a326d1f4513fb5c25fec51c6ca66
> > DIFF:
> https://github.com/llvm/llvm-project/commit/2abcf44f4c91a326d1f4513fb5c25fec51c6ca66.diff
> >
> > LOG: [Reproducer] Add test case for expression evaluation
> >
> > Added:
> >
> lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
> >
> lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
> >
> > Modified:
> >
> >
> > Removed:
> >
> >
> >
> >
> 
> > diff  --git
> a/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
> b/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
> > new file mode 100644
> > index ..8887c201d92e
> > --- /dev/null
> > +++
> b/lldb/test/Shell/Reproducer/Functionalities/Inputs/ExpressionEvaluation.in
> > @@ -0,0 +1,10 @@
> > +breakpoint set -f foo.cpp -l 11
> > +run
> > +p foo
> > +next
> > +p Foo(2, 3.33);
> > +p $1
> > +p foo = Foo(3, 4.44);
> > +p foo
> > +cont
> > +reproducer generate
> >
> > diff  --git
> a/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
> b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
> > new file mode 100644
> > index ..d826a47cb245
> > --- /dev/null
> > +++
> b/lldb/test/Shell/Reproducer/Functionalities/TestExpressionEvaluation.test
> > @@ -0,0 +1,18 @@
> > +# UNSUPPORTED: system-windows, system-freebsd
> > +
> > +# This tests that expression evaluation continues to work when
> replaying a
> > +# reproducer.
> > +
> > +# RUN: rm -rf %t.repro
> > +# RUN: %clangxx_host %S/Inputs/foo.cpp -g -o %t.out
> > +
> > +# RUN: %lldb -x -b -s %S/Inputs/ExpressionEvaluation.in --capture
> --capture-path %t.repro %t.out | FileCheck %s
> > +# RUN: %lldb --replay %t.repro | FileCheck %s
> > +
> > +# CHECK: stop reason = breakpoint 1.1
> > +# CHECK: (Foo) $0 = (m_i = 0, m_d = 0)
> > +# CHECK: stop reason = step over
> > +# CHECK: (Foo) $1 = (m_i = 2, m_d = 3)
> > +# CHECK: (Foo) $1 = (m_i = 2, m_d = 3)
> > +# CHECK: (Foo) $2 = (m_i = 3, m_d = 4)
> > +# CHECK: (Foo) $3 = (m_i = 3, m_d = 4)
> >
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> >
>
> --
Sent from my iPhone
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bcae3b0 - lldb/docs: update the lldb-x86_64-debian bot url

2019-11-06 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-11-06T16:02:23+01:00
New Revision: bcae3b04e8740e1a82567471df410a2fd8b72c3f

URL: 
https://github.com/llvm/llvm-project/commit/bcae3b04e8740e1a82567471df410a2fd8b72c3f
DIFF: 
https://github.com/llvm/llvm-project/commit/bcae3b04e8740e1a82567471df410a2fd8b72c3f.diff

LOG: lldb/docs: update the lldb-x86_64-debian bot url

It is on the "stable" master now.

Added: 


Modified: 
lldb/docs/resources/bots.rst

Removed: 




diff  --git a/lldb/docs/resources/bots.rst b/lldb/docs/resources/bots.rst
index e054575432da..ed2d75ae7aa8 100644
--- a/lldb/docs/resources/bots.rst
+++ b/lldb/docs/resources/bots.rst
@@ -10,7 +10,7 @@ build slaves. Everyone can `add a buildbot for LLDB
 
 
 * `lldb-x64-windows-ninja 
`_
-* `lldb-x86_64-debian `_
+* `lldb-x86_64-debian `_
 * `lldb-x86_64-fedora `_
 
 Documentation



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


[Lldb-commits] [PATCH] D69630: [lldb] Record framework build path and use it everywhere

2019-11-06 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Makes sense to me (sorry about the delay).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69630



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


[Lldb-commits] [PATCH] D69873: [lldb-vscode] support the completion request

2019-11-06 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 228076.
wallace added a comment.

removed the results limit of 20 because it didn't work and I verified that 
returning a long list is displayed well on vscode. There's no need for this 
limit at this point.
I also tested the cases that @teemperor mentioned and all of them work on 
vscode. I also added them as test cases.

Fortunately, the way completions are represented inside LLDB are exactly the 
same as what vscode expects


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69873

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -821,6 +821,151 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "CompletionsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Returns a list of possible completions for a given caret position and text.\nThe CompletionsRequest may only be called if the 'supportsCompletionsRequest' capability exists and is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "completions" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/CompletionsArguments"
+//   }
+// },
+// "required": [ "command", "arguments"  ]
+//   }]
+// },
+// "CompletionsArguments": {
+//   "type": "object",
+//   "description": "Arguments for 'completions' request.",
+//   "properties": {
+// "frameId": {
+//   "type": "integer",
+//   "description": "Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope."
+// },
+// "text": {
+//   "type": "string",
+//   "description": "One or more source lines. Typically this is the text a user has typed into the debug console before he asked for completion."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "The character position for which to determine the completion proposals."
+// },
+// "line": {
+//   "type": "integer",
+//   "description": "An optional line for which to determine the completion proposals. If missing the first line of the text is assumed."
+// }
+//   },
+//   "required": [ "text", "column" ]
+// },
+// "CompletionsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to 'completions' request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "targets": {
+// "type": "array",
+// "items": {
+//   "$ref": "#/definitions/CompletionItem"
+// },
+// "description": "The possible completions for ."
+//   }
+// },
+// "required": [ "targets" ]
+//   }
+// },
+// "required": [ "body" ]
+//   }]
+// },
+// "CompletionItem": {
+//   "type": "object",
+//   "description": "CompletionItems are the suggestions returned from the CompletionsRequest.",
+//   "properties": {
+// "label": {
+//   "type": "string",
+//   "description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion."
+// },
+// "text": {
+//   "type": "string",
+//   "description": "If text is not falsy then it is inserted instead of the label."
+// },
+// "sortText": {
+//   "type": "string",
+//   "description": "A string that should be used when comparing this item with other items. When `falsy` the label is used."
+// },
+// "type": {
+//   "$ref": "#/definitions/CompletionItemType",
+//   "description": "The item's type. Typically the client uses this information to render the item in the UI with an icon."
+// },
+// "start": {
+//   "type": "integer",
+//   "description": "This value determines the location (in the CompletionsRequest's 'text' attribute) where the completion text is added.\nIf missing the text is added at the location specified by the CompletionsRequest's 'column' attribute."
+// },
+// "length": {
+//   "type": "integer",
+//   "description": "This value determines how many cha

[Lldb-commits] [PATCH] D69873: [lldb-vscode] support the completion request

2019-11-06 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 228078.
wallace added a comment.

nit 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69873

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -821,6 +821,151 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
+// "CompletionsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Returns a list of possible completions for a given caret position and text.\nThe CompletionsRequest may only be called if the 'supportsCompletionsRequest' capability exists and is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "completions" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/CompletionsArguments"
+//   }
+// },
+// "required": [ "command", "arguments"  ]
+//   }]
+// },
+// "CompletionsArguments": {
+//   "type": "object",
+//   "description": "Arguments for 'completions' request.",
+//   "properties": {
+// "frameId": {
+//   "type": "integer",
+//   "description": "Returns completions in the scope of this stack frame. If not specified, the completions are returned for the global scope."
+// },
+// "text": {
+//   "type": "string",
+//   "description": "One or more source lines. Typically this is the text a user has typed into the debug console before he asked for completion."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "The character position for which to determine the completion proposals."
+// },
+// "line": {
+//   "type": "integer",
+//   "description": "An optional line for which to determine the completion proposals. If missing the first line of the text is assumed."
+// }
+//   },
+//   "required": [ "text", "column" ]
+// },
+// "CompletionsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to 'completions' request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "targets": {
+// "type": "array",
+// "items": {
+//   "$ref": "#/definitions/CompletionItem"
+// },
+// "description": "The possible completions for ."
+//   }
+// },
+// "required": [ "targets" ]
+//   }
+// },
+// "required": [ "body" ]
+//   }]
+// },
+// "CompletionItem": {
+//   "type": "object",
+//   "description": "CompletionItems are the suggestions returned from the CompletionsRequest.",
+//   "properties": {
+// "label": {
+//   "type": "string",
+//   "description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion."
+// },
+// "text": {
+//   "type": "string",
+//   "description": "If text is not falsy then it is inserted instead of the label."
+// },
+// "sortText": {
+//   "type": "string",
+//   "description": "A string that should be used when comparing this item with other items. When `falsy` the label is used."
+// },
+// "type": {
+//   "$ref": "#/definitions/CompletionItemType",
+//   "description": "The item's type. Typically the client uses this information to render the item in the UI with an icon."
+// },
+// "start": {
+//   "type": "integer",
+//   "description": "This value determines the location (in the CompletionsRequest's 'text' attribute) where the completion text is added.\nIf missing the text is added at the location specified by the CompletionsRequest's 'column' attribute."
+// },
+// "length": {
+//   "type": "integer",
+//   "description": "This value determines how many characters are overwritten by the completion text.\nIf missing the value 0 is assumed which results in the completion text being inserted."
+// }
+//   },
+//   "required": [ "label" ]
+// },
+// "CompletionItemType": {
+//   "type": "string",
+//   "description": "Some predefined types for the Co

[Lldb-commits] [PATCH] D69904: [arm] Add core definition for armv8l and armv7l

2019-11-06 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: jasonmolenda, labath, clayborg.
Herald added a subscriber: kristof.beyls.

This patch adds core definitions in lldb ArchSpecs for armv8l and armv7l cores. 
There is also fix where while merging target and paltform triple we were 
updating core and triple which results in new triple with unknown environment 
and vendor. This fixes issues where lldb has a triple created after parsing elf 
header and another from the platform and we should be using consolidated 
information from both sides.

On Linux systems running on armv8 we are returned armv8l in case we are running 
32bit sysroot on 64bit kernel (l for little endian).

Similarly for armv8 hardware running 32bit kernel and 32bit sysroot we are 
returned armv7l. This is quite common when we run 32 bit arm using docker 
container.

Also clang return target triple=armv8l-unknown-linux-gnueabihf


https://reviews.llvm.org/D69904

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/source/Utility/ArchSpec.cpp


Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -61,6 +61,8 @@
  "armv6m"},
 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7,
  "armv7"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7l,
+ "armv7l"},
 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7f,
  "armv7f"},
 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7s,
@@ -101,6 +103,8 @@
  ArchSpec::eCore_arm_arm64, "arm64"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
  ArchSpec::eCore_arm_armv8, "armv8"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm,
+  ArchSpec::eCore_arm_armv8l, "armv8l"},
 {eByteOrderLittle, 4, 4, 4, llvm::Triple::aarch64_32,
   ArchSpec::eCore_arm_arm64_32, "arm64_32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
@@ -878,7 +882,7 @@
   IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic &&
   other.GetCore() != ArchSpec::eCore_arm_generic) {
 m_core = other.GetCore();
-CoreUpdated(true);
+CoreUpdated(false);
   }
   if (GetFlags() == 0) {
 SetFlags(other.GetFlags());
@@ -1202,6 +1206,8 @@
   case ArchSpec::eCore_arm_armv7f:
   case ArchSpec::eCore_arm_armv7k:
   case ArchSpec::eCore_arm_armv7s:
+  case ArchSpec::eCore_arm_armv7l:
+  case ArchSpec::eCore_arm_armv8l:
 if (!enforce_exact_match) {
   if (core2 == ArchSpec::eCore_arm_generic)
 return true;
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -239,7 +239,7 @@
override ARCH :=
override ARCHFLAG :=
endif
-   ifeq "$(ARCH)" "arm"
+ifeq "$(findstring arm,$(ARCH))" "arm"
override ARCH :=
override ARCHFLAG :=
endif
Index: lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
===
--- lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -25,7 +25,7 @@
 
 if arch in ['x86_64', 'i386']:
 test_case.expect("register read eax", substrs=['eax = 0x'])
-elif arch in ['arm', 'armv7', 'armv7k']:
+elif arch in ['arm', 'armv7', 'armv7k', 'armv8l', 'armv7l']:
 test_case.expect("register read r0", substrs=['r0 = 0x'])
 elif arch in ['aarch64', 'arm64', 'arm64e', 'arm64_32']:
 test_case.expect("register read x0", substrs=['x0 = 0x'])
Index: lldb/include/lldb/Utility/ArchSpec.h
===
--- lldb/include/lldb/Utility/ArchSpec.h
+++ lldb/include/lldb/Utility/ArchSpec.h
@@ -101,6 +101,7 @@
 eCore_arm_armv6,
 eCore_arm_armv6m,
 eCore_arm_armv7,
+eCore_arm_armv7l,
 eCore_arm_armv7f,
 eCore_arm_armv7s,
 eCore_arm_armv7k,
@@ -122,6 +123,7 @@
 eCore_thumbv7em,
 eCore_arm_arm64,
 eCore_arm_armv8,
+eCore_arm_armv8l,
 eCore_arm_arm64_32,
 eCore_arm_aarch64,
 


Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -61,6 +61,8 @@
  "armv6m"},
 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7,
  "armv7"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7l,
+ "armv7l"},
 {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7f,
  "armv

[Lldb-commits] [PATCH] D69913: Re-enable std::function formatter with fixes to improve non-cached lookup performance

2019-11-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: jasonmolenda, aam, jingham.
Herald added a subscriber: christof.

This PR depends on D67111 

Performance issues lead to the libc++ std::function formatter to be disabled. 
We addressed some of those performance issues by adding caching see D67111 


This PR fixes the first lookup performance by not using 
`FindSymbolsMatchingRegExAndType(...)` and instead finding the compilation unit 
the `std::function` wrapped callable should be in and then searching for the 
callable directly in the CU.


https://reviews.llvm.org/D69913

Files:
  include/lldb/Symbol/CompileUnit.h
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
  
packages/Python/lldbsuite/test/lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py
  
packages/Python/lldbsuite/test/lang/cpp/std-function-step-into-callable/main.cpp
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Symbol/CompileUnit.cpp

Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -568,6 +568,11 @@
   "weak_ptr synthetic children",
   ConstString("^(std::__[[:alnum:]]+::)weak_ptr<.+>(( )?&)?$"),
   stl_synth_flags, true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibcxxFunctionSummaryProvider,
+"libc++ std::function summary provider",
+ConstString("^std::__[[:alnum:]]+::function<.+>$"),
+stl_summary_flags, true);
 
   stl_summary_flags.SetDontShowChildren(false);
   stl_summary_flags.SetSkipPointers(false);
Index: source/Symbol/CompileUnit.cpp
===
--- source/Symbol/CompileUnit.cpp
+++ source/Symbol/CompileUnit.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
+#include "lldb/Utility/Timer.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -81,6 +82,31 @@
   return;
 }
 
+lldb::FunctionSP CompileUnit::FindFunction(
+llvm::function_ref matching_lambda) {
+  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+  Timer scoped_timer(func_cat, "CompileUnit::FindFunction");
+
+  lldb::ModuleSP module = CalculateSymbolContextModule();
+
+  if (!module)
+return {};
+
+  SymbolFile *symbol_file = module->GetSymbolFile();
+
+  if (!symbol_file)
+return {};
+
+  // m_functions_by_uid is filled in lazily but we need all the entries.
+  symbol_file->ParseFunctions(*this);
+
+  for (auto &p : m_functions_by_uid) {
+if (matching_lambda(p.second->GetName().GetStringRef()))
+  return p.second;
+  }
+  return {};
+}
+
 // Dump the current contents of this object. No functions that cause on demand
 // parsing of functions, globals, statics are called, so this is a good
 // function to call to get an idea of the current contents of the CompileUnit
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -826,6 +826,8 @@
 }
 
 size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) {
+  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+  Timer scoped_timer(func_cat, "SymbolFileDWARF::ParseFunctions");
   std::lock_guard guard(GetModuleMutex());
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
   if (!dwarf_cu)
Index: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/UniqueCStringMap.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/RegisterContext.h"
@@ -28,6 +29,7 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
 #include "lldb/Target/ThreadPlanStepInRange.h"
+#include "lldb/Utility/Timer.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -61,6 +63,10 @@
 CPPLanguageRuntime::LibCppStdFunctionCallableInfo
 CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
 lldb::ValueObjectSP &valobj_sp) {
+  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+  Timer scoped_timer(func_cat,
+ "CPPLa

[Lldb-commits] [PATCH] D69913: Re-enable std::function formatter with fixes to improve non-cached lookup performance

2019-11-06 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp:274
+  vtable_first_entry_resolved.CalculateSymbolContextCompileUnit();
+  llvm::StringRef name_to_use = func_to_match;
+  bool is_lambda = contains_lambda_identifier(name_to_use);

Why a new variable?



Comment at: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp:287
+  size_t pos = llvm::StringRef::npos;
+  pos = name_to_use.find("::operator");
+

Doesn't matter too much for lambdas, but shouldn't this be "operator()" ?
Is this guaranteed to return a valid index? Should we assert on it?



Comment at: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp:293
+  if (name.startswith(sliced_name) && name.contains("operator"))
+if (name.contains("$_") || name.contains("'lambda'"))
+  return true;

this is basically is_lambda. As we filter it above, why do we need this test?



Comment at: source/Symbol/CompileUnit.cpp:101
+  // m_functions_by_uid is filled in lazily but we need all the entries.
+  symbol_file->ParseFunctions(*this);
+

This seems pretty expensive. Can we Force the parsing of the functions just in 
the compiler unit rather than the whole symbol file? If you are using a dSYM, 
then this is going to load all the debug information in one go.


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

https://reviews.llvm.org/D69913



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


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69589#1734818 , @aadsm wrote:

> @hhb I just did, and get the same error as well :(
>  `ninja: error: 'bin/LLDB.framework/LLDB', needed by 
> 'bin/LLDB.framework/Resources/Python/lldb/_lldb.so', missing and no known 
> rule to make it`


Thanks for the testing. It is interesting and I can reproduce now by build, 
remove LLDB.framework and build again.

LLDB.framework/LLDB symlink is not created by any target I can find. I tried 
liblldb or lldb. Seems only a full build will create it? I'm not familiar with 
framework build. Will spend some time to look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589



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


[Lldb-commits] [lldb] 77a60f0 - [lldb] Record framework build path and use it everywhere

2019-11-06 Thread Haibo Huang via lldb-commits

Author: Haibo Huang
Date: 2019-11-06T14:05:35-08:00
New Revision: 77a60f0df673074a2c9276498f95a9eaadeece56

URL: 
https://github.com/llvm/llvm-project/commit/77a60f0df673074a2c9276498f95a9eaadeece56
DIFF: 
https://github.com/llvm/llvm-project/commit/77a60f0df673074a2c9276498f95a9eaadeece56.diff

LOG: [lldb] Record framework build path and use it everywhere

This avoids config time dependencies on liblldb. And enables other refactoring.

Added: 


Modified: 
lldb/CMakeLists.txt
lldb/cmake/modules/AddLLDB.cmake
lldb/cmake/modules/LLDBConfig.cmake
lldb/cmake/modules/LLDBFramework.cmake
lldb/test/API/CMakeLists.txt
lldb/tools/debugserver/source/CMakeLists.txt
lldb/tools/driver/CMakeLists.txt
lldb/tools/lldb-vscode/CMakeLists.txt

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 128130621ba0..81d7dd8123bd 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -93,10 +93,9 @@ endif()
 
 if (NOT LLDB_DISABLE_PYTHON)
   get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
-  get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
 
   if(LLDB_BUILD_FRAMEWORK)
-set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
+set(lldb_python_build_path 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
   else()
 set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
   endif()
@@ -188,7 +187,7 @@ if (NOT LLDB_DISABLE_PYTHON)
   endfunction()
 
   if(LLDB_BUILD_FRAMEWORK)
-set(LIBLLDB_SYMLINK_DEST "${liblldb_build_dir}/LLDB.framework/LLDB")
+set(LIBLLDB_SYMLINK_DEST 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/LLDB")
   else()
 set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
   endif()

diff  --git a/lldb/cmake/modules/AddLLDB.cmake 
b/lldb/cmake/modules/AddLLDB.cmake
index b58a62ca7771..6f05be384908 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -227,8 +227,7 @@ endfunction()
 function(lldb_add_to_buildtree_lldb_framework name subdir)
   # Destination for the copy in the build-tree. While the framework target may
   # not exist yet, it will exist when the generator expression gets expanded.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-  set(copy_dest "${framework_build_dir}/${subdir}/$")
+  set(copy_dest 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/${subdir}/$")
 
   # Copy into the given subdirectory for testing.
   add_custom_command(TARGET ${name} POST_BUILD

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index c042cbf1b22e..e9ed2229d6bf 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -68,6 +68,9 @@ if(LLDB_BUILD_FRAMEWORK)
   set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for 
LLDB.framework")
   set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install 
directory for LLDB.framework")
 
+  get_filename_component(LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR 
${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
+BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR})
+
   # Essentially, emit the framework's dSYM outside of the framework directory.
   set(LLDB_DEBUGINFO_INSTALL_PREFIX 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING
   "Directory to emit dSYM files stripped from executables and libraries 
(Darwin Only)")

diff  --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 249fea30a874..b6488936806a 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -1,10 +1,4 @@
-# Path relative to the root binary directory
-get_filename_component(
-  framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
-  BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
-)
-
-message(STATUS "LLDB.framework: build path is '${framework_target_dir}'")
+message(STATUS "LLDB.framework: build path is 
'${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}'")
 message(STATUS "LLDB.framework: install path is 
'${LLDB_FRAMEWORK_INSTALL_DIR}'")
 message(STATUS "LLDB.framework: resources subdirectory is 
'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
 
@@ -15,7 +9,7 @@ set_target_properties(liblldb PROPERTIES
 
   OUTPUT_NAME LLDB
   VERSION ${LLDB_VERSION}
-  LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir}
+  LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 
   # Compatibility version
   SOVERSION "1.0.0"
@@ -29,8 +23,8 @@ set_target_properties(liblldb PROPERTIES
 # Used in llvm_add_library() to set default output directories for multi-config
 # generators. Overwrite to account for special framework output directory.
 set_output_directory(liblldb
-  BINARY_DIR ${framework_target_dir}
-  LIBRARY_DIR ${framework_target_dir}
+  BINARY

[Lldb-commits] [PATCH] D69871: crashlog.py: Improve regular expressions

2019-11-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 228141.

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

https://reviews.llvm.org/D69871

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/Python/crashlog.test

Index: lldb/test/Shell/Python/crashlog.test
===
--- lldb/test/Shell/Python/crashlog.test
+++ lldb/test/Shell/Python/crashlog.test
@@ -1,5 +1,6 @@
 # -*- python -*-
 # REQUIRES: system-darwin
+# DEBUG: cd %S/../../../examples/python && cat %s | %lldb && false
 # RUN: cd %S/../../../examples/python && cat %s | %lldb | FileCheck %s
 # CHECK-LABEL: {{S}}KIP BEYOND CHECKS
 script
@@ -32,11 +33,11 @@
 "0x111 - 0x2 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro",
 # CHECK: 0x111
 # CHECK: 0x2
-# CHECK: MyApp Pro arm64
-# CHECK: None
+# CHECK: MyApp Pro
+# CHECK: arm64
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
-
+
 "0x111 - 0x2 +MyApp Pro (0) <01234> /tmp/MyApp Pro.app/MyApp Pro",
 # CHECK: 0x111
 # CHECK: 0x2
@@ -45,13 +46,45 @@
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
 
-"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
+"0x111 - 0x222 MyFramework Plus.dylib (1.11 - MyFramework 1.11) <01234> /tmp/MyFramework Plus.dylib",
+# CHECK: 0x111
+# CHECK: 0x222
+# CHECK: MyFramework Plus.dylib
+# CHECK: ({{.*}}
+# CHECK: 1.11 - MyFramework 1.11
+# CHECK: <{{.*}}
+# CHECK: 01234
+# CHECK: /tmp/MyFramework Plus.dylib
+
+"0x111 - 0x222 MyFramework-dev.dylib (1.0.0svn - 1.0.0svn) <01234> /MyFramework-dev.dylib",
+# CHECK: 0x111
+# CHECK: 0x222
+# CHECK: MyFramework-dev.dylib
+# CHECK: ({{.*}}
+# CHECK: 1.0.0svn - 1.0.0svn
+# CHECK: <{{.*}}
+# CHECK: 01234
+# CHECK: /MyFramework-dev.dylib
+
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib",
 # CHECK: 0x7fff63f2
 # CHECK: 0x7fff63f77ff7
 # CHECK: libc++.1.dylib
-# CHECK: (400.9.4)
+# CHECK: ({{.*}}
+# CHECK: 400.9.4
+# CHECK: None
 # CHECK: None
 # CHECK: /usr/lib/libc++.1.dylib
+
+"0x1047b8000 - 0x10481 dyld arm64e   /usr/lib/dyld"
+# CHECK: 0x1047b8000
+# CHECK: 0x10481
+# CHECK: dyld
+# CHECK: {{.*}}
+# CHECK: arm64e
+# CHECK: <{{.*}}
+# CHECK: cfa789d10da63f9a8996daf84ed9d04f
+# CHECK: /usr/lib/dyld
 ]
 # CHECK-LABEL: FRAMES
 frames = [
@@ -67,7 +100,10 @@
 # CHECK: lldb_private{{.*}} + 105
 "2   MyApp Pro arm64	0x00019b0db3a8 foo + 72",
 # CHECK: 2
-# CHECK: MyApp Pro arm64
+# CHECK: MyApp Pro
+# CHECK: a
+# CHECK: arm64
+# CHECK: a
 # CHECK: 0x00019b0db3a8
 # CHECK: foo + 72
 "3   He 0x1	0x00019b0db3a8 foo + 72"
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -101,10 +101,22 @@
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile(
 '^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-frame_regex = re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
-null_frame_regex = re.compile('^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
-image_regex_uuid = re.compile(
-'(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)? (.*)')
+version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
+frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
+ r'+(.+?)'r'\s+'   # img_name
+ r'(' +version+ r')?'  # img_version
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+)
+null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
+  r'\s+' '-' r'\s+'  #   -
+  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
+  r'[+]?(.+?)'r'\s+' # img_name
+  r'(' +version+ ')?'# img_version
+  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)'   # img_path
+ )
 empty_line_regex = re.compile('^$')
 
 class Thread:
@@ -489,18 +501,20 @@
 continue
 frame_match = self.frame_regex.search(line)
 if frame_match:
-ident = frame_match.group(2)
+(frame_id, frame_img_name, _, frame_img_version, _,
+ frame_addr, frame_ofs) = frame_match.groups()
+ident = frame_img_name
 thread.add_ident(ident

[Lldb-commits] [PATCH] D69871: crashlog.py: Improve regular expressions

2019-11-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 228139.
aprantl added a comment.

Added some more tests as suggested by Jason and made the regex slightly more 
robust by requiring a `/` at the beginning of `img_path`. All crashlogs I found 
were meeting this requirement.


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

https://reviews.llvm.org/D69871

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/Python/crashlog.test

Index: lldb/test/Shell/Python/crashlog.test
===
--- lldb/test/Shell/Python/crashlog.test
+++ lldb/test/Shell/Python/crashlog.test
@@ -1,5 +1,6 @@
 # -*- python -*-
 # REQUIRES: system-darwin
+# DEBUG: cd %S/../../../examples/python && cat %s | %lldb && false
 # RUN: cd %S/../../../examples/python && cat %s | %lldb | FileCheck %s
 # CHECK-LABEL: {{S}}KIP BEYOND CHECKS
 script
@@ -32,11 +33,11 @@
 "0x111 - 0x2 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro",
 # CHECK: 0x111
 # CHECK: 0x2
-# CHECK: MyApp Pro arm64
-# CHECK: None
+# CHECK: MyApp Pro
+# CHECK: arm64
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
-
+
 "0x111 - 0x2 +MyApp Pro (0) <01234> /tmp/MyApp Pro.app/MyApp Pro",
 # CHECK: 0x111
 # CHECK: 0x2
@@ -45,13 +46,45 @@
 # CHECK: 01234
 # CHECK: /tmp/MyApp Pro.app/MyApp Pro
 
-"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
+"0x111 - 0x222 MyFramework Plus.dylib (1.11 - MyFramework 1.11) <01234> /tmp/MyFramework Plus.dylib",
+# CHECK: 0x111
+# CHECK: 0x222
+# CHECK: MyFramework Plus.dylib
+# CHECK: ({{.*}}
+# CHECK: 1.11 - MyFramework 1.11
+# CHECK: <{{.*}}
+# CHECK: 01234
+# CHECK: /tmp/MyFramework Plus.dylib
+
+"0x111 - 0x222 MyFramework-dev.dylib (1.0.0svn - 1.0.0svn) <01234> /MyFramework-dev.dylib",
+# CHECK: 0x111
+# CHECK: 0x222
+# CHECK: MyFramework-dev.dylib
+# CHECK: ({{.*}}
+# CHECK: 1.0.0svn - 1.0.0svn
+# CHECK: <{{.*}}
+# CHECK: 01234
+# CHECK: /MyFramework-dev.dylib
+
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib",
 # CHECK: 0x7fff63f2
 # CHECK: 0x7fff63f77ff7
 # CHECK: libc++.1.dylib
+# CHECK: 4
 # CHECK: (400.9.4)
 # CHECK: None
+# CHECK: None
 # CHECK: /usr/lib/libc++.1.dylib
+
+"0x1047b8000 - 0x10481 dyld arm64e   /usr/lib/dyld"
+# CHECK: 0x1047b8000
+# CHECK: 0x10481
+# CHECK: dyld
+# CHECK: a
+# CHECK: arm64e
+# CHECK: )? (.*)')
+version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
+frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
+ r'+(.+?)'r'\s+'   # img_name
+ r'(' +version+ r')?'  # img_version
+ r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
+ r' +(.*)' # offs
+)
+null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
+  r'\s+' '-' r'\s+'  #   -
+  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
+  r'[+]?(.+?)'r'\s+' # img_name
+  r'(' +version+ ')?'# img_version
+  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)'   # img_path
+ )
 empty_line_regex = re.compile('^$')
 
 class Thread:
@@ -489,18 +501,20 @@
 continue
 frame_match = self.frame_regex.search(line)
 if frame_match:
-ident = frame_match.group(2)
+(frame_id, frame_img_name, _, frame_img_version, _,
+ frame_addr, frame_ofs) = frame_match.groups()
+ident = frame_img_name
 thread.add_ident(ident)
 if ident not in self.idents:
 self.idents.append(ident)
-thread.frames.append(CrashLog.Frame(int(frame_match.group(1)), int(
-frame_match.group(3), 0), frame_match.group(4)))
+thread.frames.append(CrashLog.Frame(int(frame_id), int(
+frame_addr, 0), frame_ofs))
 else:
 print('error: frame regex failed for line: "%s"' % line)
 elif parse_mode == PARSE_MODE_IMAGES:
 image_match = self.image_regex_uuid.search(line)
 if image_match:
-(img_lo, img_hi, img_name, img_version,
+(img_lo, img_hi, img_name, _, img_version, _,
  _, img_uuid, img_path) = image_match.groups()
 image = CrashLog.DarwinImage

[Lldb-commits] [lldb] 83393d2 - [LLDB] Fix handling for the clang name mangling extension for block invocations

2019-11-06 Thread via lldb-commits

Author: shafik
Date: 2019-11-06T14:20:00-08:00
New Revision: 83393d27af6631d1df5c549feb214abbdd1d6054

URL: 
https://github.com/llvm/llvm-project/commit/83393d27af6631d1df5c549feb214abbdd1d6054
DIFF: 
https://github.com/llvm/llvm-project/commit/83393d27af6631d1df5c549feb214abbdd1d6054.diff

LOG: [LLDB] Fix handling for the clang name mangling extension for block 
invocations

Add support for clangs  mangling extension for block invocations.

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

Added: 


Modified: 
lldb/include/lldb/Core/Mangled.h
lldb/source/Core/Mangled.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/unittests/Core/MangledTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Mangled.h 
b/lldb/include/lldb/Core/Mangled.h
index 63fa0f618dae..8d6fa77745e5 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -261,6 +261,15 @@ class Mangled {
   bool DemangleWithRichManglingInfo(RichManglingContext &context,
 SkipMangledNameFn *skip_mangled_name);
 
+  /// Try to identify the mangling scheme used.
+  /// \param[in] name
+  /// The name we are attempting to identify the mangling scheme for.
+  ///
+  /// \return
+  /// eManglingSchemeNone if no known mangling scheme could be identified
+  /// for s, otherwise the enumerator for the mangling scheme detected.
+  static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name);
+
 private:
   /// Mangled member variables.
   ConstString m_mangled;   ///< The mangled version of the name

diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index b06656aa3fb7..15baffd212af 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -32,18 +32,8 @@
 #include 
 using namespace lldb_private;
 
-static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
-  if (s) {
-if (s[0] == '?')
-  return Mangled::eManglingSchemeMSVC;
-if (s[0] == '_' && s[1] == 'Z')
-  return Mangled::eManglingSchemeItanium;
-  }
-  return Mangled::eManglingSchemeNone;
-}
-
-static inline bool cstring_is_mangled(const char *s) {
-  return cstring_mangling_scheme(s) != Mangled::eManglingSchemeNone;
+static inline bool cstring_is_mangled(llvm::StringRef s) {
+  return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
 }
 
 static ConstString 
@@ -99,6 +89,23 @@ get_demangled_name_without_arguments(ConstString mangled,
 
 #pragma mark Mangled
 
+Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) 
{
+  if (name.empty())
+return Mangled::eManglingSchemeNone;
+
+  if (name.startswith("?"))
+return Mangled::eManglingSchemeMSVC;
+
+  if (name.startswith("_Z"))
+return Mangled::eManglingSchemeItanium;
+
+  // ___Z is a clang extension of block invocations
+  if (name.startswith("___Z"))
+return Mangled::eManglingSchemeItanium;
+
+  return Mangled::eManglingSchemeNone;
+}
+
 Mangled::Mangled(ConstString s) : m_mangled(), m_demangled() {
   if (s)
 SetValue(s);
@@ -159,7 +166,7 @@ void Mangled::SetValue(ConstString s, bool mangled) {
 
 void Mangled::SetValue(ConstString name) {
   if (name) {
-if (cstring_is_mangled(name.GetCString())) {
+if (cstring_is_mangled(name.GetStringRef())) {
   m_demangled.Clear();
   m_mangled = name;
 } else {
@@ -232,7 +239,7 @@ bool Mangled::DemangleWithRichManglingInfo(
   assert(m_mangled);
 
   // Check whether or not we are interested in this name at all.
-  ManglingScheme scheme = cstring_mangling_scheme(m_mangled.GetCString());
+  ManglingScheme scheme = GetManglingScheme(m_mangled.GetStringRef());
   if (skip_mangled_name && skip_mangled_name(m_mangled.GetStringRef(), scheme))
 return false;
 
@@ -300,7 +307,7 @@ Mangled::GetDemangledName(lldb::LanguageType language) 
const {
 
 // Don't bother running anything that isn't mangled
 const char *mangled_name = m_mangled.GetCString();
-ManglingScheme mangling_scheme{cstring_mangling_scheme(mangled_name)};
+ManglingScheme mangling_scheme = 
GetManglingScheme(m_mangled.GetStringRef());
 if (mangling_scheme != eManglingSchemeNone &&
 !m_mangled.GetMangledCounterpart(m_demangled)) {
   // We didn't already mangle this name, demangle it and if all goes well
@@ -405,6 +412,7 @@ size_t Mangled::MemorySize() const {
 // within those targets.
 lldb::LanguageType Mangled::GuessLanguage() const {
   ConstString mangled = GetMangledName();
+
   if (mangled) {
 const char *mangled_name = mangled.GetCString();
 if (CPlusPlusLanguage::IsCPPMangledName(mangled_name))

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 489fa7d0ad91..5886

[Lldb-commits] [PATCH] D69738: Fix handling for the clang name mangling extension for block invocations

2019-11-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
shafik marked 2 inline comments as done.
Closed by commit rG83393d27af66: [LLDB] Fix handling for the clang name 
mangling extension for block invocations (authored by shafik).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69738

Files:
  lldb/include/lldb/Core/Mangled.h
  lldb/source/Core/Mangled.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
  lldb/unittests/Core/MangledTest.cpp

Index: lldb/unittests/Core/MangledTest.cpp
===
--- lldb/unittests/Core/MangledTest.cpp
+++ lldb/unittests/Core/MangledTest.cpp
@@ -37,6 +37,17 @@
   EXPECT_STREQ(ExpectedResult.GetCString(), TheDemangled.GetCString());
 }
 
+TEST(MangledTest, ResultForBlockInvocation) {
+  ConstString MangledName("___Z1fU13block_pointerFviE_block_invoke");
+  Mangled TheMangled(MangledName);
+  ConstString TheDemangled =
+  TheMangled.GetDemangledName(eLanguageTypeC_plus_plus);
+
+  ConstString ExpectedResult(
+  "invocation function for block in f(void (int) block_pointer)");
+  EXPECT_STREQ(ExpectedResult.GetCString(), TheDemangled.GetCString());
+}
+
 TEST(MangledTest, EmptyForInvalidName) {
   ConstString MangledName("_ZN1a1b1cmxktpEEvm");
   Mangled TheMangled(MangledName);
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -101,7 +101,7 @@
 
   static lldb_private::ConstString GetPluginNameStatic();
 
-  static bool IsCPPMangledName(const char *name);
+  static bool IsCPPMangledName(llvm::StringRef name);
 
   // Extract C++ context and identifier from a string using heuristic matching
   // (as opposed to
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Demangle/ItaniumDemangle.h"
 
+#include "lldb/Core/Mangled.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/UniqueCStringMap.h"
 #include "lldb/DataFormatters/CXXFunctionPointer.h"
@@ -238,18 +239,16 @@
   return res;
 }
 
-bool CPlusPlusLanguage::IsCPPMangledName(const char *name) {
+bool CPlusPlusLanguage::IsCPPMangledName(llvm::StringRef name) {
   // FIXME!! we should really run through all the known C++ Language plugins
   // and ask each one if this is a C++ mangled name
 
-  if (name == nullptr)
-return false;
+  Mangled::ManglingScheme scheme = Mangled::GetManglingScheme(name);
 
-  // MSVC style mangling
-  if (name[0] == '?')
-return true;
+  if (scheme == Mangled::eManglingSchemeNone)
+return false;
 
-  return (name[0] != '\0' && name[0] == '_' && name[1] == 'Z');
+  return true;
 }
 
 bool CPlusPlusLanguage::ExtractContextAndIdentifier(
Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -32,18 +32,8 @@
 #include 
 using namespace lldb_private;
 
-static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
-  if (s) {
-if (s[0] == '?')
-  return Mangled::eManglingSchemeMSVC;
-if (s[0] == '_' && s[1] == 'Z')
-  return Mangled::eManglingSchemeItanium;
-  }
-  return Mangled::eManglingSchemeNone;
-}
-
-static inline bool cstring_is_mangled(const char *s) {
-  return cstring_mangling_scheme(s) != Mangled::eManglingSchemeNone;
+static inline bool cstring_is_mangled(llvm::StringRef s) {
+  return Mangled::GetManglingScheme(s) != Mangled::eManglingSchemeNone;
 }
 
 static ConstString 
@@ -99,6 +89,23 @@
 
 #pragma mark Mangled
 
+Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
+  if (name.empty())
+return Mangled::eManglingSchemeNone;
+
+  if (name.startswith("?"))
+return Mangled::eManglingSchemeMSVC;
+
+  if (name.startswith("_Z"))
+return Mangled::eManglingSchemeItanium;
+
+  // ___Z is a clang extension of block invocations
+  if (name.startswith("___Z"))
+return Mangled::eManglingSchemeItanium;
+
+  return Mangled::eManglingSchemeNone;
+}
+
 Mangled::Mangled(ConstString s) : m_mangled(), m_demangled() {
   if (s)
 SetValue(s);
@@ -159,7 +166,7 @@
 
 void Mangled::SetValue(ConstString name) {
   if (name) {
-if (cstring_is_mangled(name.GetCString())) {
+if (cstring_is_mangled(name.GetStringRef())) {
   m_demangled.Clear();
   m_mangled = name;
 } else {
@@ -232,7 +239,7 @@
   assert(m_mangled);
 
   // Check

[Lldb-commits] [PATCH] D69913: Re-enable std::function formatter with fixes to improve non-cached lookup performance

2019-11-06 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: source/Symbol/CompileUnit.cpp:101
+  // m_functions_by_uid is filled in lazily but we need all the entries.
+  symbol_file->ParseFunctions(*this);
+

friss wrote:
> This seems pretty expensive. Can we Force the parsing of the functions just 
> in the compiler unit rather than the whole symbol file? If you are using a 
> dSYM, then this is going to load all the debug information in one go.
Sorry, I somehow missed that this takes a CU as argument. This seems fine.


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

https://reviews.llvm.org/D69913



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


[Lldb-commits] [lldb] 8243918 - Testuite: Support Asan test with remote testing

2019-11-06 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-06T14:28:48-08:00
New Revision: 8243918f43c6eedc2b018c1edc9c6b72fe9b3c1e

URL: 
https://github.com/llvm/llvm-project/commit/8243918f43c6eedc2b018c1edc9c6b72fe9b3c1e
DIFF: 
https://github.com/llvm/llvm-project/commit/8243918f43c6eedc2b018c1edc9c6b72fe9b3c1e.diff

LOG: Testuite: Support Asan test with remote testing

To do so, we need to register the sanitizer libraries with the target
so that they get uploaded before running. This patch adds a helper to
the test class to this effect.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py 
b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
index 6b299e6c3b8c..6b192b3fc304 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
@@ -17,7 +17,6 @@ class AsanTestCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
-@skipIfRemote
 @skipUnlessAddressSanitizer
 def test(self):
 self.build()
@@ -33,9 +32,10 @@ def setUp(self):
 
 def asan_tests(self):
 exe = self.getBuildArtifact("a.out")
-self.expect(
-"file " + exe,
-patterns=["Current executable set to .*a.out"])
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+self.registerSanitizerLibrariesWithTarget(target)
 
 self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
 

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py 
b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
index d523b472b3e7..18d99638925d 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
@@ -17,7 +17,6 @@ class AsanTestReportDataCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
-@skipIfRemote
 @skipUnlessAddressSanitizer
 @skipIf(archs=['i386'], bugnumber="llvm.org/PR36710")
 def test(self):
@@ -36,9 +35,11 @@ def setUp(self):
 
 def asan_tests(self):
 exe = self.getBuildArtifact("a.out")
-self.expect(
-"file " + exe,
-patterns=["Current executable set to .*a.out"])
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+self.registerSanitizerLibrariesWithTarget(target)
+
 self.runCmd("run")
 
 stop_reason = 
self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index f3165ab32585..0b32fc4ef585 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1922,6 +1922,15 @@ def registerSharedLibrariesWithTarget(self, target, 
shlibs):
 
 return environment
 
+def registerSanitizerLibrariesWithTarget(self, target):
+runtimes = []
+for m in target.module_iter():
+libspec = m.GetFileSpec()
+if "clang_rt" in libspec.GetFilename():
+runtimes.append(os.path.join(libspec.GetDirectory(),
+ libspec.GetFilename()))
+return self.registerSharedLibrariesWithTarget(target, runtimes)
+
 # utility methods that tests can use to access the current objects
 def target(self):
 if not self.dbg:



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


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-06 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

Yeah, weird. I wonder if this is something cmake does implicitly when the 
target is defined as `FRAMEWORK`: 
https://cmake.org/cmake/help/latest/prop_tgt/FRAMEWORK.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589



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


[Lldb-commits] [lldb] cfca005 - [lldb] Remove dead code from STLUtils.h

2019-11-06 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-11-06T15:06:29-08:00
New Revision: cfca0056f054602dd46d1224c63d2275a4ecd90f

URL: 
https://github.com/llvm/llvm-project/commit/cfca0056f054602dd46d1224c63d2275a4ecd90f
DIFF: 
https://github.com/llvm/llvm-project/commit/cfca0056f054602dd46d1224c63d2275a4ecd90f.diff

LOG: [lldb] Remove dead code from STLUtils.h

Added: 


Modified: 
lldb/include/lldb/Core/STLUtils.h
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectBreakpoint.h
lldb/source/Commands/CommandObjectCommands.h
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Commands/CommandObjectSource.h

Removed: 




diff  --git a/lldb/include/lldb/Core/STLUtils.h 
b/lldb/include/lldb/Core/STLUtils.h
index 830aca36a116..f9500aa5594e 100644
--- a/lldb/include/lldb/Core/STLUtils.h
+++ b/lldb/include/lldb/Core/STLUtils.h
@@ -23,52 +23,4 @@ struct CStringCompareFunctionObject {
   }
 };
 
-// C string equality function object (binary predicate).
-struct CStringEqualBinaryPredicate {
-  bool operator()(const char *s1, const char *s2) const {
-return strcmp(s1, s2) == 0;
-  }
-};
-
-// Templated type for finding an entry in a std::map whose value is equal
-// to something
-template  class ValueEquals {
-public:
-  ValueEquals(const S &val) : second_value(val) {}
-
-  // Compare the second item
-  bool operator()(std::pair elem) {
-return elem.second == second_value;
-  }
-
-private:
-  S second_value;
-};
-
-template 
-inline void PrintAllCollectionElements(std::ostream &s, const T &coll,
-   const char *header_cstr = nullptr,
-   const char *separator_cstr = " ") {
-  typename T::const_iterator pos;
-
-  if (header_cstr)
-s << header_cstr;
-  for (pos = coll.begin(); pos != coll.end(); ++pos) {
-s << *pos << separator_cstr;
-  }
-  s << std::endl;
-}
-
-// The function object below can be used to delete a STL container that
-// contains C++ object pointers.
-//
-// Usage: std::for_each(vector.begin(), vector.end(), for_each_delete());
-
-struct for_each_cplusplus_delete {
-  template  void operator()(T *ptr) { delete ptr; }
-};
-
-typedef std::vector STLStringArray;
-typedef std::vector CStringArray;
-
 #endif // liblldb_STLUtils_h_

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 1d13087eef69..bf444a72278a 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -36,7 +36,6 @@
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/STLUtils.h"
 #include "lldb/Core/SearchFilter.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/StructuredDataImpl.h"
@@ -1598,7 +1597,7 @@ lldb::SBModule SBTarget::AddModule(const SBModuleSpec 
&module_spec) {
   lldb::SBModule sb_module;
   TargetSP target_sp(GetSP());
   if (target_sp)
-sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up, 
+sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
  true /* notify */));
   return LLDB_RECORD_RESULT(sb_module);
 }

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.h 
b/lldb/source/Commands/CommandObjectBreakpoint.h
index 7a0d5546d7a0..d7b3a3e3f36c 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.h
+++ b/lldb/source/Commands/CommandObjectBreakpoint.h
@@ -14,7 +14,6 @@
 
 #include "lldb/Breakpoint/BreakpointName.h"
 #include "lldb/Core/Address.h"
-#include "lldb/Core/STLUtils.h"
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 #include "lldb/Interpreter/Options.h"
 #include "lldb/lldb-private.h"

diff  --git a/lldb/source/Commands/CommandObjectCommands.h 
b/lldb/source/Commands/CommandObjectCommands.h
index 468ee53344f1..ef5fc4b0a83c 100644
--- a/lldb/source/Commands/CommandObjectCommands.h
+++ b/lldb/source/Commands/CommandObjectCommands.h
@@ -10,7 +10,6 @@
 #ifndef liblldb_CommandObjectCommands_h_
 #define liblldb_CommandObjectCommands_h_
 
-#include "lldb/Core/STLUtils.h"
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 

diff  --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 10da30fb38b9..fd1b158afb16 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -111,7 +111,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
 uint32_t start_line;
 uint32_t end_line;
 uint32_t num_lines;
-STLStringArray modules;
+std::vector modules;
   };
 
 public:
@@ -708,7 +708,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
 lldb::addr_t address;
 uint32_t start_line;
 uint32_t num_lines;
-STLStringArray modules;
+std::vector modules;
 bool show_bp_locs;
 bool reverse;
  

[Lldb-commits] [lldb] a6b5daa - [test] Fix apple_simulator_test decorator when simulators are unavailable

2019-11-06 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2019-11-06T15:14:01-08:00
New Revision: a6b5daa701d3a276ace90c688f913b96d396bed1

URL: 
https://github.com/llvm/llvm-project/commit/a6b5daa701d3a276ace90c688f913b96d396bed1
DIFF: 
https://github.com/llvm/llvm-project/commit/a6b5daa701d3a276ace90c688f913b96d396bed1.diff

LOG: [test] Fix apple_simulator_test decorator when simulators are unavailable

In the case where xcodebuild fails as you set up simulator tests, you
would fail because `feature` is never defined.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 2816cb7e39a5..10f52325875e 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -364,7 +364,7 @@ def should_skip_simulator_test():
 else:
 return "%s simulator is not supported on this system." % 
platform
 except subprocess.CalledProcessError:
-return "%s is not supported on this system (xcodebuild failed)." % 
feature
+return "Simulators are unsupported on this system (xcodebuild 
failed)"
 
 return skipTestIfFn(should_skip_simulator_test)
 



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


[Lldb-commits] [lldb] 703c97b - [lldb] Mark ASan & TSan as test dependencies

2019-11-06 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-11-06T15:24:49-08:00
New Revision: 703c97be2492dfb0e4f3138e47fc1fe71c91adfa

URL: 
https://github.com/llvm/llvm-project/commit/703c97be2492dfb0e4f3138e47fc1fe71c91adfa
DIFF: 
https://github.com/llvm/llvm-project/commit/703c97be2492dfb0e4f3138e47fc1fe71c91adfa.diff

LOG: [lldb] Mark ASan & TSan as test dependencies

Without asan and tsan as test dependencies, you might end up with a
clang that points to sanitizer runtime library that hasn't been build
yet.

Added: 


Modified: 
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 759006f818fd..e5704f662f7a 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -75,8 +75,16 @@ endif()
 # This works with standalone builds as they import the clang target.
 if(TARGET clang)
   add_lldb_test_dependency(clang)
+
+  if(TARGET asan)
+add_lldb_test_dependency(asan)
+  endif()
+
+  if(TARGET tsan)
+add_lldb_test_dependency(tsan)
+  endif()
+
   if(APPLE)
-# If we build clang, we should build libcxx.
 # FIXME: Standalone builds should import the cxx target as well.
 if(LLDB_BUILT_STANDALONE)
   # For now check that the include directory exists.



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


[Lldb-commits] [lldb] e18f4db - [LLDB] Adding caching to libc++ std::function formatter for lookups that require scanning symbols

2019-11-06 Thread via lldb-commits

Author: shafik
Date: 2019-11-06T16:02:56-08:00
New Revision: e18f4db208baa84800cf304d7e15f2ee7343cd05

URL: 
https://github.com/llvm/llvm-project/commit/e18f4db208baa84800cf304d7e15f2ee7343cd05
DIFF: 
https://github.com/llvm/llvm-project/commit/e18f4db208baa84800cf304d7e15f2ee7343cd05.diff

LOG: [LLDB] Adding caching to libc++ std::function formatter for lookups that 
require scanning symbols

Performance issues lead to the libc++ std::function formatter to be disabled.
This change is the first of two changes that should address the performance 
issues and allow us to enable the formatter again.
In some cases we end up scanning the symbol table for the callable wrapped by 
std::function for those cases we will now cache the results and used the cache 
in subsequent look-ups. This still leaves a large cost for the initial lookup 
which will be addressed in the next change.

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

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
index f06ab5d70ba3..a0cf19b3bed6 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
@@ -15,11 +15,22 @@ class LibCxxFunctionTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def get_variable(self, name):
-var = self.frame().FindVariable(name)
-var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
-var.SetPreferSyntheticValue(True)
-return var
+# Run frame var for a variable twice. Verify we do not hit the cache
+# the first time but do the second time.
+def run_frame_var_check_cache_use(self, variable, result_to_match):
+self.runCmd("log timers reset")
+self.expect("frame variable " + variable,
+substrs=[variable + " =  " + result_to_match])
+self.expect("log timers dump",
+   
substrs=["lldb_private::Module::FindSymbolsMatchingRegExAndType"])
+
+self.runCmd("log timers reset")
+self.expect("frame variable " + variable,
+substrs=[variable + " =  " + result_to_match])
+self.expect("log timers dump",
+   matching=False,
+   
substrs=["lldb_private::Module::FindSymbolsMatchingRegExAndType"])
+
 
 # Temporarily skipping for everywhere b/c we are disabling the 
std::function formatter
 # due to performance issues but plan on turning it back on once they are 
addressed.
@@ -41,17 +52,22 @@ def test(self):
 substrs=['stopped',
  'stop reason = breakpoint'])
 
-self.expect("frame variable f1",
-substrs=['f1 =  Function = foo(int, int)'])
+self.run_frame_var_check_cache_use("foo2_f", "Lambda in File main.cpp 
at Line 30")
+
+lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-self.expect("frame variable f2",
-substrs=['f2 =  Lambda in File main.cpp at Line 26'])
+self.run_frame_var_check_cache_use("add_num2_f", "Lambda in File 
main.cpp at Line 21")
 
-self.expect("frame variable f3",
-substrs=['f3 =  Lambda in File main.cpp at Line 30'])
+lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-self.expect("frame variable f4",
-substrs=['f4 =  Function in File main.cpp at Line 16'])
+self.run_frame_var_check_cache_use("f2", "Lambda in File main.cpp at 
Line 43")
+self.run_frame_var_check_cache_use("f3", "Lambda in File main.cpp at 
Line 47")
+self.run_frame_var_check_cache_use("f4", "Function in File main.cpp at 
Line 16")
+
+# These cases won't hit the cache at all but also don't require
+# an expensive lookup.
+self.expect("frame variable f1",
+substrs=['f1 =  Function = foo(int, int)'])
 
 self.expect("frame variable f5",
 substrs=['f5 =  Function = Bar::add_num(int) const'])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
 
b/lldb/pac

[Lldb-commits] [PATCH] D67111: Adding caching to libc++ std::function formatter for lookups that require scanning symbols

2019-11-06 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe18f4db208ba: [LLDB] Adding caching to libc++ std::function 
formatter for lookups that… (authored by shafik).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D67111?vs=219633&id=228164#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67111

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h

Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
@@ -10,6 +10,9 @@
 #define liblldb_CPPLanguageRuntime_h_
 
 #include 
+
+#include "llvm/ADT/StringMap.h"
+
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/lldb-private.h"
@@ -82,6 +85,11 @@
   CPPLanguageRuntime(Process *process);
 
 private:
+  using OperatorStringToCallableInfoMap =
+llvm::StringMap;
+
+  OperatorStringToCallableInfoMap CallableLookupCache;
+
   DISALLOW_COPY_AND_ASSIGN(CPPLanguageRuntime);
 };
 
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -192,14 +192,33 @@
 function_address_resolved, eSymbolContextEverything, sc);
 symbol = sc.symbol;
   }
+
+auto contains_lambda_identifier = []( llvm::StringRef & str_ref ) {
+return str_ref.contains("$_") || str_ref.contains("'lambda'");
+};
 
-  auto get_name = [&first_template_parameter, &symbol]() {
+  // Case 4 or 5
+  // We eliminate these cases early because they don't need the potentially
+  // expensive lookup through the symbol table.
+  if (symbol && !symbol->GetName().GetStringRef().startswith("vtable for") &&
+  !contains_lambda_identifier(first_template_parameter) &&
+  !symbol->GetName().GetStringRef().contains("__invoke")) {
+optional_info.callable_case =
+LibCppStdFunctionCallableCase::FreeOrMemberFunction;
+optional_info.callable_address = function_address_resolved;
+optional_info.callable_symbol = *symbol;
+
+return optional_info;
+  }
+
+  auto get_name = [&first_template_parameter, &symbol, contains_lambda_identifier]() {
 // Given case 1:
 //
 //main::$_0
+//Bar::add_num2(int)::'lambda'(int)
 //
 // we want to append ::operator()()
-if (first_template_parameter.contains("$_"))
+if (contains_lambda_identifier(first_template_parameter))
   return llvm::Regex::escape(first_template_parameter.str()) +
  R"(::operator\(\)\(.*\))";
 
@@ -228,6 +247,10 @@
 
   std::string func_to_match = get_name();
 
+  auto it = CallableLookupCache.find(func_to_match);
+  if (it != CallableLookupCache.end())
+return it->second;
+
   SymbolContextList scl;
 
   target.GetImages().FindSymbolsMatchingRegExAndType(
@@ -248,7 +271,7 @@
   LineEntry line_entry;
   addr.CalculateSymbolContextLineEntry(line_entry);
 
-  if (first_template_parameter.contains("$_") ||
+  if (contains_lambda_identifier(first_template_parameter) ||
   (symbol != nullptr &&
symbol->GetName().GetStringRef().contains("__invoke"))) {
 // Case 1 and 2
@@ -262,19 +285,10 @@
   optional_info.callable_symbol = *symbol;
   optional_info.callable_line_entry = line_entry;
   optional_info.callable_address = addr;
-  return optional_info;
 }
   }
 
-  // Case 4 or 5
-  if (symbol && !symbol->GetName().GetStringRef().startswith("vtable for")) {
-optional_info.callable_case =
-LibCppStdFunctionCallableCase::FreeOrMemberFunction;
-optional_info.callable_address = function_address_resolved;
-optional_info.callable_symbol = *symbol;
-
-return optional_info;
-  }
+  CallableLookupCache[func_to_match] = optional_info;
 
   return optional_info;
 }
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
@@ -17,8 +17,25 @@
retu

[Lldb-commits] [PATCH] D69913: Re-enable std::function formatter with fixes to improve non-cached lookup performance

2019-11-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Seems fine otherwise, I think.




Comment at: include/lldb/Symbol/CompileUnit.h:174
+  lldb::FunctionSP
+  FindFunction(llvm::function_ref 
matching_lambda);
+

perhaps calling it `is_match` makes this more obvious?


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

https://reviews.llvm.org/D69913



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


[Lldb-commits] [PATCH] D69913: Re-enable std::function formatter with fixes to improve non-cached lookup performance

2019-11-06 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: include/lldb/Symbol/CompileUnit.h:172
+  /// \return
+  ///   The FunctionSP containing the first matching entry.
+  lldb::FunctionSP

Document what does the bool return value do?



Comment at: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp:299
+
+lldb::FunctionSP fsp = vtable_cu->FindFunction(find_function_matcher);
+

func_sp?


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

https://reviews.llvm.org/D69913



___
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-06 Thread António Afonso via Phabricator via lldb-commits
aadsm created this revision.
aadsm added reviewers: hhb, sgraenitz, xiaobai, smeenai.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

I want to be able to specify which python framework to use for lldb in macos. 
With python2.7 we could just rely on the MacOS one but python3.7 is not shipped 
with the OS.
An alternative is to use the one shipped with Xcode but that could be path 
dependent or maybe the user doesn't have Xcode installed at all.
A definite solution is to just ship a python framework with lldb. To make this 
possible I added two new variables:

`PYTHON_FRAMEWORK_DIR`: with the path of the Python.framework to ship and link 
against
`PYTHON_FRAMEWORK_INSTALL_RPATH`: If the install_path of the python binary uses 
an @rpath then we need to be able to set this accordingly.

Here's an example:

  
-DPYTHON_FRAMEWORK_DIR="/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework"
  -DPYTHON_FRAMEWORK_INSTALL_RPATH="@loader_path/../../../"

What do you think?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69931

Files:
  lldb/cmake/modules/LLDBFramework.cmake


Index: lldb/cmake/modules/LLDBFramework.cmake
===
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -120,3 +120,14 @@
 COMMENT "LLDB.framework: copy clang vendor-specific headers"
   )
 endif()
+
+# Import Python framework if specified
+if(PYTHON_FRAMEWORK_DIR)
+  install(DIRECTORY ${PYTHON_FRAMEWORK_DIR}
+DESTINATION ${LLDB_FRAMEWORK_INSTALL_DIR}
+COMPONENT liblldb)
+  if(PYTHON_FRAMEWORK_INSTALL_RPATH)
+set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH
+  ${PYTHON_FRAMEWORK_INSTALL_RPATH})
+  endif()
+endif()


Index: lldb/cmake/modules/LLDBFramework.cmake
===
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -120,3 +120,14 @@
 COMMENT "LLDB.framework: copy clang vendor-specific headers"
   )
 endif()
+
+# Import Python framework if specified
+if(PYTHON_FRAMEWORK_DIR)
+  install(DIRECTORY ${PYTHON_FRAMEWORK_DIR}
+DESTINATION ${LLDB_FRAMEWORK_INSTALL_DIR}
+COMPONENT liblldb)
+  if(PYTHON_FRAMEWORK_INSTALL_RPATH)
+set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH
+  ${PYTHON_FRAMEWORK_INSTALL_RPATH})
+  endif()
+endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits