[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:28
 set(default_disable_python OFF)
+set(default_disable_lua OFF)
 set(default_disable_curses OFF)

I think this will tick off some bots (and people) because it means that the 
default configuration will not build unless one has (compatible?) lua 
installed. Though I don't really like that, the usual way to handle external 
dependencies in llvm is to detect their presence and automatically disable the 
relevant functionality.

Now, that's not how things work in lldb right now, so it _may_ make sense to do 
the same for lua (though it also may make sense to port everything to the llvm 
style). However, the current lldb behavior has been a source of friction in the 
past and I suspect a fresh build error might reignite some of that.

Anyway, you have been warned...



Comment at: lldb/cmake/modules/LLDBConfig.cmake:332
+if (LLDB_DISABLE_LUA)
+  add_definitions( -DLLDB_DISABLE_LUA )
+endif()

Can we replace this (and maybe python too, while at it) with a Host/Config.h 
entry? A global definition means that one has to recompile everything when 
these change in any way, whereas in practice only a handful of files need this..


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

https://reviews.llvm.org/D71232



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


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-10 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

@labath does this one seem sensible and like what you suggested in D70848 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71108



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


[Lldb-commits] [PATCH] D71234: [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It looks like this patch already includes some non-trivial functionality, so I 
think this is a good time to start figuring out how to test this. Another 
thing, which may not be needed straight away, but which I think we should 
consider pretty early is creating some sort of c++ wrappers, similar to the 
PythonDataObject we have for python. This is so that we don't have C error 
handling code everywhere, but have things wrapped in a nicer interface with 
`llvm::Expected`s and everything.




Comment at: 
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp:47
+
+class IOHandlerLuaInterpreter : public IOHandler {
+public:

How much of this class is boiler plate? Can it be shared with something?



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp:159
+  const ExecuteScriptOptions &options) 
{
+  if (command.empty()) {
+result->AppendError("empty command passed to lua\n");

TBH, I am not sure how useful this error really is. Presumably you will get 
some sort of an error from the lua interpreter if you just let this pass..



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp:167
+  // FIXME: Redirecting stdin, stdout and stderr.
+  int success = luaL_dostring(l.State(), command.data());
+  if (success == 0)

So what happens when `command` is not null terminated? I guess you ought to 
split this into `luaL_loadbuffer && lua_pcall`..



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp:171
+
+  result->AppendErrorWithFormat("lua failed attempting to evaluate '%s'\n",
+command.data());

same here. You can just use `AppendErrorWithFormatv`..


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71234



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


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-10 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.

Sorry, I missed this one. Yes, I think this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71108



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


[Lldb-commits] [PATCH] D71237: [FormatEntity] Add mangled function name support

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

No opinion on the code, but I think the test needs to be cleaned up _a lot_.




Comment at: lldb/test/Shell/Settings/Inputs/main.cpp:1
+//===-- main.cpp *- C++ 
-*-===//
+//

This file is about 70 lines longer than necessary to test this functionality, 
and it contains a #include statement in the middle of the file which is 
completely bogus



Comment at: lldb/test/Shell/Settings/TestFrameFormatMangling.test:2
+# UNSUPPORTED: system-windows
+# RUN: %clangxx_host -std=c++14 -g -O0 %S/Inputs/main.cpp -o %t.out
+# RUN: %lldb -x -b -s %s %t.out | FileCheck %s

The -std argument doesn't seem relevant here.



Comment at: lldb/test/Shell/Settings/TestFrameFormatMangling.test:3
+# RUN: %clangxx_host -std=c++14 -g -O0 %S/Inputs/main.cpp -o %t.out
+# RUN: %lldb -x -b -s %s %t.out | FileCheck %s
+br set -p "Set break"

-x not needed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71237



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


[Lldb-commits] [PATCH] D71235: [lldb/Lua] Generate Lua Bindings and Make Them Available to the Script Interpreter

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/scripts/CMakeLists.txt:61-83
+  add_custom_command(
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapLua.cpp
+DEPENDS ${SWIG_SOURCES}
+DEPENDS ${SWIG_INTERFACES}
+DEPENDS ${SWIG_HEADERS}
+COMMAND ${SWIG_EXECUTABLE}
+-c++

This looks like it could/should be shared between lua and python.



Comment at: lldb/scripts/lldb_lua.swig:10-170
+%{
+#include 
+#include 
+%}
+
+/* The liblldb header files to be included. */
+%{

Can we figure out a way to share this stuff? I guess it could be just put into 
a common header and %included from the language-specific files..



Comment at: lldb/scripts/lldb_lua.swig:173
+%luacode%{
+lldb.SBDebugger.Initialize()
+%}

This shouldn't be needed if lua is only ever used from within lldb (mode a).



Comment at: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt:16
   ScriptInterpreterLua.cpp
+  ${lldb_lua_wrapper}
 

I'd like to discuss this bit in more detail, as you've chosen to do things 
differently than python. While it does seem strange to have python (&lua) code 
built in the API folder, there is a reason for it -- this stuff depends on the 
lldb public api. Having it here creates a loop between the API folder and this 
script interpreter. One of the effects of that will be that it will be 
impossible to create a unit test binary for testing the lower level lua code 
(which I think it would be useful, just as equivalent python unit tests are 
shown themselves to be useful). 

Unfortunately, moving this stuff to the API folder does not completely remove 
the cycle (though it makes it much easier to work around it), because there 
will still be some API code which you'll need to call from within the script 
interpreter. Right now, that's just the `luaopen_lldb` but there will be others 
in the future.

I'd like to take this opportunity to create a solid story for the separation of 
responsibilities and layering between these two entities. If we can figure out 
a good solution here, then the we could also retrofit python to follow the same 
pattern. They way I would define "good layering" is that if "A is implemented 
on top of B" then it should be possible to define the purpose of "B" as well as 
implement it without referencing any concepts which are only defined in "A".

The way I would try to define the relationship of lua/python script 
interpreters and the API code is that the script interpreter operates on the 
lower level lldb_private debugger objects -- i.e., it sits "on top of" pretty 
much everything else *except* the API folder. It implements all of the 
interesting stuff about interacting with python/lua *except* how to actually 
represent the lldb_private entities in python. This last bit a customization 
point, which needs to be provided by the thing which it uses it -- in our case 
the API folder. This could be done by having funtcions which take the 
lldb_private objects, wrap them in the appropriate lldb object, and then wrap 
*that* via swig. And unwrapping could proceed similarly. This way, the 
python/lua code would never see any lldb::SB*** classes -- it would just see 
lldb_private classes, and their fully lua wrapped versions.

And the API folder would be left with the job of wrapping lldb_private objects 
into lua form and back, which isn't totally unreasonable -- the main job of the 
API folder is to provide a stable interface to lldb, and that is something we 
want to have in lua too. It does mean that there will have to be some language 
specific code in API folder, but I currently don't see a way to avoid that 
(though I'd like to see someone try to do that).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71235



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


[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:28
 set(default_disable_python OFF)
+set(default_disable_lua OFF)
 set(default_disable_curses OFF)

labath wrote:
> I think this will tick off some bots (and people) because it means that the 
> default configuration will not build unless one has (compatible?) lua 
> installed. Though I don't really like that, the usual way to handle external 
> dependencies in llvm is to detect their presence and automatically disable 
> the relevant functionality.
> 
> Now, that's not how things work in lldb right now, so it _may_ make sense to 
> do the same for lua (though it also may make sense to port everything to the 
> llvm style). However, the current lldb behavior has been a source of friction 
> in the past and I suspect a fresh build error might reignite some of that.
> 
> Anyway, you have been warned...
Fixing this is one of the things at the far end of my todo. If you could look 
into replacing the disable logic with something better, a lot of people would 
really be grateful.


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

https://reviews.llvm.org/D71232



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


[Lldb-commits] [PATCH] D71251: [lldb] Actually enabled wchar support in Editline when it is defined in the host config

2019-12-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: labath.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.
teemperor added a comment.

If anyone wants to test this pre-commit, that would be appreciated as I fear 
we'll find some Editline implementations that will freak out over this patch. I 
tested this on Arch Linux and macOS.


Our Editline implementation in LLDB supports using the wchar interface of 
Editline which
should improve handling of unicode input when using Editline. At the moment we 
essentially
just ignore it and print the escaped unicode code point to the command line 
(which we then
also incorrectly treat as multiple characters, so console navigation is also 
broken afterwards).

This patch just adds the include to the host config file which already contains 
the LLDB_EDITLINE_USE_WCHAR
define to enable the Editline support (we just never included it in the file 
before).

Also adds a test that the unicode we put into Editline actually ends up being 
interpreted as unicode
and not just ends up being ignored in Editline.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71251

Files:
  lldb/include/lldb/Host/Editline.h
  lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py


Index: lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+"""
+Test unicode handling in LLDB.
+"""
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_unicode_input(self):
+self.launch()
+
+# Pass in some unicode that should be read correctly.
+self.child.send(u'\u1234\n')
+# We should get out that this is an invalid command with our character 
as UTF-8.
+self.child.expect(u"error: '\u1234' is not a valid 
command.".encode('utf-8'))
+
+self.quit()
Index: lldb/include/lldb/Host/Editline.h
===
--- lldb/include/lldb/Host/Editline.h
+++ lldb/include/lldb/Host/Editline.h
@@ -32,6 +32,8 @@
 #define liblldb_Editline_h_
 #if defined(__cplusplus)
 
+#include "lldb/Host/Config.h"
+
 #if LLDB_EDITLINE_USE_WCHAR
 #include 
 #endif


Index: lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+"""
+Test unicode handling in LLDB.
+"""
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_unicode_input(self):
+self.launch()
+
+# Pass in some unicode that should be read correctly.
+self.child.send(u'\u1234\n')
+# We should get out that this is an invalid command with our character as UTF-8.
+self.child.expect(u"error: '\u1234' is not a valid command.".encode('utf-8'))
+
+self.quit()
Index: lldb/include/lldb/Host/Editline.h
===
--- lldb/include/lldb/Host/Editline.h
+++ lldb/include/lldb/Host/Editline.h
@@ -32,6 +32,8 @@
 #define liblldb_Editline_h_
 #if defined(__cplusplus)
 
+#include "lldb/Host/Config.h"
+
 #if LLDB_EDITLINE_USE_WCHAR
 #include 
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71251: [lldb] Actually enabled wchar support in Editline when it is defined in the host config

2019-12-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

If anyone wants to test this pre-commit, that would be appreciated as I fear 
we'll find some Editline implementations that will freak out over this patch. I 
tested this on Arch Linux and macOS.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71251



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


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-10 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0f72441c898: [LLDB] [PECOFF] Make sure to set the address 
byte size in m_data after parsing… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71108

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Symbol/ObjectFile.cpp


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor &data) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -315,6 +315,7 @@
   ParseCOFFOptionalHeader(&offset);
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor &data) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -315,6 +315,7 @@
   ParseCOFFOptionalHeader(&offset);
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e9895c6 - [lldb][NFC] Make g_TotalSizeOfMetadata in ClangExternalASTSourceCommon.cpp static

2019-12-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-10T13:46:12+01:00
New Revision: e9895c612a5a331660020172affa927664e138ad

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

LOG: [lldb][NFC] Make g_TotalSizeOfMetadata in ClangExternalASTSourceCommon.cpp 
static

Clang was warning that this global should be static (which makes sense).

Added: 


Modified: 
lldb/source/Symbol/ClangExternalASTSourceCommon.cpp

Removed: 




diff  --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp 
b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
index 3dcf9051d0a4..2309bc60d617 100644
--- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
+++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -13,7 +13,7 @@
 
 using namespace lldb_private;
 
-uint64_t g_TotalSizeOfMetadata = 0;
+static uint64_t g_TotalSizeOfMetadata = 0;
 
 typedef llvm::DenseMap



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


[Lldb-commits] [PATCH] D71251: [lldb] Actually enable wchar support in Editline when it is defined in the host config

2019-12-10 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.

Looks like there are still some issues with echoing unicode characters on 
linux, but this is still an improvement over status quo everywhere, so I see no 
reason to hold it up over that.




Comment at: 
lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py:24-26
+self.child.send(u'\u1234\n')
+# We should get out that this is an invalid command with our character 
as UTF-8.
+self.child.expect(u"error: '\u1234' is not a valid 
command.".encode('utf-8'))

I'd recommend using `self.expect` here. Right now the only difference is that 
it will do an additional `expect_prompt` after the command (which could 
possible help with the stability of this test, but probably won't make a 
difference), but the command may gain additional improvements over time.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71251



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


[Lldb-commits] [PATCH] D71212: [lldb] Centralize type "desugaring" logic in ClangASTContext

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: lldb/source/Symbol/ClangASTContext.cpp:2489
+case clang::Type::Typedef:
+  type = cast(type)->getDecl()->getUnderlyingType();
+  break;

teemperor wrote:
> QualType already has a `getDesugaredType` implementation that does the same 
> (but handles more cases, so you still need the switch statement but you can 
> unify all the case bodies if you want to keep this NFC).
Good idea. I should have checked clang for similar functionality. Though, the 
right function here seems to be `getLocallyUnqualifiedSingleStepDesugaredType`. 
"SingleStep" because we want to avoid desugaring all the way if the caller has 
asked us to stop at typedefs. And "LocallyUnqualified" because: a) that's what 
the current code does; b) the non-locally unqualified version requires a 
ClangASTContext, which is not available in all callers.

That said, I think that the `LocallyUnqualified` thing should be fixed as it's 
probably the cause of some subtle bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71212



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


[Lldb-commits] [lldb] f482708 - [lldb] Centralize type "desugaring" logic in ClangASTContext

2019-12-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-10T14:05:10+01:00
New Revision: f482708149138088f74f6b01668208a8c037563c

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

LOG: [lldb] Centralize type "desugaring" logic in ClangASTContext

Summary:
A *lot* of ClangASTContext functions contained repetitive code for
"desugaring" certain kinds of clang types. This patch creates a utility
function for performing this task.

Right now it handles four types (auto, elaborated, paren and typedef),
as these are the types that were handled everywhere. There are probably
other kinds of types that could/should be added here too (TypeOf,
decltype, ...), but I'm leaving that for a separate patch as doing that
would not be NFC (though I'm pretty sure that adding them will not hurt,
and it may in fact fix some bugs).

In another patch I'd like to add "atomic" type to this list to properly
display atomic structs.

Since sometimes one may want to handle a certain kind of type specially
(right now we have code which does that with typedefs), the Desugar
function takes a "mask" argument, which can supress desugaring of
certain kinds of types.

Reviewers: teemperor, shafik

Subscribers: jfb, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Symbol/ClangASTContext.cpp

Removed: 




diff  --git a/lldb/source/Symbol/ClangASTContext.cpp 
b/lldb/source/Symbol/ClangASTContext.cpp
index b765dfb3df36..8c5b0cae34b7 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -2466,12 +2466,34 @@ ClangASTContext::GetDeclContextForType(const 
CompilerType &type) {
   return GetDeclContextForType(ClangUtil::GetQualType(type));
 }
 
+/// Aggressively desugar the provided type, skipping past various kinds of
+/// syntactic sugar and other constructs one typically wants to ignore.
+/// The \p mask argument allows one to skip certain kinds of simplifications,
+/// when one wishes to handle a certain kind of type directly.
+static QualType Desugar(QualType type,
+ArrayRef mask = {}) {
+  while (true) {
+if (find(mask, type->getTypeClass()) != mask.end())
+  return type;
+switch (type->getTypeClass()) {
+case clang::Type::Auto:
+case clang::Type::Elaborated:
+case clang::Type::Paren:
+case clang::Type::Typedef:
+  type = type->getLocallyUnqualifiedSingleStepDesugaredType();
+  break;
+default:
+  return type;
+}
+  }
+}
+
 clang::DeclContext *
 ClangASTContext::GetDeclContextForType(clang::QualType type) {
   if (type.isNull())
 return nullptr;
 
-  clang::QualType qual_type = type.getCanonicalType();
+  clang::QualType qual_type = Desugar(type.getCanonicalType());
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
   case clang::Type::ObjCInterface:
@@ -2485,19 +2507,6 @@ ClangASTContext::GetDeclContextForType(clang::QualType 
type) {
 return llvm::cast(qual_type)->getDecl();
   case clang::Type::Enum:
 return llvm::cast(qual_type)->getDecl();
-  case clang::Type::Typedef:
-return GetDeclContextForType(llvm::cast(qual_type)
- ->getDecl()
- ->getUnderlyingType());
-  case clang::Type::Auto:
-return GetDeclContextForType(
-llvm::cast(qual_type)->getDeducedType());
-  case clang::Type::Elaborated:
-return GetDeclContextForType(
-llvm::cast(qual_type)->getNamedType());
-  case clang::Type::Paren:
-return GetDeclContextForType(
-llvm::cast(qual_type)->desugar());
   default:
 break;
   }
@@ -2508,6 +2517,7 @@ ClangASTContext::GetDeclContextForType(clang::QualType 
type) {
 static bool GetCompleteQualType(clang::ASTContext *ast,
 clang::QualType qual_type,
 bool allow_completion = true) {
+  qual_type = Desugar(qual_type);
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
   case clang::Type::ConstantArray:
@@ -2609,27 +2619,6 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 }
   } break;
 
-  case clang::Type::Typedef:
-return GetCompleteQualType(ast, llvm::cast(qual_type)
-->getDecl()
-->getUnderlyingType(),
-   allow_completion);
-
-  case clang::Type::Auto:
-return GetCompleteQualType(
-ast, llvm::cast(qual_type)->getDeducedType(),
-allow_completion);
-
-  case clang::Type::Elaborated:
-return GetCompleteQualType(
-ast, llvm::cast(qual_type)->getNamedType(),
-allow_completion);
-
-  case clang::Type::Paren:
-r

[Lldb-commits] [PATCH] D71212: [lldb] Centralize type "desugaring" logic in ClangASTContext

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf48270814913: [lldb] Centralize type "desugaring" 
logic in ClangASTContext (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D71212?vs=232868&id=233062#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71212

Files:
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -2466,12 +2466,34 @@
   return GetDeclContextForType(ClangUtil::GetQualType(type));
 }
 
+/// Aggressively desugar the provided type, skipping past various kinds of
+/// syntactic sugar and other constructs one typically wants to ignore.
+/// The \p mask argument allows one to skip certain kinds of simplifications,
+/// when one wishes to handle a certain kind of type directly.
+static QualType Desugar(QualType type,
+ArrayRef mask = {}) {
+  while (true) {
+if (find(mask, type->getTypeClass()) != mask.end())
+  return type;
+switch (type->getTypeClass()) {
+case clang::Type::Auto:
+case clang::Type::Elaborated:
+case clang::Type::Paren:
+case clang::Type::Typedef:
+  type = type->getLocallyUnqualifiedSingleStepDesugaredType();
+  break;
+default:
+  return type;
+}
+  }
+}
+
 clang::DeclContext *
 ClangASTContext::GetDeclContextForType(clang::QualType type) {
   if (type.isNull())
 return nullptr;
 
-  clang::QualType qual_type = type.getCanonicalType();
+  clang::QualType qual_type = Desugar(type.getCanonicalType());
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
   case clang::Type::ObjCInterface:
@@ -2485,19 +2507,6 @@
 return llvm::cast(qual_type)->getDecl();
   case clang::Type::Enum:
 return llvm::cast(qual_type)->getDecl();
-  case clang::Type::Typedef:
-return GetDeclContextForType(llvm::cast(qual_type)
- ->getDecl()
- ->getUnderlyingType());
-  case clang::Type::Auto:
-return GetDeclContextForType(
-llvm::cast(qual_type)->getDeducedType());
-  case clang::Type::Elaborated:
-return GetDeclContextForType(
-llvm::cast(qual_type)->getNamedType());
-  case clang::Type::Paren:
-return GetDeclContextForType(
-llvm::cast(qual_type)->desugar());
   default:
 break;
   }
@@ -2508,6 +2517,7 @@
 static bool GetCompleteQualType(clang::ASTContext *ast,
 clang::QualType qual_type,
 bool allow_completion = true) {
+  qual_type = Desugar(qual_type);
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
   case clang::Type::ConstantArray:
@@ -2609,27 +2619,6 @@
 }
   } break;
 
-  case clang::Type::Typedef:
-return GetCompleteQualType(ast, llvm::cast(qual_type)
-->getDecl()
-->getUnderlyingType(),
-   allow_completion);
-
-  case clang::Type::Auto:
-return GetCompleteQualType(
-ast, llvm::cast(qual_type)->getDeducedType(),
-allow_completion);
-
-  case clang::Type::Elaborated:
-return GetCompleteQualType(
-ast, llvm::cast(qual_type)->getNamedType(),
-allow_completion);
-
-  case clang::Type::Paren:
-return GetCompleteQualType(
-ast, llvm::cast(qual_type)->desugar(),
-allow_completion);
-
   case clang::Type::Attributed:
 return GetCompleteQualType(
 ast, llvm::cast(qual_type)->getModifiedType(),
@@ -2662,7 +2651,7 @@
 // Tests
 
 bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) {
-  clang::QualType qual_type(GetCanonicalQualType(type));
+  clang::QualType qual_type(Desugar(GetCanonicalQualType(type)));
 
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
@@ -2675,22 +2664,6 @@
   case clang::Type::ObjCObject:
   case clang::Type::ObjCInterface:
 return true;
-  case clang::Type::Auto:
-return IsAggregateType(llvm::cast(qual_type)
-   ->getDeducedType()
-   .getAsOpaquePtr());
-  case clang::Type::Elaborated:
-return IsAggregateType(llvm::cast(qual_type)
-   ->getNamedType()
-   .getAsOpaquePtr());
-  case clang::Type::Typedef:
-return IsAggregateType(llvm::cast(qual_type)
-   ->getDecl()
-   ->getUnderlyingType()
-   .getAsOpaquePtr());
-  case clang::Type::Paren:
-return IsAggregateType(
-llvm::cast(qual_type)->desugar().getAsOpaquePtr()

[Lldb-commits] [PATCH] D71262: [lldb] "See through" atomic types in ClangASTContext

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, shafik.
Herald added a subscriber: jfb.
Herald added a project: LLDB.

This enables us to display the contents of atomic structs. Calling the
removal of _Atomic "desugaring" is not fully correct as it does more
than remove sugar, but it is the right thing to do for most of the
things that we care about. We can change this back once we decide to
support atomic types more comprehensively.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71262

Files:
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s
===
--- lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s
+++ lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s
@@ -4,13 +4,13 @@
 # RUN: %lldb %t -o "target variable integer structure" -o exit | FileCheck %s
 
 # CHECK: (_Atomic(int)) integer = 14159
-# CHECK: (_Atomic(struct_type)) structure = {}
+# CHECK: (_Atomic(struct_type)) structure = (member = 71828)
 
 .data
 integer:
 .long 14159
 structure:
-.byte 0
+.long 71828
 
 .section.debug_abbrev,"",@progbits
 .byte   1   # Abbreviation Code
@@ -53,13 +53,24 @@
 .byte   0   # EOM(2)
 .byte   5   # Abbreviation Code
 .byte   19  # DW_TAG_structure_type
-.byte   0   # DW_CHILDREN_no
+.byte   1   # DW_CHILDREN_yes
 .byte   3   # DW_AT_name
 .byte   8   # DW_FORM_string
 .byte   11  # DW_AT_byte_size
 .byte   11  # DW_FORM_data1
 .byte   0   # EOM(1)
 .byte   0   # EOM(2)
+.byte   6   # Abbreviation Code
+.byte   13  # DW_TAG_member
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   56  # DW_AT_data_member_location
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
 .byte   0   # EOM(3)
 
 .section.debug_info,"",@progbits
@@ -99,6 +110,11 @@
 .Lstruct:
 .byte   5   # Abbrev [5] DW_TAG_structure_type
 .asciz  "struct_type"   # DW_AT_name
-.byte   0   # DW_AT_byte_size
+.byte   4   # DW_AT_byte_size
+.byte   6   # Abbrev [6] DW_TAG_member
+.asciz  "member"# DW_AT_name
+.long   .Lint   # DW_AT_type
+.byte   0   # DW_AT_data_member_location
+.byte   0   # End Of Children Mark
 .byte   0   # End Of Children Mark
 .Ldebug_info_end0:
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -2476,6 +2476,11 @@
 if (find(mask, type->getTypeClass()) != mask.end())
   return type;
 switch (type->getTypeClass()) {
+// This is not fully correct as _Atomic is more than sugar, but it is
+// sufficient for the purposes we care about.
+case clang::Type::Atomic:
+  type = cast(type)->getValueType();
+  break;
 case clang::Type::Auto:
 case clang::Type::Elaborated:
 case clang::Type::Paren:
@@ -3826,11 +3831,6 @@
   ->getUnderlyingType()
   .getAsOpaquePtr())
 .GetTypeInfo(pointee_or_element_clang_type);
-  case clang::Type::Atomic:
-return CompilerType(this, llvm::cast(qual_type)
-  ->getValueType()
-  .getAsOpaquePtr())
-.GetTypeInfo(pointee_or_element_clang_type);
   case clang::Type::UnresolvedUsing:
 return 0;
 
@@ -3947,6 +3947,7 @@
   Desugar(GetQualType(type), {clang::Type::Typedef});
 
   switch (qual_type->getTypeClass()) {
+  case clang::Type::Atomic:
   case clang::Type::Auto:
   case clang::Type::Elaborated:
   case clang::Type::Paren:
@@ -4051,8 +4052,6 @@
 break;
   case clang::Type::DeducedTemplateSpecialization:
 break;
-  case clang::Type::Atomic:
-break;
   case clang::Type::Pipe:
 break;
 
@@ -4660,6 +4659,7 @@
   clang::QualType qual_type = Desugar(GetCanonicalQualType(type)

[Lldb-commits] [PATCH] D63540: Fix lookup of symbols at the same address with no size vs. size

2019-12-10 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

@omjavaid FYI the JIT error happens for me on `2019-09-26-raspbian-buster` even 
without this my patch. I will try to debug that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63540



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


[Lldb-commits] [lldb] 14f3d13 - [lldb] Actually enable wchar support in Editline when it is defined in the host config

2019-12-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-10T14:30:41+01:00
New Revision: 14f3d13412cb2eac87f1c0ae74ed2af7ace1580f

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

LOG: [lldb] Actually enable wchar support in Editline when it is defined in the 
host config

Summary:
Our Editline implementation in LLDB supports using the wchar interface of 
Editline which
should improve handling of unicode input when using Editline. At the moment we 
essentially
just ignore unicode input and echo the escaped unicode code point (`\U1234`) to 
the command line
(which we then also incorrectly treat as multiple characters, so console 
navigation is also broken afterwards).

This patch just adds the include to the host config file which already contains 
the LLDB_EDITLINE_USE_WCHAR
define to enable the Editline support (we just never included it in the file 
before). With this we now actually
echo back unicode characters on macOS and we no longer ignore unicode input. On 
Linux this doesn't
seem to improve the echoing back of characters but at least it fixes that we 
ignore unicode input.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 
lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py

Modified: 
lldb/include/lldb/Host/Editline.h

Removed: 




diff  --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 0cb2c6c5b6a1..db3d9e48cfbb 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -32,6 +32,8 @@
 #define liblldb_Editline_h_
 #if defined(__cplusplus)
 
+#include "lldb/Host/Config.h"
+
 #if LLDB_EDITLINE_USE_WCHAR
 #include 
 #endif

diff  --git 
a/lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py 
b/lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
new file mode 100644
index ..c8ff9a6ab32d
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+"""
+Test unicode handling in LLDB.
+"""
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_unicode_input(self):
+self.launch()
+
+# Send some unicode input to LLDB.
+# We should get back that this is an invalid command with our 
character as UTF-8.
+self.expect(u'\u1234', substrs=[u"error: '\u1234' is not a valid 
command.".encode('utf-8')])
+
+self.quit()



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


[Lldb-commits] [PATCH] D71251: [lldb] Actually enable wchar support in Editline when it is defined in the host config

2019-12-10 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14f3d13412cb: [lldb] Actually enable wchar support in 
Editline when it is defined in the host… (authored by teemperor).

Changed prior to commit:
  https://reviews.llvm.org/D71251?vs=233042&id=233067#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71251

Files:
  lldb/include/lldb/Host/Editline.h
  lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py


Index: lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+"""
+Test unicode handling in LLDB.
+"""
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_unicode_input(self):
+self.launch()
+
+# Send some unicode input to LLDB.
+# We should get back that this is an invalid command with our 
character as UTF-8.
+self.expect(u'\u1234', substrs=[u"error: '\u1234' is not a valid 
command.".encode('utf-8')])
+
+self.quit()
Index: lldb/include/lldb/Host/Editline.h
===
--- lldb/include/lldb/Host/Editline.h
+++ lldb/include/lldb/Host/Editline.h
@@ -32,6 +32,8 @@
 #define liblldb_Editline_h_
 #if defined(__cplusplus)
 
+#include "lldb/Host/Config.h"
+
 #if LLDB_EDITLINE_USE_WCHAR
 #include 
 #endif


Index: lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+"""
+Test unicode handling in LLDB.
+"""
+
+import os
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test_unicode_input(self):
+self.launch()
+
+# Send some unicode input to LLDB.
+# We should get back that this is an invalid command with our character as UTF-8.
+self.expect(u'\u1234', substrs=[u"error: '\u1234' is not a valid command.".encode('utf-8')])
+
+self.quit()
Index: lldb/include/lldb/Host/Editline.h
===
--- lldb/include/lldb/Host/Editline.h
+++ lldb/include/lldb/Host/Editline.h
@@ -32,6 +32,8 @@
 #define liblldb_Editline_h_
 #if defined(__cplusplus)
 
+#include "lldb/Host/Config.h"
+
 #if LLDB_EDITLINE_USE_WCHAR
 #include 
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71262: [lldb] "See through" atomic types in ClangASTContext

2019-12-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM beside my inline comment about the function name.




Comment at: lldb/source/Symbol/ClangASTContext.cpp:2483
+  type = cast(type)->getValueType();
+  break;
 case clang::Type::Auto:

In this case I would rename it to something like `getUnderlyingType`, 
`unpackType`, `removeWrappingTypes` or something like that. We shouldn't have 
our own definition of 'desugar' that differs from Clang's definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71262



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


[Lldb-commits] [PATCH] D71262: [lldb] "See through" atomic types in ClangASTContext

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 233080.
labath added a comment.

rename to RemoveWrappingTypes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71262

Files:
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s
===
--- lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s
+++ lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s
@@ -4,13 +4,13 @@
 # RUN: %lldb %t -o "target variable integer structure" -o exit | FileCheck %s
 
 # CHECK: (_Atomic(int)) integer = 14159
-# CHECK: (_Atomic(struct_type)) structure = {}
+# CHECK: (_Atomic(struct_type)) structure = (member = 71828)
 
 .data
 integer:
 .long 14159
 structure:
-.byte 0
+.long 71828
 
 .section.debug_abbrev,"",@progbits
 .byte   1   # Abbreviation Code
@@ -53,13 +53,24 @@
 .byte   0   # EOM(2)
 .byte   5   # Abbreviation Code
 .byte   19  # DW_TAG_structure_type
-.byte   0   # DW_CHILDREN_no
+.byte   1   # DW_CHILDREN_yes
 .byte   3   # DW_AT_name
 .byte   8   # DW_FORM_string
 .byte   11  # DW_AT_byte_size
 .byte   11  # DW_FORM_data1
 .byte   0   # EOM(1)
 .byte   0   # EOM(2)
+.byte   6   # Abbreviation Code
+.byte   13  # DW_TAG_member
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   56  # DW_AT_data_member_location
+.byte   11  # DW_FORM_data1
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
 .byte   0   # EOM(3)
 
 .section.debug_info,"",@progbits
@@ -99,6 +110,11 @@
 .Lstruct:
 .byte   5   # Abbrev [5] DW_TAG_structure_type
 .asciz  "struct_type"   # DW_AT_name
-.byte   0   # DW_AT_byte_size
+.byte   4   # DW_AT_byte_size
+.byte   6   # Abbrev [6] DW_TAG_member
+.asciz  "member"# DW_AT_name
+.long   .Lint   # DW_AT_type
+.byte   0   # DW_AT_data_member_location
+.byte   0   # End Of Children Mark
 .byte   0   # End Of Children Mark
 .Ldebug_info_end0:
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -2470,12 +2470,17 @@
 /// syntactic sugar and other constructs one typically wants to ignore.
 /// The \p mask argument allows one to skip certain kinds of simplifications,
 /// when one wishes to handle a certain kind of type directly.
-static QualType Desugar(QualType type,
-ArrayRef mask = {}) {
+static QualType
+RemoveWrappingTypes(QualType type, ArrayRef mask = {}) {
   while (true) {
 if (find(mask, type->getTypeClass()) != mask.end())
   return type;
 switch (type->getTypeClass()) {
+// This is not fully correct as _Atomic is more than sugar, but it is
+// sufficient for the purposes we care about.
+case clang::Type::Atomic:
+  type = cast(type)->getValueType();
+  break;
 case clang::Type::Auto:
 case clang::Type::Elaborated:
 case clang::Type::Paren:
@@ -2493,7 +2498,7 @@
   if (type.isNull())
 return nullptr;
 
-  clang::QualType qual_type = Desugar(type.getCanonicalType());
+  clang::QualType qual_type = RemoveWrappingTypes(type.getCanonicalType());
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
   case clang::Type::ObjCInterface:
@@ -2517,7 +2522,7 @@
 static bool GetCompleteQualType(clang::ASTContext *ast,
 clang::QualType qual_type,
 bool allow_completion = true) {
-  qual_type = Desugar(qual_type);
+  qual_type = RemoveWrappingTypes(qual_type);
   const clang::Type::TypeClass type_class = qual_type->getTypeClass();
   switch (type_class) {
   case clang::Type::ConstantArray:
@@ -2651,7 +2656,7 @@
 // Tests
 
 bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) {
-  clang::Qua

lldb-commits@lists.llvm.org

2019-12-10 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a project: LLDB.

This adds support for DWARF5 location lists which are specified
indirectly, via an index into the debug_loclists offset table. This
includes parsing the DW_AT_loclists_base attribute which determines the
location of this offset table, and support for new form DW_FORM_loclistx
which is used in conjuction with DW_AT_location to refer to the location
lists in this way.

The code uses the llvm class to parse the offset information, and I've
also tried to structure it similarly to how the relevant llvm
functionality works.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71268

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_loclists_base.s

Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_loclists_base.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_loclists_base.s
@@ -0,0 +1,132 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t -o "image lookup -v -s lookup_loclists" -o exit | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s lookup_loclists
+# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg0 RAX,
+# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = ,
+
+loclists:
+nop
+.Ltmp0:
+nop
+lookup_loclists:
+.Ltmp1:
+nop
+.Ltmp2:
+nop
+.Ltmp3:
+nop
+.Ltmp4:
+nop
+.Lloclists_end:
+
+.section.debug_loclists,"",@progbits
+.long   .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
+.Ldebug_loclist_table_start0:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   1   # Offset entry count
+.Lloclists_table_base:
+.long   .Ldebug_loc0-.Lloclists_table_base
+.long   .Ldebug_loc1-.Lloclists_table_base
+.Ldebug_loc0:
+.byte   4   # DW_LLE_offset_pair
+.uleb128 loclists-loclists
+.uleb128  .Ltmp2-loclists
+.uleb128 1  # Expression size
+.byte   80  # super-register DW_OP_reg0
+.byte   0   # DW_LLE_end_of_list
+.Ldebug_loc1:
+.byte   4   # DW_LLE_offset_pair
+.uleb128 .Ltmp3-loclists
+.uleb128  .Ltmp4-loclists
+.uleb128 1  # Expression size
+.byte   81  # super-register DW_OP_reg1
+.byte   0   # DW_LLE_end_of_list
+.Ldebug_loclist_table_end0:
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   19  # DW_AT_language
+.byte   5   # DW_FORM_data2
+.uleb128 0x8c   # DW_AT_loclists_base
+.byte   0x17# DW_FORM_sec_offset
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_yes
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   3   # Abbreviation Code
+.byte   5   # DW_TAG_formal_parameter
+.byte   0   # DW_CHILDREN_no
+.byte   2   # DW_AT_location
+.byte   0x22# DW_FORM_loclistx
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_r

[Lldb-commits] [PATCH] D71280: [lldb/Host] Use Host/Config.h entries instead of a global define.

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: labath.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.

As suggested by Pavel in D71232 

> Can we replace this (and maybe python too, while at it) with a Host/Config.h 
> entry? A global definition means that one has to recompile everything when 
> these change in any way, whereas in practice only a handful of files need 
> this..


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71280

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBHostOS.cpp
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/CommandObjectScript.cpp
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
  lldb/unittests/Editline/EditlineTest.cpp

Index: lldb/unittests/Editline/EditlineTest.cpp
===
--- lldb/unittests/Editline/EditlineTest.cpp
+++ lldb/unittests/Editline/EditlineTest.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_LIBEDIT
 
 #define EDITLINE_TEST_DUMP_OUTPUT 0
Index: lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -9,6 +9,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
 
+#include "lldb/Host/Config.h"
+
 // Python.h needs to be included before any system headers in order to avoid
 // redefinition of macros
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #ifdef LLDB_DISABLE_PYTHON
 
 // Python is disabled in this build
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -9,6 +9,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
 
+#include "lldb/Host/Config.h"
+
 #ifdef LLDB_DISABLE_PYTHON
 
 // Python is disabled in this build
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -48,6 +48,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_PYTHON
 
 // LLDB Python header must be included first
Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
===
--- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
+++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
@@ -9,6 +9,8 @@
 #ifndef liblldb_OperatingSystemPython_h_
 #define liblldb_OperatingSystemPython_h_
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_PYTHON
 
 #include "lldb/Target/OperatingSystem.h"
Index: lldb/source/Interpreter/CommandObjectScript.cpp
===
--- lldb/source/Interpreter/CommandObjectScript.cpp
+++ lldb/source/Interpreter/CommandObjectScript.cpp
@@ -7,12 +7,9 @@
 //===--===//
 
 #include "CommandObjectScript.h"
-
-
 #include "lldb/Core/Debugger.h"
-
 #include "lldb/DataFormatters/DataVisualization.h"
-
+#include "lldb/Host/Config.h"
 #include 

lldb-commits@lists.llvm.org

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:462
+  uint64_t header_size = llvm::DWARFListTableHeader::getHeaderSize(DWARF32);
+  if (loclists_base >= header_size) {
+m_loclist_table_header.emplace(".debug_loclists", "locations");

For symmetry, we could early-exitify this function, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71268



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


[Lldb-commits] [PATCH] D71105: [lldb/Reproducers] Support multiple GDB remotes

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 233131.
JDevlieghere added a comment.

Add test


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

https://reviews.llvm.org/D71105

Files:
  lldb/include/lldb/Utility/GDBRemote.h
  lldb/include/lldb/Utility/Reproducer.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectReproducer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/Reproducer.cpp
  lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
  lldb/test/Shell/Reproducer/TestMultipleTargets.test

Index: lldb/test/Shell/Reproducer/TestMultipleTargets.test
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/TestMultipleTargets.test
@@ -0,0 +1,23 @@
+# UNSUPPORTED: system-windows, system-freebsd
+
+# This tests the replaying with multiple targets.
+
+# RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
+
+# RUN: rm -rf %t.repro
+# RUN: %lldb -x -b --capture --capture-path %t.repro -o 'target create %t.out' -o 'target create %t.out' -s %S/Inputs/MultipleTargetsCapture.in  | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE
+# RUN: env FOO=BAR %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK --check-prefix REPLAY
+
+# CHECK: Process [[TARGET0:[0-9]+]] stopped
+# CHECK: stop reason = breakpoint 1.1
+# CHECK: simple.c:12:5
+# CHECK: Process [[TARGET1:[0-9]+]] stopped
+# CHECK: stop reason = breakpoint 1.1
+# CHECK: simple.c:16:5
+# CHECK: Process [[TARGET0]] resuming
+# CHECK: Process [[TARGET0]] exited
+# CHECK: Process [[TARGET1]] resuming
+# CHECK: Process [[TARGET1]] exited
+
+# CAPTURE: Reproducer is in capture mode.
+# CAPTURE: Reproducer written
Index: lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
@@ -0,0 +1,12 @@
+target select 0
+breakpoint set -f simple.c -l 12
+run
+target select 1
+breakpoint set -f simple.c -l 16
+run
+target select 0
+cont
+target select 1
+cont
+reproducer status
+reproducer generate
Index: lldb/source/Utility/Reproducer.cpp
===
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -255,7 +255,7 @@
 DataRecorder *CommandProvider::GetNewDataRecorder() {
   std::size_t i = m_data_recorders.size() + 1;
   std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
-  llvm::Twine(i) + llvm::Twine(".txt"))
+  llvm::Twine(i) + llvm::Twine(".yaml"))
  .str();
   auto recorder_or_error =
   DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename));
@@ -304,53 +304,9 @@
   os << m_cwd << "\n";
 }
 
-llvm::raw_ostream *ProcessGDBRemoteProvider::GetHistoryStream() {
-  FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
-
-  std::error_code EC;
-  m_stream_up = std::make_unique(history_file.GetPath(), EC,
- sys::fs::OpenFlags::OF_Text);
-  return m_stream_up.get();
-}
-
-std::unique_ptr CommandLoader::Create(Loader *loader) {
-  if (!loader)
-return {};
-
-  FileSpec file = loader->GetFile();
-  if (!file)
-return {};
-
-  auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
-  if (auto err = error_or_file.getError())
-return {};
-
-  std::vector files;
-  llvm::yaml::Input yin((*error_or_file)->getBuffer());
-  yin >> files;
-
-  if (auto err = yin.error())
-return {};
-
-  for (auto &file : files) {
-FileSpec absolute_path =
-loader->GetRoot().CopyByAppendingPathComponent(file);
-file = absolute_path.GetPath();
-  }
-
-  return std::make_unique(std::move(files));
-}
-
-llvm::Optional CommandLoader::GetNextFile() {
-  if (m_index >= m_files.size())
-return {};
-  return m_files[m_index++];
-}
-
 void ProviderBase::anchor() {}
 char CommandProvider::ID = 0;
 char FileProvider::ID = 0;
-char ProcessGDBRemoteProvider::ID = 0;
 char ProviderBase::ID = 0;
 char VersionProvider::ID = 0;
 char WorkingDirectoryProvider::ID = 0;
@@ -358,8 +314,6 @@
 const char *CommandProvider::Info::name = "command-interpreter";
 const char *FileProvider::Info::file = "files.yaml";
 const char *FileProvider::Info::name = "files";
-const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml";
-const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote";
 const char *VersionProvider::Info::file = "version.txt";
 const char *VersionProvider::Info::name = "version";
 const char *

[Lldb-commits] [PATCH] D71280: [lldb/Host] Use Host/Config.h entries instead of a global define.

2019-12-10 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.

Thanks, this should have been done a long time ago...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71280



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


[Lldb-commits] [PATCH] D71231: Replace redundant code in FormatManager and FormatCache with templates (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 233134.
aprantl added a comment.

Make (most) of the Get methods return return values, as Pavel suggested.


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

https://reviews.llvm.org/D71231

Files:
  lldb/include/lldb/DataFormatters/FormatCache.h
  lldb/include/lldb/DataFormatters/FormatManager.h
  lldb/include/lldb/DataFormatters/TypeCategoryMap.h
  lldb/source/DataFormatters/FormatCache.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp
  lldb/source/DataFormatters/TypeCategoryMap.cpp

Index: lldb/source/DataFormatters/TypeCategoryMap.cpp
===
--- lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -169,8 +169,8 @@
   return false;
 }
 
-lldb::TypeFormatImplSP
-TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
+template 
+void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
   std::lock_guard guard(m_map_mutex);
 
   uint32_t reason_why;
@@ -182,8 +182,8 @@
 for (auto match : match_data.GetMatchesVector()) {
   LLDB_LOGF(
   log,
-  "[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = "
-  "%" PRIu32,
+  "[%s] candidate match = %s %s %s %s reason = %" PRIu32,
+  __FUNCTION__,
   match.GetTypeName().GetCString(),
   match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
   match.DidStripReference() ? "strip-reference" : "no-strip-reference",
@@ -194,140 +194,34 @@
 
   for (begin = m_active_categories.begin(); begin != end; begin++) {
 lldb::TypeCategoryImplSP category_sp = *begin;
-lldb::TypeFormatImplSP current_format;
-LLDB_LOGF(log, "[TypeCategoryMap::GetFormat] Trying to use category %s",
+ImplSP current_format;
+LLDB_LOGF(log, "[%s] Trying to use category %s", __FUNCTION__,
   category_sp->GetName());
 if (!category_sp->Get(match_data.GetValueObject(),
   match_data.GetMatchesVector(), current_format,
   &reason_why))
   continue;
-return current_format;
-  }
-  LLDB_LOGF(log,
-"[TypeCategoryMap::GetFormat] nothing found - returning empty SP");
-  return lldb::TypeFormatImplSP();
-}
-
-lldb::TypeSummaryImplSP
-TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) {
-  std::lock_guard guard(m_map_mutex);
-
-  uint32_t reason_why;
-  ActiveCategoriesIterator begin, end = m_active_categories.end();
-
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-
-  if (log) {
-for (auto match : match_data.GetMatchesVector()) {
-  LLDB_LOGF(
-  log,
-  "[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s "
-  "reason = %" PRIu32,
-  match.GetTypeName().GetCString(),
-  match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
-  match.DidStripReference() ? "strip-reference" : "no-strip-reference",
-  match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
-  match.GetReason());
-}
-  }
-
-  for (begin = m_active_categories.begin(); begin != end; begin++) {
-lldb::TypeCategoryImplSP category_sp = *begin;
-lldb::TypeSummaryImplSP current_format;
-LLDB_LOGF(log, "[CategoryMap::GetSummaryFormat] Trying to use category %s",
-  category_sp->GetName());
-if (!category_sp->Get(match_data.GetValueObject(),
-  match_data.GetMatchesVector(), current_format,
-  &reason_why))
-  continue;
-return current_format;
-  }
-  LLDB_LOGF(
-  log,
-  "[CategoryMap::GetSummaryFormat] nothing found - returning empty SP");
-  return lldb::TypeSummaryImplSP();
-}
-
-lldb::SyntheticChildrenSP
-TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
-  std::lock_guard guard(m_map_mutex);
-
-  uint32_t reason_why;
-
-  ActiveCategoriesIterator begin, end = m_active_categories.end();
-
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-
-  if (log) {
-for (auto match : match_data.GetMatchesVector()) {
-  LLDB_LOGF(
-  log,
-  "[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s "
-  "reason = %" PRIu32,
-  match.GetTypeName().GetCString(),
-  match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
-  match.DidStripReference() ? "strip-reference" : "no-strip-reference",
-  match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
-  match.GetReason());
-}
-  }
 
-  for (begin = m_active_categories.begin(); begin != end; begin++) {
-lldb::TypeCategoryImplSP category_sp = *begin;
-lldb::SyntheticChildrenSP current_format;
-LLDB_LOGF(log,
-  "[CategoryMap::GetSyntheticChildren] Trying to use cate

[Lldb-commits] [lldb] 7034794 - Replace redundant code in FormatManager and FormatCache with templates (NFC)

2019-12-10 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-12-10T10:27:16-08:00
New Revision: 7034794b314d9de808de004d22b47f18d134757d

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

LOG: Replace redundant code in FormatManager and FormatCache with templates 
(NFC)

This is a preparatory patch for an upcoming bugfix.

FormatManager and friends have four identical implementations of many
accessor functions to deal with the four types of shared pointers in
the FormatCache. This patch replaces these implementations with
templates. While this patch drastically reduces the amount of source
code and its maintainablity, it doesn't actually improve code
size. I'd argue, this is still an improvement.

rdar://problem/57756763

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

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormatCache.h
lldb/include/lldb/DataFormatters/FormatManager.h
lldb/include/lldb/DataFormatters/TypeCategoryMap.h
lldb/source/DataFormatters/FormatCache.cpp
lldb/source/DataFormatters/FormatManager.cpp
lldb/source/DataFormatters/LanguageCategory.cpp
lldb/source/DataFormatters/TypeCategoryMap.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormatCache.h 
b/lldb/include/lldb/DataFormatters/FormatCache.h
index 7a6774b7f837..e8be01e55d40 100644
--- a/lldb/include/lldb/DataFormatters/FormatCache.h
+++ b/lldb/include/lldb/DataFormatters/FormatCache.h
@@ -33,36 +33,22 @@ class FormatCache {
 
   public:
 Entry();
-Entry(lldb::TypeFormatImplSP);
-Entry(lldb::TypeSummaryImplSP);
-Entry(lldb::SyntheticChildrenSP);
-Entry(lldb::TypeValidatorImplSP);
-Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
-  lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
 
+template bool IsCached();
 bool IsFormatCached();
-
 bool IsSummaryCached();
-
 bool IsSyntheticCached();
-
 bool IsValidatorCached();
 
-lldb::TypeFormatImplSP GetFormat();
-
-lldb::TypeSummaryImplSP GetSummary();
-
-lldb::SyntheticChildrenSP GetSynthetic();
-
-lldb::TypeValidatorImplSP GetValidator();
-
-void SetFormat(lldb::TypeFormatImplSP);
-
-void SetSummary(lldb::TypeSummaryImplSP);
-
-void SetSynthetic(lldb::SyntheticChildrenSP);
+void Get(lldb::TypeFormatImplSP &);
+void Get(lldb::TypeSummaryImplSP &);
+void Get(lldb::SyntheticChildrenSP &);
+void Get(lldb::TypeValidatorImplSP &);
 
-void SetValidator(lldb::TypeValidatorImplSP);
+void Set(lldb::TypeFormatImplSP);
+void Set(lldb::TypeSummaryImplSP);
+void Set(lldb::SyntheticChildrenSP);
+void Set(lldb::TypeValidatorImplSP);
   };
   typedef std::map CacheMap;
   CacheMap m_map;
@@ -76,25 +62,11 @@ class FormatCache {
 public:
   FormatCache();
 
-  bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
-
-  bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
-
-  bool GetSynthetic(ConstString type,
-lldb::SyntheticChildrenSP &synthetic_sp);
-
-  bool GetValidator(ConstString type,
-lldb::TypeValidatorImplSP &summary_sp);
-
-  void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
-
-  void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
-
-  void SetSynthetic(ConstString type,
-lldb::SyntheticChildrenSP &synthetic_sp);
-
-  void SetValidator(ConstString type,
-lldb::TypeValidatorImplSP &synthetic_sp);
+  template  bool Get(ConstString type, ImplSP 
&format_impl_sp);
+  void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);
+  void Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
+  void Set(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp);
+  void Set(ConstString type, lldb::TypeValidatorImplSP &synthetic_sp);
 
   void Clear();
 
@@ -102,6 +74,7 @@ class FormatCache {
 
   uint64_t GetCacheMisses() { return m_cache_misses; }
 };
+
 } // namespace lldb_private
 
 #endif // lldb_FormatCache_h_

diff  --git a/lldb/include/lldb/DataFormatters/FormatManager.h 
b/lldb/include/lldb/DataFormatters/FormatManager.h
index 54877284c57b..dffba1f93987 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -208,14 +208,9 @@ class FormatManager : public IFormatChangeListener {
   ConstString m_system_category_name;
   ConstString m_vectortypes_category_name;
 
-  lldb::TypeFormatImplSP GetHardcodedFormat(FormattersMatchData &);
-
-  lldb::TypeSummaryImplSP GetHardcodedSummaryFormat(FormattersMatchData &);
-
-  lldb::SyntheticChildrenSP
-  GetHardcodedSyntheticChildren(FormattersMatchData &);
-
-  lldb::TypeValidatorImplSP GetHardcodedValidator(FormattersMatchData &);
+  template 
+  ImplSP GetCach

[Lldb-commits] [PATCH] D71231: Replace redundant code in FormatManager and FormatCache with templates (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7034794b314d: Replace redundant code in FormatManager and 
FormatCache with templates (NFC) (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71231

Files:
  lldb/include/lldb/DataFormatters/FormatCache.h
  lldb/include/lldb/DataFormatters/FormatManager.h
  lldb/include/lldb/DataFormatters/TypeCategoryMap.h
  lldb/source/DataFormatters/FormatCache.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp
  lldb/source/DataFormatters/TypeCategoryMap.cpp

Index: lldb/source/DataFormatters/TypeCategoryMap.cpp
===
--- lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -169,8 +169,8 @@
   return false;
 }
 
-lldb::TypeFormatImplSP
-TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
+template 
+void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
   std::lock_guard guard(m_map_mutex);
 
   uint32_t reason_why;
@@ -182,8 +182,8 @@
 for (auto match : match_data.GetMatchesVector()) {
   LLDB_LOGF(
   log,
-  "[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = "
-  "%" PRIu32,
+  "[%s] candidate match = %s %s %s %s reason = %" PRIu32,
+  __FUNCTION__,
   match.GetTypeName().GetCString(),
   match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
   match.DidStripReference() ? "strip-reference" : "no-strip-reference",
@@ -194,140 +194,34 @@
 
   for (begin = m_active_categories.begin(); begin != end; begin++) {
 lldb::TypeCategoryImplSP category_sp = *begin;
-lldb::TypeFormatImplSP current_format;
-LLDB_LOGF(log, "[TypeCategoryMap::GetFormat] Trying to use category %s",
+ImplSP current_format;
+LLDB_LOGF(log, "[%s] Trying to use category %s", __FUNCTION__,
   category_sp->GetName());
 if (!category_sp->Get(match_data.GetValueObject(),
   match_data.GetMatchesVector(), current_format,
   &reason_why))
   continue;
-return current_format;
-  }
-  LLDB_LOGF(log,
-"[TypeCategoryMap::GetFormat] nothing found - returning empty SP");
-  return lldb::TypeFormatImplSP();
-}
-
-lldb::TypeSummaryImplSP
-TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) {
-  std::lock_guard guard(m_map_mutex);
-
-  uint32_t reason_why;
-  ActiveCategoriesIterator begin, end = m_active_categories.end();
-
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-
-  if (log) {
-for (auto match : match_data.GetMatchesVector()) {
-  LLDB_LOGF(
-  log,
-  "[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s "
-  "reason = %" PRIu32,
-  match.GetTypeName().GetCString(),
-  match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
-  match.DidStripReference() ? "strip-reference" : "no-strip-reference",
-  match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
-  match.GetReason());
-}
-  }
-
-  for (begin = m_active_categories.begin(); begin != end; begin++) {
-lldb::TypeCategoryImplSP category_sp = *begin;
-lldb::TypeSummaryImplSP current_format;
-LLDB_LOGF(log, "[CategoryMap::GetSummaryFormat] Trying to use category %s",
-  category_sp->GetName());
-if (!category_sp->Get(match_data.GetValueObject(),
-  match_data.GetMatchesVector(), current_format,
-  &reason_why))
-  continue;
-return current_format;
-  }
-  LLDB_LOGF(
-  log,
-  "[CategoryMap::GetSummaryFormat] nothing found - returning empty SP");
-  return lldb::TypeSummaryImplSP();
-}
-
-lldb::SyntheticChildrenSP
-TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
-  std::lock_guard guard(m_map_mutex);
-
-  uint32_t reason_why;
-
-  ActiveCategoriesIterator begin, end = m_active_categories.end();
-
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-
-  if (log) {
-for (auto match : match_data.GetMatchesVector()) {
-  LLDB_LOGF(
-  log,
-  "[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s "
-  "reason = %" PRIu32,
-  match.GetTypeName().GetCString(),
-  match.DidStripPointer() ? "strip-pointers" : "no-strip-pointers",
-  match.DidStripReference() ? "strip-reference" : "no-strip-reference",
-  match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef",
-  match.GetReason());
-}
-  }
 
-  for (begin = m_active_categories.begin(); 

[Lldb-commits] [PATCH] D71233: Do not cache hardcoded formats in FormatManager

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 233145.
aprantl added a comment.

Rebase.


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

https://reviews.llvm.org/D71233

Files:
  lldb/include/lldb/DataFormatters/FormatManager.h
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
  lldb/source/DataFormatters/FormatManager.cpp

Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -622,11 +622,21 @@
   return retval_sp;
 }
 
-template  ImplSP
-FormatManager::GetCached(ValueObject &valobj,
- lldb::DynamicValueType use_dynamic) {
-  ImplSP retval_sp;
+template 
+ImplSP FormatManager::Get(ValueObject &valobj,
+  lldb::DynamicValueType use_dynamic) {
   FormattersMatchData match_data(valobj, use_dynamic);
+  if (ImplSP retval_sp = GetCached(match_data))
+return retval_sp;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
+  return GetHardcoded(match_data);
+}
+
+template 
+ImplSP FormatManager::GetCached(FormattersMatchData &match_data) {
+  ImplSP retval_sp;
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
   if (match_data.GetTypeForCache()) {
 LLDB_LOGF(log, "\n\n[%s] Looking into cache for type %s", __FUNCTION__,
@@ -659,10 +669,6 @@
   return retval_sp;
 }
   }
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
-retval_sp = GetHardcoded(match_data);
-  }
 
   if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
@@ -678,25 +684,25 @@
 lldb::TypeFormatImplSP
 FormatManager::GetFormat(ValueObject &valobj,
  lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 lldb::TypeSummaryImplSP
 FormatManager::GetSummaryFormat(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 lldb::SyntheticChildrenSP
 FormatManager::GetSyntheticChildren(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 lldb::TypeValidatorImplSP
 FormatManager::GetValidator(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 FormatManager::FormatManager()
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
@@ -0,0 +1,8 @@
+typedef float float4 __attribute__((ext_vector_type(4)));
+void stop() {}
+int a() {
+  float4 f4 = {1, 2, 3, 4};
+  // break here
+  stop();
+  return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
@@ -0,0 +1,7 @@
+typedef float float4;
+
+int main() {
+  float4 f = 4.0f;
+  // break here
+  return a(); 
+}
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
@@ -0,0 +1,27 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestDataFormatterCaching(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+def test_with_run_command(self):
+"""
+Test that hardcoded summary formatter matches aren't improperly cached.
+"""
+self.build()
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, 'break here', lldb.SBFileSpec('a.c'))
+ 

[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, davide.
aprantl added a parent revision: D71233: Do not cache hardcoded formats in 
FormatManager.

This refactoring makes the lookup caching easier to reason about. This has no 
observable effect although it does slightly change what is being cached.

Before this patch a negative lookup in the LanguageCategory would be cached, 
but a positive wouldn't.
After this patch LanguageCategory lookups aren't cached, period.


https://reviews.llvm.org/D71289

Files:
  lldb/source/DataFormatters/FormatManager.cpp


Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@
 return retval_sp;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", 
__FUNCTION__);
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", 
__FUNCTION__);
+  for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
+if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
+  ImplSP retval_sp;
+  if (lang_category->Get(match_data, retval_sp))
+if (retval_sp) {
+  LLDB_LOGF(log, "[%s] Language search success. Returning.",
+__FUNCTION__);
+  return retval_sp;
+}
+}
+  }
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.",
+__FUNCTION__);
   return GetHardcoded(match_data);
 }
 
@@ -655,21 +670,6 @@
   }
 
   m_categories_map.Get(match_data, retval_sp);
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
-  __FUNCTION__);
-for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-  if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) 
{
-if (lang_category->Get(match_data, retval_sp))
-  break;
-  }
-}
-if (retval_sp) {
-  LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
-  return retval_sp;
-}
-  }
-
   if (match_data.GetTypeForCache() && (!retval_sp || 
!retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
   static_cast(retval_sp.get()),


Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@
 return retval_sp;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", __FUNCTION__);
+  for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
+if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
+  ImplSP retval_sp;
+  if (lang_category->Get(match_data, retval_sp))
+if (retval_sp) {
+  LLDB_LOGF(log, "[%s] Language search success. Returning.",
+__FUNCTION__);
+  return retval_sp;
+}
+}
+  }
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.",
+__FUNCTION__);
   return GetHardcoded(match_data);
 }
 
@@ -655,21 +670,6 @@
   }
 
   m_categories_map.Get(match_data, retval_sp);
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
-  __FUNCTION__);
-for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-  if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
-if (lang_category->Get(match_data, retval_sp))
-  break;
-  }
-}
-if (retval_sp) {
-  LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
-  return retval_sp;
-}
-  }
-
   if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
   static_cast(retval_sp.get()),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Actually, it's worse, LanguageCategory::Get does its own caching.


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

https://reviews.llvm.org/D71289



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


[Lldb-commits] [lldb] e81268d - [lldb/Reproducers] Support multiple GDB remotes

2019-12-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-10T11:16:52-08:00
New Revision: e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf

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

LOG: [lldb/Reproducers] Support multiple GDB remotes

When running the test suite with always capture on, a handful of tests
are failing because they have multiple targets and therefore multiple
GDB remote connections. The current reproducer infrastructure is capable
of dealing with that.

This patch reworks the GDB remote provider to support multiple GDB
remote connections, similar to how the reproducers support shadowing
multiple command interpreter inputs. The provider now keeps a list of
packet recorders which deal with a single GDB remote connection. During
replay we rely on the order of creation to match the number of packets
to the GDB remote connection.

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

Added: 
lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
lldb/test/Shell/Reproducer/TestMultipleTargets.test

Modified: 
lldb/include/lldb/Utility/GDBRemote.h
lldb/include/lldb/Utility/Reproducer.h
lldb/source/API/SBDebugger.cpp
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Utility/GDBRemote.cpp
lldb/source/Utility/Reproducer.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/GDBRemote.h 
b/lldb/include/lldb/Utility/GDBRemote.h
index b4adeb368524..21b2c8cd73cd 100644
--- a/lldb/include/lldb/Utility/GDBRemote.h
+++ b/lldb/include/lldb/Utility/GDBRemote.h
@@ -9,6 +9,8 @@
 #ifndef liblldb_GDBRemote_h_
 #define liblldb_GDBRemote_h_
 
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-public.h"
@@ -69,7 +71,6 @@ struct GDBRemotePacket {
 std::string data;
   };
 
-  void Serialize(llvm::raw_ostream &strm) const;
   void Dump(Stream &strm) const;
 
   BinaryData packet;
@@ -82,6 +83,46 @@ struct GDBRemotePacket {
   llvm::StringRef GetTypeStr() const;
 };
 
+namespace repro {
+class PacketRecorder : public AbstractRecorder {
+public:
+  PacketRecorder(const FileSpec &filename, std::error_code &ec)
+  : AbstractRecorder(filename, ec) {}
+
+  static llvm::Expected>
+  Create(const FileSpec &filename);
+
+  void Record(const GDBRemotePacket &packet);
+};
+
+class GDBRemoteProvider : public repro::Provider {
+public:
+  struct Info {
+static const char *name;
+static const char *file;
+  };
+
+  GDBRemoteProvider(const FileSpec &directory) : Provider(directory) {}
+
+  llvm::raw_ostream *GetHistoryStream();
+  PacketRecorder *GetNewPacketRecorder();
+
+  void SetCallback(std::function callback) {
+m_callback = std::move(callback);
+  }
+
+  void Keep() override;
+  void Discard() override;
+
+  static char ID;
+
+private:
+  std::function m_callback;
+  std::unique_ptr m_stream_up;
+  std::vector> m_packet_recorders;
+};
+
+} // namespace repro
 } // namespace lldb_private
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(lldb_private::GDBRemotePacket)

diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index ddb1f45a7219..0d23fe8571ff 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -153,24 +153,13 @@ class WorkingDirectoryProvider : public 
Provider {
   static char ID;
 };
 
-class DataRecorder {
-public:
-  DataRecorder(const FileSpec &filename, std::error_code &ec)
+class AbstractRecorder {
+protected:
+  AbstractRecorder(const FileSpec &filename, std::error_code &ec)
   : m_filename(filename.GetFilename().GetStringRef()),
 m_os(filename.GetPath(), ec, llvm::sys::fs::OF_Text), m_record(true) {}
 
-  static llvm::Expected>
-  Create(const FileSpec &filename);
-
-  template  void Record(const T &t, bool newline = false) {
-if (!m_record)
-  return;
-m_os << t;
-if (newline)
-  m_os << '\n';
-m_os.flush();
-  }
-
+public:
   const FileSpec &GetFilename() { return m_filename; }
 
   void Stop() {
@@ -180,10 +169,30 @@ class DataRecorder {
 
 private:
   FileSpec m_filename;
+
+protected:
   llvm::raw_fd_ostream m_os;
   bool m_record;
 };
 
+class DataRecorder : public AbstractRecorder {
+public:
+  DataRecorder(const FileSpec &filename, std::error_code &ec)
+  : AbstractRecorder(filename, ec) {}
+
+  static llvm::Expected>
+  Create(const FileSpec &fi

[Lldb-commits] [lldb] 53acf06 - Fix a -Wsign-compare error around wchar_t vs unsigned int.

2019-12-10 Thread Eric Christopher via lldb-commits

Author: Eric Christopher
Date: 2019-12-10T11:18:57-08:00
New Revision: 53acf0663f80e1be99bae28769c6b658fff0e097

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

LOG: Fix a -Wsign-compare error around wchar_t vs unsigned int.

Added: 


Modified: 
lldb/source/Host/common/Editline.cpp

Removed: 




diff  --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index b29c218f0369..5fd5a0cfc7fc 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1484,7 +1484,7 @@ bool Editline::CompleteCharacter(char ch, 
EditLineGetCharType &out) {
 switch (cvt.in(state, input.begin(), input.end(), from_next, &out, &out + 
1,
to_next)) {
 case std::codecvt_base::ok:
-  return out != WEOF;
+  return out != (int)WEOF;
 
 case std::codecvt_base::error:
 case std::codecvt_base::noconv:



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


[Lldb-commits] [lldb] d0789e6 - Assert launch success in run_to_breakpoint_do_run

2019-12-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-12-10T11:19:17-08:00
New Revision: d0789e6346e489cd84b37ec58964feb0db015de7

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

LOG: Assert launch success in run_to_breakpoint_do_run

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 05d0c9f9d3e9..9deaed5cf50d 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -778,6 +778,8 @@ def run_to_breakpoint_do_run(test, target, bkpt, 
launch_info = None,
 test.assertTrue(process,
 "Could not create a valid process for %s: 
%s"%(target.GetExecutable().GetFilename(),
 error.GetCString()))
+test.assertFalse(error.Fail(),
+ "Process launch failed: %s" % (error.GetCString()))
 
 # Frame #0 should be at our breakpoint.
 threads = get_threads_stopped_at_breakpoint(



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


[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

and again.. it passes in a ValueObject, so it shouldn't be caching.


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

https://reviews.llvm.org/D71289



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


[Lldb-commits] [PATCH] D71105: [lldb/Reproducers] Support multiple GDB remotes

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe81268d03e73: [lldb/Reproducers] Support multiple GDB 
remotes (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71105

Files:
  lldb/include/lldb/Utility/GDBRemote.h
  lldb/include/lldb/Utility/Reproducer.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectReproducer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/Reproducer.cpp
  lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
  lldb/test/Shell/Reproducer/TestMultipleTargets.test

Index: lldb/test/Shell/Reproducer/TestMultipleTargets.test
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/TestMultipleTargets.test
@@ -0,0 +1,23 @@
+# UNSUPPORTED: system-windows, system-freebsd
+
+# This tests the replaying with multiple targets.
+
+# RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
+
+# RUN: rm -rf %t.repro
+# RUN: %lldb -x -b --capture --capture-path %t.repro -o 'target create %t.out' -o 'target create %t.out' -s %S/Inputs/MultipleTargetsCapture.in  | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE
+# RUN: env FOO=BAR %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK --check-prefix REPLAY
+
+# CHECK: Process [[TARGET0:[0-9]+]] stopped
+# CHECK: stop reason = breakpoint 1.1
+# CHECK: simple.c:12:5
+# CHECK: Process [[TARGET1:[0-9]+]] stopped
+# CHECK: stop reason = breakpoint 1.1
+# CHECK: simple.c:16:5
+# CHECK: Process [[TARGET0]] resuming
+# CHECK: Process [[TARGET0]] exited
+# CHECK: Process [[TARGET1]] resuming
+# CHECK: Process [[TARGET1]] exited
+
+# CAPTURE: Reproducer is in capture mode.
+# CAPTURE: Reproducer written
Index: lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
===
--- /dev/null
+++ lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
@@ -0,0 +1,12 @@
+target select 0
+breakpoint set -f simple.c -l 12
+run
+target select 1
+breakpoint set -f simple.c -l 16
+run
+target select 0
+cont
+target select 1
+cont
+reproducer status
+reproducer generate
Index: lldb/source/Utility/Reproducer.cpp
===
--- lldb/source/Utility/Reproducer.cpp
+++ lldb/source/Utility/Reproducer.cpp
@@ -255,7 +255,7 @@
 DataRecorder *CommandProvider::GetNewDataRecorder() {
   std::size_t i = m_data_recorders.size() + 1;
   std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
-  llvm::Twine(i) + llvm::Twine(".txt"))
+  llvm::Twine(i) + llvm::Twine(".yaml"))
  .str();
   auto recorder_or_error =
   DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename));
@@ -304,53 +304,9 @@
   os << m_cwd << "\n";
 }
 
-llvm::raw_ostream *ProcessGDBRemoteProvider::GetHistoryStream() {
-  FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
-
-  std::error_code EC;
-  m_stream_up = std::make_unique(history_file.GetPath(), EC,
- sys::fs::OpenFlags::OF_Text);
-  return m_stream_up.get();
-}
-
-std::unique_ptr CommandLoader::Create(Loader *loader) {
-  if (!loader)
-return {};
-
-  FileSpec file = loader->GetFile();
-  if (!file)
-return {};
-
-  auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
-  if (auto err = error_or_file.getError())
-return {};
-
-  std::vector files;
-  llvm::yaml::Input yin((*error_or_file)->getBuffer());
-  yin >> files;
-
-  if (auto err = yin.error())
-return {};
-
-  for (auto &file : files) {
-FileSpec absolute_path =
-loader->GetRoot().CopyByAppendingPathComponent(file);
-file = absolute_path.GetPath();
-  }
-
-  return std::make_unique(std::move(files));
-}
-
-llvm::Optional CommandLoader::GetNextFile() {
-  if (m_index >= m_files.size())
-return {};
-  return m_files[m_index++];
-}
-
 void ProviderBase::anchor() {}
 char CommandProvider::ID = 0;
 char FileProvider::ID = 0;
-char ProcessGDBRemoteProvider::ID = 0;
 char ProviderBase::ID = 0;
 char VersionProvider::ID = 0;
 char WorkingDirectoryProvider::ID = 0;
@@ -358,8 +314,6 @@
 const char *CommandProvider::Info::name = "command-interpreter";
 const char *FileProvider::Info::file = "files.yaml";
 const char *FileProvider::Info::name = "files";
-const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml";
-const char *ProcessGDBRemoteProvider::Info::name = "gdb-rem

[Lldb-commits] [PATCH] D71280: [lldb/Host] Use Host/Config.h entries instead of a global define.

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59998b7b7f12: [lldb/Host] Use Host/Config.h entries instead 
of a global define. (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D71280?vs=233122&id=233159#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71280

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBHostOS.cpp
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/CommandObjectScript.cpp
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
  lldb/unittests/Editline/EditlineTest.cpp

Index: lldb/unittests/Editline/EditlineTest.cpp
===
--- lldb/unittests/Editline/EditlineTest.cpp
+++ lldb/unittests/Editline/EditlineTest.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_LIBEDIT
 
 #define EDITLINE_TEST_DUMP_OUTPUT 0
Index: lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -9,6 +9,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
 
+#include "lldb/Host/Config.h"
+
 // Python.h needs to be included before any system headers in order to avoid
 // redefinition of macros
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -6,11 +6,9 @@
 //
 //===--===//
 
-#ifdef LLDB_DISABLE_PYTHON
+#include "lldb/Host/Config.h"
 
-// Python is disabled in this build
-
-#else
+#ifndef LLDB_DISABLE_PYTHON
 
 #include "lldb-python.h"
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -9,6 +9,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
 
+#include "lldb/Host/Config.h"
+
 #ifdef LLDB_DISABLE_PYTHON
 
 // Python is disabled in this build
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -6,11 +6,9 @@
 //
 //===--===//
 
-#ifdef LLDB_DISABLE_PYTHON
+#include "lldb/Host/Config.h"
 
-// Python is disabled in this build
-
-#else
+#ifndef LLDB_DISABLE_PYTHON
 
 // LLDB Python header must be included first
 #include "lldb-python.h"
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -48,6 +48,8 @@
 #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_PYTHONDATAOBJECTS_H
 
+#include "lldb/Host/Config.h"
+
 #ifndef LLDB_DISABLE_PYTHON
 
 // LLDB Python header must be included first
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInter

lldb-commits@lists.llvm.org

2019-12-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71268



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


[Lldb-commits] [PATCH] D69820: [Symbol] Add TypeSystem::GetClassName

2019-12-10 Thread Alex Langford via Phabricator via lldb-commits
xiaobai updated this revision to Diff 233163.
xiaobai added a comment.

Add fixme


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69820

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -3539,6 +3539,13 @@
   return ClangASTContextSupportsLanguage(language);
 }
 
+Optional
+ClangASTContext::GetClassName(const CompilerType &compiler_type) {
+  if (!ClangUtil::IsClangType(compiler_type))
+return llvm::None;
+  return GetCXXClassName(compiler_type);
+}
+
 Optional
 ClangASTContext::GetCXXClassName(const CompilerType &type) {
   if (!type)
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -25,7 +25,6 @@
 #include "lldb/DataFormatters/TypeValidator.h"
 #include "lldb/DataFormatters/ValueObjectPrinter.h"
 #include "lldb/Expression/ExpressionVariable.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/Declaration.h"
@@ -2033,20 +2032,34 @@
 }
 
 bool ValueObject::GetBaseClassPath(Stream &s) {
-  if (IsBaseClass()) {
-bool parent_had_base_class =
-GetParent() && GetParent()->GetBaseClassPath(s);
-CompilerType compiler_type = GetCompilerType();
-llvm::Optional cxx_class_name =
-ClangASTContext::GetCXXClassName(compiler_type);
-if (cxx_class_name) {
-  if (parent_had_base_class)
-s.PutCString("::");
-  s.PutCString(cxx_class_name.getValue());
-}
-return parent_had_base_class || cxx_class_name;
+  if (!IsBaseClass())
+return false;
+
+  TargetSP target_sp = GetTargetSP();
+  if (!target_sp)
+return false;
+
+  auto *type_system = GetCompilerType().GetTypeSystem();
+  if (!type_system) {
+LLDB_LOG(
+lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS),
+"Unable to get TypeSystem in order to get class name in "
+"ValueObject::GetBaseClassPath");
+return false;
   }
-  return false;
+
+  llvm::Optional class_name =
+  type_system->GetClassName(GetCompilerType());
+  bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath(s);
+  if (class_name) {
+if (parent_had_base_class)
+  // FIXME: This is still specific to C++. We should implement something
+  // like `GetClassSeparator` in the Language plugins to figure out what to
+  // use here.
+  s.PutCString("::");
+s.PutCString(class_name.getValue());
+  }
+  return parent_had_base_class || class_name;
 }
 
 ValueObject *ValueObject::GetNonBaseClassParent() {
Index: lldb/include/lldb/Symbol/TypeSystem.h
===
--- lldb/include/lldb/Symbol/TypeSystem.h
+++ lldb/include/lldb/Symbol/TypeSystem.h
@@ -181,6 +181,9 @@
 
   // Accessors
 
+  virtual llvm::Optional
+  GetClassName(const CompilerType &compiler_type) = 0;
+
   virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0;
 
   virtual uint32_t
Index: lldb/include/lldb/Symbol/ClangASTContext.h
===
--- lldb/include/lldb/Symbol/ClangASTContext.h
+++ lldb/include/lldb/Symbol/ClangASTContext.h
@@ -585,6 +585,9 @@
 
   // Accessors
 
+  llvm::Optional
+  GetClassName(const CompilerType &compiler_type) override;
+
   ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
 
   uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

This seems reasonable.


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

https://reviews.llvm.org/D71289



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


Re: [Lldb-commits] [lldb] e81268d - [lldb/Reproducers] Support multiple GDB remotes

2019-12-10 Thread Eric Christopher via lldb-commits
Hi Jonas,

This appears to be causing crashes in a release asserts build:

 #3 0x7efe57b613a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x123a0)
 #4 0x7efe54178d00 llvm::raw_ostream::operator<<(llvm::StringRef)
sources/llvm-project/llvm/include/llvm/Support/raw_ostream.h:190:7
 #5 0x7efe54178d00 llvm::yaml::Output::output(llvm::StringRef)
sources/llvm-project/llvm/lib/Support/YAMLTraits.cpp:751:7
 #6 0x7efe54178d00
llvm::yaml::Output::outputUpToEndOfLine(llvm::StringRef)
sources/llvm-project/llvm/lib/Support/YAMLTraits.cpp:755:3
 #7 0x7efe54178d00 llvm::yaml::Output::beginDocuments()
sources/llvm-project/llvm/lib/Support/YAMLTraits.cpp:537:3
 #8 0x7efe53fc5d7e
std::enable_if::value, llvm::yaml::Output&>::type
llvm::yaml::operator<<(llvm::yaml::Output&,
lldb_private::GDBRemotePacket&)
sources/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:1796:13
 #9 0x7efe53fc5d7e
lldb_private::GDBRemotePacket::Serialize(llvm::raw_ostream&) const
sources/llvm-project/lldb/source/Utility/GDBRemote.cpp:50:8
...

want to revert and see what's going on? Happy to help if you can't
duplicate?

Thanks!

-eric

On Tue, Dec 10, 2019 at 11:17 AM Jonas Devlieghere via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

>
> Author: Jonas Devlieghere
> Date: 2019-12-10T11:16:52-08:00
> New Revision: e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf
>
> URL:
> https://github.com/llvm/llvm-project/commit/e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf
> DIFF:
> https://github.com/llvm/llvm-project/commit/e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf.diff
>
> LOG: [lldb/Reproducers] Support multiple GDB remotes
>
> When running the test suite with always capture on, a handful of tests
> are failing because they have multiple targets and therefore multiple
> GDB remote connections. The current reproducer infrastructure is capable
> of dealing with that.
>
> This patch reworks the GDB remote provider to support multiple GDB
> remote connections, similar to how the reproducers support shadowing
> multiple command interpreter inputs. The provider now keeps a list of
> packet recorders which deal with a single GDB remote connection. During
> replay we rely on the order of creation to match the number of packets
> to the GDB remote connection.
>
> Differential revision: https://reviews.llvm.org/D71105
>
> Added:
> lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
> lldb/test/Shell/Reproducer/TestMultipleTargets.test
>
> Modified:
> lldb/include/lldb/Utility/GDBRemote.h
> lldb/include/lldb/Utility/Reproducer.h
> lldb/source/API/SBDebugger.cpp
> lldb/source/Commands/CommandObjectReproducer.cpp
> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
>
> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
> lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> lldb/source/Utility/GDBRemote.cpp
> lldb/source/Utility/Reproducer.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/lldb/include/lldb/Utility/GDBRemote.h
> b/lldb/include/lldb/Utility/GDBRemote.h
> index b4adeb368524..21b2c8cd73cd 100644
> --- a/lldb/include/lldb/Utility/GDBRemote.h
> +++ b/lldb/include/lldb/Utility/GDBRemote.h
> @@ -9,6 +9,8 @@
>  #ifndef liblldb_GDBRemote_h_
>  #define liblldb_GDBRemote_h_
>
> +#include "lldb/Utility/FileSpec.h"
> +#include "lldb/Utility/Reproducer.h"
>  #include "lldb/Utility/StreamString.h"
>  #include "lldb/lldb-enumerations.h"
>  #include "lldb/lldb-public.h"
> @@ -69,7 +71,6 @@ struct GDBRemotePacket {
>  std::string data;
>};
>
> -  void Serialize(llvm::raw_ostream &strm) const;
>void Dump(Stream &strm) const;
>
>BinaryData packet;
> @@ -82,6 +83,46 @@ struct GDBRemotePacket {
>llvm::StringRef GetTypeStr() const;
>  };
>
> +namespace repro {
> +class PacketRecorder : public AbstractRecorder {
> +public:
> +  PacketRecorder(const FileSpec &filename, std::error_code &ec)
> +  : AbstractRecorder(filename, ec) {}
> +
> +  static llvm::Expected>
> +  Create(const FileSpec &filename);
> +
> +  void Record(const GDBRemotePacket &packet);
> +};
> +
> +class GDBRemoteProvider : public repro::Provider {
> +public:
> +  struct Info {
> +static const char *name;
> +static const char *file;
> +  };
> +
> +  GDBRemoteProvider(const FileSpec &directory) : Provider(directory) {}
> +
> +  llvm::raw_ostream *GetHistoryStream();
> +  PacketRecorder *GetNewPacketRecorder();
> +
> +  void SetCallback(std::function callback) {
> +m_callback = std::move(callback);
> +  }
> +
> +  void Keep() override;
> +  void Discard() override;
> +
> +  static char ID;
> +
> +private:
> +  std::function m_callback;
> +  std::unique_ptr m_stream_up;
> +  std::vector> m_packet_recorders;
> +};
> +
> +} // namespace repro
>  }

[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

@davide said he's working on a patch that turns the ValueObject parameter into 
a Language. With that in place the caching it does is sound again.


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

https://reviews.llvm.org/D71289



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


[Lldb-commits] [lldb] c9e0b35 - Temporarily revert [lldb] e81268d - [lldb/Reproducers] Support multiple GDB remotes

2019-12-10 Thread Eric Christopher via lldb-commits

Author: Eric Christopher
Date: 2019-12-10T12:29:46-08:00
New Revision: c9e0b354e2749ce7ab553974692cb35c8651a869

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

LOG: Temporarily revert [lldb] e81268d - [lldb/Reproducers] Support multiple 
GDB remotes

This was causing a crash in opt+assert builds on linux and a follow-up
message was posted.

This reverts commit e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf

Added: 


Modified: 
lldb/include/lldb/Utility/GDBRemote.h
lldb/include/lldb/Utility/Reproducer.h
lldb/source/API/SBDebugger.cpp
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Utility/GDBRemote.cpp
lldb/source/Utility/Reproducer.cpp

Removed: 
lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
lldb/test/Shell/Reproducer/TestMultipleTargets.test



diff  --git a/lldb/include/lldb/Utility/GDBRemote.h 
b/lldb/include/lldb/Utility/GDBRemote.h
index 21b2c8cd73cd..b4adeb368524 100644
--- a/lldb/include/lldb/Utility/GDBRemote.h
+++ b/lldb/include/lldb/Utility/GDBRemote.h
@@ -9,8 +9,6 @@
 #ifndef liblldb_GDBRemote_h_
 #define liblldb_GDBRemote_h_
 
-#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-public.h"
@@ -71,6 +69,7 @@ struct GDBRemotePacket {
 std::string data;
   };
 
+  void Serialize(llvm::raw_ostream &strm) const;
   void Dump(Stream &strm) const;
 
   BinaryData packet;
@@ -83,46 +82,6 @@ struct GDBRemotePacket {
   llvm::StringRef GetTypeStr() const;
 };
 
-namespace repro {
-class PacketRecorder : public AbstractRecorder {
-public:
-  PacketRecorder(const FileSpec &filename, std::error_code &ec)
-  : AbstractRecorder(filename, ec) {}
-
-  static llvm::Expected>
-  Create(const FileSpec &filename);
-
-  void Record(const GDBRemotePacket &packet);
-};
-
-class GDBRemoteProvider : public repro::Provider {
-public:
-  struct Info {
-static const char *name;
-static const char *file;
-  };
-
-  GDBRemoteProvider(const FileSpec &directory) : Provider(directory) {}
-
-  llvm::raw_ostream *GetHistoryStream();
-  PacketRecorder *GetNewPacketRecorder();
-
-  void SetCallback(std::function callback) {
-m_callback = std::move(callback);
-  }
-
-  void Keep() override;
-  void Discard() override;
-
-  static char ID;
-
-private:
-  std::function m_callback;
-  std::unique_ptr m_stream_up;
-  std::vector> m_packet_recorders;
-};
-
-} // namespace repro
 } // namespace lldb_private
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(lldb_private::GDBRemotePacket)

diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index 0d23fe8571ff..ddb1f45a7219 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -153,32 +153,11 @@ class WorkingDirectoryProvider : public 
Provider {
   static char ID;
 };
 
-class AbstractRecorder {
-protected:
-  AbstractRecorder(const FileSpec &filename, std::error_code &ec)
-  : m_filename(filename.GetFilename().GetStringRef()),
-m_os(filename.GetPath(), ec, llvm::sys::fs::OF_Text), m_record(true) {}
-
-public:
-  const FileSpec &GetFilename() { return m_filename; }
-
-  void Stop() {
-assert(m_record);
-m_record = false;
-  }
-
-private:
-  FileSpec m_filename;
-
-protected:
-  llvm::raw_fd_ostream m_os;
-  bool m_record;
-};
-
-class DataRecorder : public AbstractRecorder {
+class DataRecorder {
 public:
   DataRecorder(const FileSpec &filename, std::error_code &ec)
-  : AbstractRecorder(filename, ec) {}
+  : m_filename(filename.GetFilename().GetStringRef()),
+m_os(filename.GetPath(), ec, llvm::sys::fs::OF_Text), m_record(true) {}
 
   static llvm::Expected>
   Create(const FileSpec &filename);
@@ -191,6 +170,18 @@ class DataRecorder : public AbstractRecorder {
   m_os << '\n';
 m_os.flush();
   }
+
+  const FileSpec &GetFilename() { return m_filename; }
+
+  void Stop() {
+assert(m_record);
+m_record = false;
+  }
+
+private:
+  FileSpec m_filename;
+  llvm::raw_fd_ostream m_os;
+  bool m_record;
 };
 
 class CommandProvider : public Provider {
@@ -213,6 +204,32 @@ class CommandProvider : public Provider {
   std::vector> m_data_recorders;
 };
 
+class ProcessGDBRemoteProvider
+: public repro::Provider {
+public:
+  struct Info {
+static const char *name;
+static const char *file;
+  };
+
+  P

Re: [Lldb-commits] [lldb] e81268d - [lldb/Reproducers] Support multiple GDB remotes

2019-12-10 Thread Eric Christopher via lldb-commits
For now I've gone ahead and reverted thusly:

echristo@athyra ~/r/llvm-project> git push
To github.com:llvm/llvm-project.git
   a2602bdd731..c9e0b354e27  master -> master

Sorry for the very quick turnaround.

-eric

On Tue, Dec 10, 2019 at 12:21 PM Eric Christopher 
wrote:

> Hi Jonas,
>
> This appears to be causing crashes in a release asserts build:
>
>  #3 0x7efe57b613a0 __restore_rt
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x123a0)
>  #4 0x7efe54178d00 llvm::raw_ostream::operator<<(llvm::StringRef)
> sources/llvm-project/llvm/include/llvm/Support/raw_ostream.h:190:7
>  #5 0x7efe54178d00 llvm::yaml::Output::output(llvm::StringRef)
> sources/llvm-project/llvm/lib/Support/YAMLTraits.cpp:751:7
>  #6 0x7efe54178d00
> llvm::yaml::Output::outputUpToEndOfLine(llvm::StringRef)
> sources/llvm-project/llvm/lib/Support/YAMLTraits.cpp:755:3
>  #7 0x7efe54178d00 llvm::yaml::Output::beginDocuments()
> sources/llvm-project/llvm/lib/Support/YAMLTraits.cpp:537:3
>  #8 0x7efe53fc5d7e
> std::enable_if llvm::yaml::EmptyContext>::value, llvm::yaml::Output&>::type
> llvm::yaml::operator<<(llvm::yaml::Output&,
> lldb_private::GDBRemotePacket&)
> sources/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:1796:13
>  #9 0x7efe53fc5d7e
> lldb_private::GDBRemotePacket::Serialize(llvm::raw_ostream&) const
> sources/llvm-project/lldb/source/Utility/GDBRemote.cpp:50:8
> ...
>
> want to revert and see what's going on? Happy to help if you can't
> duplicate?
>
> Thanks!
>
> -eric
>
> On Tue, Dec 10, 2019 at 11:17 AM Jonas Devlieghere via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>>
>> Author: Jonas Devlieghere
>> Date: 2019-12-10T11:16:52-08:00
>> New Revision: e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/e81268d03e73aef4f9c7bd8ece8ad02f5b017dcf.diff
>>
>> LOG: [lldb/Reproducers] Support multiple GDB remotes
>>
>> When running the test suite with always capture on, a handful of tests
>> are failing because they have multiple targets and therefore multiple
>> GDB remote connections. The current reproducer infrastructure is capable
>> of dealing with that.
>>
>> This patch reworks the GDB remote provider to support multiple GDB
>> remote connections, similar to how the reproducers support shadowing
>> multiple command interpreter inputs. The provider now keeps a list of
>> packet recorders which deal with a single GDB remote connection. During
>> replay we rely on the order of creation to match the number of packets
>> to the GDB remote connection.
>>
>> Differential revision: https://reviews.llvm.org/D71105
>>
>> Added:
>> lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
>> lldb/test/Shell/Reproducer/TestMultipleTargets.test
>>
>> Modified:
>> lldb/include/lldb/Utility/GDBRemote.h
>> lldb/include/lldb/Utility/Reproducer.h
>> lldb/source/API/SBDebugger.cpp
>> lldb/source/Commands/CommandObjectReproducer.cpp
>> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
>> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
>>
>> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
>> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
>> lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
>> lldb/source/Utility/GDBRemote.cpp
>> lldb/source/Utility/Reproducer.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/lldb/include/lldb/Utility/GDBRemote.h
>> b/lldb/include/lldb/Utility/GDBRemote.h
>> index b4adeb368524..21b2c8cd73cd 100644
>> --- a/lldb/include/lldb/Utility/GDBRemote.h
>> +++ b/lldb/include/lldb/Utility/GDBRemote.h
>> @@ -9,6 +9,8 @@
>>  #ifndef liblldb_GDBRemote_h_
>>  #define liblldb_GDBRemote_h_
>>
>> +#include "lldb/Utility/FileSpec.h"
>> +#include "lldb/Utility/Reproducer.h"
>>  #include "lldb/Utility/StreamString.h"
>>  #include "lldb/lldb-enumerations.h"
>>  #include "lldb/lldb-public.h"
>> @@ -69,7 +71,6 @@ struct GDBRemotePacket {
>>  std::string data;
>>};
>>
>> -  void Serialize(llvm::raw_ostream &strm) const;
>>void Dump(Stream &strm) const;
>>
>>BinaryData packet;
>> @@ -82,6 +83,46 @@ struct GDBRemotePacket {
>>llvm::StringRef GetTypeStr() const;
>>  };
>>
>> +namespace repro {
>> +class PacketRecorder : public AbstractRecorder {
>> +public:
>> +  PacketRecorder(const FileSpec &filename, std::error_code &ec)
>> +  : AbstractRecorder(filename, ec) {}
>> +
>> +  static llvm::Expected>
>> +  Create(const FileSpec &filename);
>> +
>> +  void Record(const GDBRemotePacket &packet);
>> +};
>> +
>> +class GDBRemoteProvider : public repro::Provider {
>> +public:
>> +  struct Info {
>> +static const char *name;
>> +static const char *file;
>> +  };
>> +
>> +  GDBRemoteProvider(const FileSpec &directory) 

[Lldb-commits] [lldb] 7ec933e - [lldb] Add #include to appease the modules build

2019-12-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-12-10T12:37:26-08:00
New Revision: 7ec933e50162e2ddc6204f0f1708b75309a9555a

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

LOG: [lldb] Add #include to appease the modules build

This #include appears to be completely unnecessary, but it does fix the
following build failure:

http://green.lab.llvm.org/green/job/lldb-cmake/4565/consoleText

FAILED: tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o
/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/clang++  
-DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLIBXML2_DEFINED -DLLDB_CONFIGURATION_RELEASE 
-DLLDB_USE_OS_LOG -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/lldb/source/Host 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host 
-Itools/lldb/source 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/include 
-Itools/lldb/include -Iinclude 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include 
-I/usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/../clang/include
 -Itools/lldb/../clang/include -I/usr/local/include 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/. 
-isystem 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
 -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -fmodules 
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/module.cache
 -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color 
-Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-deprecated-register -Wno-vla-extension -O3  -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
   -UNDEBUG  -fno-exceptions -fno-rtti -std=c++14 -MD -MT 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o -MF 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o.d -o 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o -c 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp:211:7:
 error: use of undeclared identifier 'ppoll'
  if (ppoll(read_fds.data(), read_fds.size(), nullptr, &sigmask) == -1 &&
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp:336:25:
 error: use of undeclared identifier 'HAVE_SYS_EVENT_H'
  ret = pthread_sigmask(HAVE_SYS_EVENT_H ? SIG_UNBLOCK : SIG_BLOCK,
^
2 errors generated.

Added: 


Modified: 
lldb/source/Host/common/MainLoop.cpp

Removed: 




diff  --git a/lldb/source/Host/common/MainLoop.cpp 
b/lldb/source/Host/common/MainLoop.cpp
index 6f774451c8a4..240320f83242 100644
--- a/lldb/source/Host/common/MainLoop.cpp
+++ b/lldb/source/Host/common/MainLoop.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "llvm/Config/llvm-config.h"
+#include "lldb/Host/Config.h"
 
 #include "lldb/Host/MainLoop.h"
 #include "lldb/Host/PosixApi.h"



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


[Lldb-commits] [PATCH] D71296: Replace redundant code in LanguageCategory with templates (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, davide.

This is a cleanup similar to https://reviews.llvm.org/D71231.


https://reviews.llvm.org/D71296

Files:
  lldb/include/lldb/DataFormatters/LanguageCategory.h
  lldb/source/DataFormatters/LanguageCategory.cpp

Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -34,8 +34,9 @@
   Enable();
 }
 
+template
 bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeFormatImplSP &format_sp) {
+   ImplSP &retval_sp) {
   if (!m_category_sp)
 return false;
 
@@ -43,168 +44,90 @@
 return false;
 
   if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
+if (m_format_cache.Get(match_data.GetTypeForCache(), retval_sp))
+  return (bool)retval_sp;
   }
 
   ValueObject &valobj(match_data.GetValueObject());
   bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+  m_category_sp->Get(valobj, match_data.GetMatchesVector(), retval_sp);
   if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
+  (!retval_sp || !retval_sp->NonCacheable())) {
+m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
   }
   return result;
 }
 
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeSummaryImplSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
-}
-
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::SyntheticChildrenSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
+/// Explicit instantiations for the four types.
+/// \{
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+ lldb::TypeValidatorImplSP &);
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+  lldb::TypeFormatImplSP &);
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+   lldb::TypeSummaryImplSP &);
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+ lldb::SyntheticChildrenSP &);
+/// \}
+
+template <>
+auto &LanguageCategory::GetHardcodedFinder() {
+  return m_hardcoded_formats;
 }
 
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeValidatorImplSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
+template <>
+auto &LanguageCategory::GetHardcodedFinder() {
+  return m_hardcoded_summaries;
 }
 
-bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
-FormattersMatchData &match_data,
-lldb::TypeFormatImplSP &format_sp) {
-  if (!IsEnabled())
-return false;
-
-  ValueObject &valobj(match_data.GetValueObject());
-  lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
-
-  for (auto &candidate : m_hardcoded_formats) {
-if ((format_sp = candidate(valobj, use_dyn

[Lldb-commits] [PATCH] D71297: Remove unsound caching in LanguageCategory

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, davide.
aprantl added a parent revision: D71296: Replace redundant code in 
LanguageCategory with templates (NFC).

Analogous to https://reviews.llvm.org/D71233 it is not safe to cache something 
that depends on the actual ValueObject in a cache then keys only off the type 
name.


https://reviews.llvm.org/D71297

Files:
  lldb/source/DataFormatters/LanguageCategory.cpp


Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -110,10 +110,6 @@
   break;
 }
   }
-  if (match_data.GetTypeForCache() &&
-  (!retval_sp || !retval_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
-  }
   return (bool)retval_sp;
 }
 


Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -110,10 +110,6 @@
   break;
 }
   }
-  if (match_data.GetTypeForCache() &&
-  (!retval_sp || !retval_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
-  }
   return (bool)retval_sp;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71299: [FormatManager] Add a unittest for GetCandidateLanguages()

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: teemperor, JDevlieghere, aprantl, jingham.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.
JDevlieghere accepted this revision.
This revision is now accepted and ready to land.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71299

Files:
  lldb/unittests/CMakeLists.txt
  lldb/unittests/DataFormatter/CMakeLists.txt
  lldb/unittests/DataFormatter/FormatManagerTests.cpp


Index: lldb/unittests/DataFormatter/FormatManagerTests.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -0,0 +1,49 @@
+//===-- FormatManagerTests.cpp --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Mangled.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(FormatManagerTests, CompatibleLangs) {
+  std::vector candidates = {eLanguageTypeC_plus_plus,
+  eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC89), 
candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC99), 
candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC11), 
candidates);
+
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_03),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_11),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_14),
+candidates);
+
+  candidates = {eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeObjC),
+candidates);
+}
Index: lldb/unittests/DataFormatter/CMakeLists.txt
===
--- /dev/null
+++ lldb/unittests/DataFormatter/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_lldb_unittest(LLDBFormatterTests
+  FormatManagerTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbInterpreter
+lldbSymbol
+lldbTarget
+lldbUtility
+
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -61,6 +61,7 @@
 add_subdirectory(TestingSupport)
 add_subdirectory(Breakpoint)
 add_subdirectory(Core)
+add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
 add_subdirectory(Editline)
 add_subdirectory(Expression)


Index: lldb/unittests/DataFormatter/FormatManagerTests.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -0,0 +1,49 @@
+//===-- FormatManagerTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Mangled.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(FormatManagerTests, CompatibleLangs) {
+  std::vector candidates = {eLanguageTypeC_plus_plus,
+  eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC89), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC99), candidates);
+  EXPECT_EQ(Fo

[Lldb-commits] [lldb] e8d955f - [FormatManager] Add a unittest for GetCandidateLanguages()

2019-12-10 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2019-12-10T13:42:59-08:00
New Revision: e8d955f29de7ee4b50d889c418b4efb18add0653

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

LOG: [FormatManager] Add a unittest for GetCandidateLanguages()

Reviewers: teemperor, JDevlieghere, aprantl, jingham

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 
lldb/unittests/DataFormatter/CMakeLists.txt
lldb/unittests/DataFormatter/FormatManagerTests.cpp

Modified: 
lldb/unittests/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index 22c684f4fce3..bf117030dd4b 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -61,6 +61,7 @@ endfunction()
 add_subdirectory(TestingSupport)
 add_subdirectory(Breakpoint)
 add_subdirectory(Core)
+add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
 add_subdirectory(Editline)
 add_subdirectory(Expression)

diff  --git a/lldb/unittests/DataFormatter/CMakeLists.txt 
b/lldb/unittests/DataFormatter/CMakeLists.txt
new file mode 100644
index ..fc60bff05879
--- /dev/null
+++ b/lldb/unittests/DataFormatter/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_lldb_unittest(LLDBFormatterTests
+  FormatManagerTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbInterpreter
+lldbSymbol
+lldbTarget
+lldbUtility
+
+  LINK_COMPONENTS
+Support
+  )

diff  --git a/lldb/unittests/DataFormatter/FormatManagerTests.cpp 
b/lldb/unittests/DataFormatter/FormatManagerTests.cpp
new file mode 100644
index ..d57454b3f9d1
--- /dev/null
+++ b/lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -0,0 +1,49 @@
+//===-- FormatManagerTests.cpp --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Mangled.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(FormatManagerTests, CompatibleLangs) {
+  std::vector candidates = {eLanguageTypeC_plus_plus,
+  eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC89), 
candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC99), 
candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC11), 
candidates);
+
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_03),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_11),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_14),
+candidates);
+
+  candidates = {eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeObjC),
+candidates);
+}



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


[Lldb-commits] [PATCH] D71299: [FormatManager] Add a unittest for GetCandidateLanguages()

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8d955f29de7: [FormatManager] Add a unittest for 
GetCandidateLanguages() (authored by davide).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71299

Files:
  lldb/unittests/CMakeLists.txt
  lldb/unittests/DataFormatter/CMakeLists.txt
  lldb/unittests/DataFormatter/FormatManagerTests.cpp


Index: lldb/unittests/DataFormatter/FormatManagerTests.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -0,0 +1,49 @@
+//===-- FormatManagerTests.cpp --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Mangled.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(FormatManagerTests, CompatibleLangs) {
+  std::vector candidates = {eLanguageTypeC_plus_plus,
+  eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC89), 
candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC99), 
candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC11), 
candidates);
+
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_03),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_11),
+candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_14),
+candidates);
+
+  candidates = {eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeObjC),
+candidates);
+}
Index: lldb/unittests/DataFormatter/CMakeLists.txt
===
--- /dev/null
+++ lldb/unittests/DataFormatter/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_lldb_unittest(LLDBFormatterTests
+  FormatManagerTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbInterpreter
+lldbSymbol
+lldbTarget
+lldbUtility
+
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -61,6 +61,7 @@
 add_subdirectory(TestingSupport)
 add_subdirectory(Breakpoint)
 add_subdirectory(Core)
+add_subdirectory(DataFormatter)
 add_subdirectory(Disassembler)
 add_subdirectory(Editline)
 add_subdirectory(Expression)


Index: lldb/unittests/DataFormatter/FormatManagerTests.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -0,0 +1,49 @@
+//===-- FormatManagerTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Mangled.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/SymbolContext.h"
+
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Testing/Support/Error.h"
+
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(FormatManagerTests, CompatibleLangs) {
+  std::vector candidates = {eLanguageTypeC_plus_plus,
+  eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC89), candidates);
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC99), candidates);
+  EXPEC

[Lldb-commits] [PATCH] D71237: [FormatEntity] Add mangled function name support

2019-12-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 233189.
mib marked 4 inline comments as done.
mib added a comment.

Remove unnecessary Language FunctionNameRepresention changes.
Rewrote test file. Refactored frame-format FormatEntity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71237

Files:
  lldb/docs/use/formatting.rst
  lldb/include/lldb/Core/FormatEntity.h
  lldb/source/Core/FormatEntity.cpp
  lldb/test/Shell/Settings/Inputs/main.cpp
  lldb/test/Shell/Settings/TestFrameFormatMangling.test

Index: lldb/test/Shell/Settings/TestFrameFormatMangling.test
===
--- /dev/null
+++ lldb/test/Shell/Settings/TestFrameFormatMangling.test
@@ -0,0 +1,12 @@
+# UNSUPPORTED: system-windows
+# RUN: %clangxx_host -g -O0 %S/Inputs/main.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck %s
+br set -p "Set break"
+run
+frame info
+# CHECK: frame #0: {{.*}}Increment::GetValue()
+set set frame-format "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{\`${function.mangled-name}}\n"
+frame info
+# CHECK: frame #0: {{.*}}_ZN9Increment8GetValueEv
+c
+q
Index: lldb/test/Shell/Settings/Inputs/main.cpp
===
--- /dev/null
+++ lldb/test/Shell/Settings/Inputs/main.cpp
@@ -0,0 +1,29 @@
+//===-- main.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+class Increment {
+public:
+  Increment(int value) { Increment::value += value; }
+
+  static const int GetValue();
+
+private:
+  static int value;
+};
+
+int Increment::value = 40;
+
+const int Increment::GetValue() {
+  return value; // Set break point at this line.
+}
+
+int main() {
+  Increment i(2);
+  const int new_val = Increment::GetValue();
+  return new_val;
+}
Index: lldb/source/Core/FormatEntity.cpp
===
--- lldb/source/Core/FormatEntity.cpp
+++ lldb/source/Core/FormatEntity.cpp
@@ -125,6 +125,7 @@
 ENTRY("name", FunctionName),
 ENTRY("name-without-args", FunctionNameNoArgs),
 ENTRY("name-with-args", FunctionNameWithArgs),
+ENTRY("mangled-name", FunctionMangledName),
 ENTRY("addr-offset", FunctionAddrOffset),
 ENTRY("concrete-only-addr-offset-no-padding", FunctionAddrOffsetConcrete),
 ENTRY("line-offset", FunctionLineOffset),
@@ -351,6 +352,7 @@
 ENUM_TO_CSTR(FunctionName);
 ENUM_TO_CSTR(FunctionNameWithArgs);
 ENUM_TO_CSTR(FunctionNameNoArgs);
+ENUM_TO_CSTR(FunctionMangledName);
 ENUM_TO_CSTR(FunctionAddrOffset);
 ENUM_TO_CSTR(FunctionAddrOffsetConcrete);
 ENUM_TO_CSTR(FunctionLineOffset);
@@ -1745,6 +1747,37 @@
   }
 return false;
 
+  case Entry::Type::FunctionMangledName: {
+const char *name = nullptr;
+if (sc->symbol)
+  name = sc->symbol->GetMangled()
+ .GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
+ .AsCString();
+else if (sc->function)
+  name = sc->function->GetMangled()
+ .GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
+ .AsCString();
+
+if (!name)
+  return false;
+else {
+  s.PutCString(name);
+
+  if (sc->block) {
+Block *inline_block = sc->block->GetContainingInlinedBlock();
+if (inline_block) {
+  const InlineFunctionInfo *inline_info =
+  sc->block->GetInlinedFunctionInfo();
+  if (inline_info) {
+s.PutCString(" [inlined] ");
+inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
+  }
+}
+  }
+  return true;
+}
+  }
+
   case Entry::Type::FunctionAddrOffset:
 if (addr) {
   if (DumpAddressOffsetFromFunction(s, sc, exe_ctx, *addr, false, false,
Index: lldb/include/lldb/Core/FormatEntity.h
===
--- lldb/include/lldb/Core/FormatEntity.h
+++ lldb/include/lldb/Core/FormatEntity.h
@@ -85,6 +85,7 @@
   FunctionName,
   FunctionNameWithArgs,
   FunctionNameNoArgs,
+  FunctionMangledName,
   FunctionAddrOffset,
   FunctionAddrOffsetConcrete,
   FunctionLineOffset,
Index: lldb/docs/use/formatting.rst
===
--- lldb/docs/use/formatting.rst
+++ lldb/docs/use/formatting.rst
@@ -92,6 +92,8 @@
 +---+--

[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2019-12-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D71150#1774575 , @labath wrote:

> Hmm... given the lua thread on lldb-dev, maybe we should slow down here, and 
> consider the potential relationship of these tests and the hypothetical lua 
> tests that come to be. One of the reasons the current tests are so deeply 
> nested was that Zach was trying to future-proof ourselves for addition of new 
> scripting languages (at that time, Java was being floated around, but the 
> idea never took off the ground). I'd hate to move these tests now, only to 
> have to move them around again in a couple of weeks to make room for lua...


I don't *think* this patch is affected by that discussion, except for the 
speculative comment to update `lldb_test_root = os.path.join(lldb_root, "test", 
"API", "test")` with the next patch. I'll followup with the next patch 
discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71150



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


[Lldb-commits] [PATCH] D71305: [TypeCategory] IsApplicable gets a LanguageType, not a ValueObject.

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: aprantl, teemperor.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71305

Files:
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/source/DataFormatters/TypeCategory.cpp


Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -60,11 +60,10 @@
   }
 }
 
-bool TypeCategoryImpl::IsApplicable(ValueObject &valobj) {
-  lldb::LanguageType valobj_lang = valobj.GetObjectRuntimeLanguage();
+bool TypeCategoryImpl::IsApplicable(lldb::LanguageType lang) {
   for (size_t idx = 0; idx < GetNumLanguages(); idx++) {
 const lldb::LanguageType category_lang = GetLanguageAtIndex(idx);
-if (::IsApplicable(category_lang, valobj_lang))
+if (::IsApplicable(category_lang, lang))
   return true;
   }
   return false;
@@ -89,7 +88,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeFormatImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
 return true;
@@ -102,7 +101,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeSummaryImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
 return true;
@@ -115,7 +114,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::SyntheticChildrenSP &entry, uint32_t *reason) 
{
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   TypeFilterImpl::SharedPointer filter_sp;
   uint32_t reason_filter = 0;
Index: lldb/include/lldb/DataFormatters/TypeCategory.h
===
--- lldb/include/lldb/DataFormatters/TypeCategory.h
+++ lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -391,7 +391,7 @@
 
   void Disable() { Enable(false, UINT32_MAX); }
 
-  bool IsApplicable(ValueObject &valobj);
+  bool IsApplicable(lldb::LanguageType lang);
 
   uint32_t GetLastEnabledPosition() { return m_enabled_position; }
 


Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -60,11 +60,10 @@
   }
 }
 
-bool TypeCategoryImpl::IsApplicable(ValueObject &valobj) {
-  lldb::LanguageType valobj_lang = valobj.GetObjectRuntimeLanguage();
+bool TypeCategoryImpl::IsApplicable(lldb::LanguageType lang) {
   for (size_t idx = 0; idx < GetNumLanguages(); idx++) {
 const lldb::LanguageType category_lang = GetLanguageAtIndex(idx);
-if (::IsApplicable(category_lang, valobj_lang))
+if (::IsApplicable(category_lang, lang))
   return true;
   }
   return false;
@@ -89,7 +88,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeFormatImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
 return true;
@@ -102,7 +101,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeSummaryImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
 return true;
@@ -115,7 +114,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::SyntheticChildrenSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   TypeFilterImpl::SharedPointer filter_sp;
   uint32_t reason_filter = 0;
Index: lldb/include/lldb/DataFormatters/TypeCategory.h
===
--- lldb/include/lldb/DataFormatters/TypeCategory.h
+++ lldb/include/lldb/DataFormatt

[Lldb-commits] [PATCH] D71305: [TypeCategory] IsApplicable gets a LanguageType, not a ValueObject.

2019-12-10 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.

This lgtm, but we could go even further and remove VlaueObject from Get() as 
well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71305



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


[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2019-12-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D71151#1774586 , @labath wrote:

> While I'm not opposed to moving "lldbsuite" to some place closer to the 
> tests, one thing I'd like to get out of this is to have the actual tests 
> stand out more prominently.


Ditto; my direct goal is just to be able to run something more fine grained 
than `ninja check-lldb-api`, but splitting tests & test framework is a nice 
side benefit. (Actually it might be simpler if I didn't split it, but now I've 
already done the work).

> For that reason, I wouldn't want to just take the "lldbsuite" folder and 
> "drop" it into `test/API`. In fact, ideally I'd like to get rid of the 
> redundant nested `test` subfolder, and put the tests directly into `test/API`.

SGTM. I can adjust that paths so there is no shim "test" directory. Will await 
resolution of the specific paths as chosen below:

> However, like I said in the other review, if lua is going to become a thing, 
> we should evaluate how will this layout work with additional scripting 
> languages: I see several options here:
> 
> - make a subfolder for each language (`test/API/{Python,Lua}`)
> - ditch the "API" part and put these at the top level (`test/{Python,Lua}`)
> - keep Python in "API", but put lua in Lua (`test/{API,Lua}`) -- besides 
> backward compat, this would kind of signal that "python" is our preferred 
> vessel for writing tests
> - ???

Any of these options are fine with me. Actually, they seem most logical in the 
order you've listed -- the last one seems kind of weird that "API" implicitly 
means python, and there are other non-python API tests elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71151



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


[Lldb-commits] [lldb] 90f4355 - Skip TestMultilineCompletion.py on ios testsuite runs.

2019-12-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2019-12-10T14:55:04-08:00
New Revision: 90f4355b43eaf9eefa02226b98d8cb43f44ca879

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

LOG: Skip TestMultilineCompletion.py on ios testsuite runs.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
index dc4f36b6f8b6..6fbdaee20510 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -14,6 +14,7 @@ class MultilineCompletionTest(PExpectTest):
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
+@skipIfDarwinEmbedded  # test is written to explicitly "run" the binary
 def test_basic_completion(self):
 """Test that we can complete a simple multiline expression"""
 self.build()



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


[Lldb-commits] [PATCH] D71233: Do not cache hardcoded formats in FormatManager

2019-12-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This looks fine to me.  So long as there wasn't much strict type-based matching 
done in the Hardcoded Summary providers, then this shouldn't cause the format 
matching to get slower.


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

https://reviews.llvm.org/D71233



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


[Lldb-commits] [PATCH] D64844: [Target] Remove Target::GetScratchClangASTContext

2019-12-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

This looks fine, sorry for leaving it too long in the In tray...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64844



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


[Lldb-commits] [PATCH] D71233: Do not cache hardcoded formats in FormatManager

2019-12-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

And check the Accept checkbox...


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

https://reviews.llvm.org/D71233



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


[Lldb-commits] [lldb] bbcdcea - [TypeCategory] IsApplicable gets a LanguageType, not a ValueObject.

2019-12-10 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2019-12-10T14:59:34-08:00
New Revision: bbcdcea4bf8423041108e22dc619f7d5fdae9870

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

LOG: [TypeCategory] IsApplicable gets a LanguageType, not a ValueObject.

Reviewers: aprantl, teemperor

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/DataFormatters/TypeCategory.h
lldb/source/DataFormatters/TypeCategory.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/TypeCategory.h 
b/lldb/include/lldb/DataFormatters/TypeCategory.h
index dc5edb654940..f37c661d56d0 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategory.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -391,7 +391,7 @@ class TypeCategoryImpl {
 
   void Disable() { Enable(false, UINT32_MAX); }
 
-  bool IsApplicable(ValueObject &valobj);
+  bool IsApplicable(lldb::LanguageType lang);
 
   uint32_t GetLastEnabledPosition() { return m_enabled_position; }
 

diff  --git a/lldb/source/DataFormatters/TypeCategory.cpp 
b/lldb/source/DataFormatters/TypeCategory.cpp
index be3b31603eac..4f8ea5d43411 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -60,11 +60,10 @@ static bool IsApplicable(lldb::LanguageType category_lang,
   }
 }
 
-bool TypeCategoryImpl::IsApplicable(ValueObject &valobj) {
-  lldb::LanguageType valobj_lang = valobj.GetObjectRuntimeLanguage();
+bool TypeCategoryImpl::IsApplicable(lldb::LanguageType lang) {
   for (size_t idx = 0; idx < GetNumLanguages(); idx++) {
 const lldb::LanguageType category_lang = GetLanguageAtIndex(idx);
-if (::IsApplicable(category_lang, valobj_lang))
+if (::IsApplicable(category_lang, lang))
   return true;
   }
   return false;
@@ -89,7 +88,7 @@ void TypeCategoryImpl::AddLanguage(lldb::LanguageType lang) {
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeFormatImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
 return true;
@@ -102,7 +101,7 @@ bool TypeCategoryImpl::Get(ValueObject &valobj,
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeSummaryImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
 return true;
@@ -115,7 +114,7 @@ bool TypeCategoryImpl::Get(ValueObject &valobj,
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::SyntheticChildrenSP &entry, uint32_t *reason) 
{
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   TypeFilterImpl::SharedPointer filter_sp;
   uint32_t reason_filter = 0;



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


[Lldb-commits] [PATCH] D71305: [TypeCategory] IsApplicable gets a LanguageType, not a ValueObject.

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbcdcea4bf84: [TypeCategory] IsApplicable gets a 
LanguageType, not a ValueObject. (authored by davide).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71305

Files:
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/source/DataFormatters/TypeCategory.cpp


Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -60,11 +60,10 @@
   }
 }
 
-bool TypeCategoryImpl::IsApplicable(ValueObject &valobj) {
-  lldb::LanguageType valobj_lang = valobj.GetObjectRuntimeLanguage();
+bool TypeCategoryImpl::IsApplicable(lldb::LanguageType lang) {
   for (size_t idx = 0; idx < GetNumLanguages(); idx++) {
 const lldb::LanguageType category_lang = GetLanguageAtIndex(idx);
-if (::IsApplicable(category_lang, valobj_lang))
+if (::IsApplicable(category_lang, lang))
   return true;
   }
   return false;
@@ -89,7 +88,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeFormatImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
 return true;
@@ -102,7 +101,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeSummaryImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
 return true;
@@ -115,7 +114,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::SyntheticChildrenSP &entry, uint32_t *reason) 
{
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   TypeFilterImpl::SharedPointer filter_sp;
   uint32_t reason_filter = 0;
Index: lldb/include/lldb/DataFormatters/TypeCategory.h
===
--- lldb/include/lldb/DataFormatters/TypeCategory.h
+++ lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -391,7 +391,7 @@
 
   void Disable() { Enable(false, UINT32_MAX); }
 
-  bool IsApplicable(ValueObject &valobj);
+  bool IsApplicable(lldb::LanguageType lang);
 
   uint32_t GetLastEnabledPosition() { return m_enabled_position; }
 


Index: lldb/source/DataFormatters/TypeCategory.cpp
===
--- lldb/source/DataFormatters/TypeCategory.cpp
+++ lldb/source/DataFormatters/TypeCategory.cpp
@@ -60,11 +60,10 @@
   }
 }
 
-bool TypeCategoryImpl::IsApplicable(ValueObject &valobj) {
-  lldb::LanguageType valobj_lang = valobj.GetObjectRuntimeLanguage();
+bool TypeCategoryImpl::IsApplicable(lldb::LanguageType lang) {
   for (size_t idx = 0; idx < GetNumLanguages(); idx++) {
 const lldb::LanguageType category_lang = GetLanguageAtIndex(idx);
-if (::IsApplicable(category_lang, valobj_lang))
+if (::IsApplicable(category_lang, lang))
   return true;
   }
   return false;
@@ -89,7 +88,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeFormatImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
 return true;
@@ -102,7 +101,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::TypeSummaryImplSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
 return true;
@@ -115,7 +114,7 @@
 bool TypeCategoryImpl::Get(ValueObject &valobj,
const FormattersMatchVector &candidates,
lldb::SyntheticChildrenSP &entry, uint32_t *reason) {
-  if (!IsEnabled() || !IsApplicable(valobj))
+  if (!IsEnabled() || !IsApplicable(valobj.GetObjectRuntimeLanguage()))
 return false;
   TypeFilterImpl::SharedPointer filter_sp;
   uint32_t reason_filter = 0;
Index: lldb/include/lldb/DataFormatters/TypeCate

[Lldb-commits] [lldb] 1d41d1b - Revert "Temporarily revert [lldb] e81268d - [lldb/Reproducers] Support multiple GDB remotes"

2019-12-10 Thread Eric Christopher via lldb-commits

Author: Eric Christopher
Date: 2019-12-10T15:04:45-08:00
New Revision: 1d41d1bcdfd70cf8f77bb32e2617392395c299a4

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

LOG: Revert "Temporarily revert [lldb] e81268d - [lldb/Reproducers] Support 
multiple GDB remotes"

On multiple retry this issue won't duplicate - will revisit with author if
duplication works again.

This reverts commit c9e0b354e2749ce7ab553974692cb35c8651a869.

Added: 
lldb/test/Shell/Reproducer/Inputs/MultipleTargetsCapture.in
lldb/test/Shell/Reproducer/TestMultipleTargets.test

Modified: 
lldb/include/lldb/Utility/GDBRemote.h
lldb/include/lldb/Utility/Reproducer.h
lldb/source/API/SBDebugger.cpp
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Utility/GDBRemote.cpp
lldb/source/Utility/Reproducer.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/GDBRemote.h 
b/lldb/include/lldb/Utility/GDBRemote.h
index b4adeb368524..21b2c8cd73cd 100644
--- a/lldb/include/lldb/Utility/GDBRemote.h
+++ b/lldb/include/lldb/Utility/GDBRemote.h
@@ -9,6 +9,8 @@
 #ifndef liblldb_GDBRemote_h_
 #define liblldb_GDBRemote_h_
 
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-public.h"
@@ -69,7 +71,6 @@ struct GDBRemotePacket {
 std::string data;
   };
 
-  void Serialize(llvm::raw_ostream &strm) const;
   void Dump(Stream &strm) const;
 
   BinaryData packet;
@@ -82,6 +83,46 @@ struct GDBRemotePacket {
   llvm::StringRef GetTypeStr() const;
 };
 
+namespace repro {
+class PacketRecorder : public AbstractRecorder {
+public:
+  PacketRecorder(const FileSpec &filename, std::error_code &ec)
+  : AbstractRecorder(filename, ec) {}
+
+  static llvm::Expected>
+  Create(const FileSpec &filename);
+
+  void Record(const GDBRemotePacket &packet);
+};
+
+class GDBRemoteProvider : public repro::Provider {
+public:
+  struct Info {
+static const char *name;
+static const char *file;
+  };
+
+  GDBRemoteProvider(const FileSpec &directory) : Provider(directory) {}
+
+  llvm::raw_ostream *GetHistoryStream();
+  PacketRecorder *GetNewPacketRecorder();
+
+  void SetCallback(std::function callback) {
+m_callback = std::move(callback);
+  }
+
+  void Keep() override;
+  void Discard() override;
+
+  static char ID;
+
+private:
+  std::function m_callback;
+  std::unique_ptr m_stream_up;
+  std::vector> m_packet_recorders;
+};
+
+} // namespace repro
 } // namespace lldb_private
 
 LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(lldb_private::GDBRemotePacket)

diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index ddb1f45a7219..0d23fe8571ff 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -153,24 +153,13 @@ class WorkingDirectoryProvider : public 
Provider {
   static char ID;
 };
 
-class DataRecorder {
-public:
-  DataRecorder(const FileSpec &filename, std::error_code &ec)
+class AbstractRecorder {
+protected:
+  AbstractRecorder(const FileSpec &filename, std::error_code &ec)
   : m_filename(filename.GetFilename().GetStringRef()),
 m_os(filename.GetPath(), ec, llvm::sys::fs::OF_Text), m_record(true) {}
 
-  static llvm::Expected>
-  Create(const FileSpec &filename);
-
-  template  void Record(const T &t, bool newline = false) {
-if (!m_record)
-  return;
-m_os << t;
-if (newline)
-  m_os << '\n';
-m_os.flush();
-  }
-
+public:
   const FileSpec &GetFilename() { return m_filename; }
 
   void Stop() {
@@ -180,10 +169,30 @@ class DataRecorder {
 
 private:
   FileSpec m_filename;
+
+protected:
   llvm::raw_fd_ostream m_os;
   bool m_record;
 };
 
+class DataRecorder : public AbstractRecorder {
+public:
+  DataRecorder(const FileSpec &filename, std::error_code &ec)
+  : AbstractRecorder(filename, ec) {}
+
+  static llvm::Expected>
+  Create(const FileSpec &filename);
+
+  template  void Record(const T &t, bool newline = false) {
+if (!m_record)
+  return;
+m_os << t;
+if (newline)
+  m_os << '\n';
+m_os.flush();
+  }
+};
+
 class CommandProvider : public Provider {
 public:
   struct Info {
@@ -204,32 +213,6 @@ class CommandProvider : public Provider {
   std::vector> m_data_recorders;
 };
 
-class ProcessGDBRemoteProvider
-: public repro::Provider {
-public:
-  struct Info {
-stati

Re: [Lldb-commits] [lldb] 90f4355 - Skip TestMultilineCompletion.py on ios testsuite runs.

2019-12-10 Thread Davide Italiano via lldb-commits
I don't think that it's terribly valuable testing autocompletion on
device, but we should try to avoid calling `run` directly to avoid
these sort of issues.

On Tue, Dec 10, 2019 at 2:55 PM Jason Molenda via lldb-commits
 wrote:
>
>
> Author: Jason Molenda
> Date: 2019-12-10T14:55:04-08:00
> New Revision: 90f4355b43eaf9eefa02226b98d8cb43f44ca879
>
> URL: 
> https://github.com/llvm/llvm-project/commit/90f4355b43eaf9eefa02226b98d8cb43f44ca879
> DIFF: 
> https://github.com/llvm/llvm-project/commit/90f4355b43eaf9eefa02226b98d8cb43f44ca879.diff
>
> LOG: Skip TestMultilineCompletion.py on ios testsuite runs.
>
> Added:
>
>
> Modified:
> 
> lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
>
> Removed:
>
>
>
> 
> diff  --git 
> a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
>  
> b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
> index dc4f36b6f8b6..6fbdaee20510 100644
> --- 
> a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
> +++ 
> b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
> @@ -14,6 +14,7 @@ class MultilineCompletionTest(PExpectTest):
>  # PExpect uses many timeouts internally and doesn't play well
>  # under ASAN on a loaded machine..
>  @skipIfAsan
> +@skipIfDarwinEmbedded  # test is written to explicitly "run" the binary
>  def test_basic_completion(self):
>  """Test that we can complete a simple multiline expression"""
>  self.build()
>
>
>
> ___
> 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


[Lldb-commits] [lldb] b0937be - Skip TestGuiBasic.py on ios etc device testing.

2019-12-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2019-12-10T15:15:25-08:00
New Revision: b0937be06e44c0cdc1c1aac16b76746150e70154

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

LOG: Skip TestGuiBasic.py on ios etc device testing.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
b/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
index d501b266cc12..0ee0982a5b42 100644
--- a/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
+++ b/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
@@ -15,6 +15,7 @@ class BasicGuiCommandTest(PExpectTest):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfCursesSupportMissing
+@skipIfDarwinEmbedded # "run" command will not work correctly for remote 
debug
 def test_gui(self):
 self.build()
 



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


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, mgorny, xiaobai.
Herald added a subscriber: abidh.
Herald added a project: LLDB.

Recently there has been some discussion about how we deal with optional 
dependencies in LLDB. The common approach in LLVM is to make things work out of 
the box. If the dependency isn't there, we just move on. This is not true in 
LLDB. Unless you explicitly disable the dependency with `LLDB_DISABLE_*`, 
you'll get a configuration-time error.

When a dependency is not found in LLVM, it prints a status message. This is 
something I don't like, because there are quite a lot, and they're easy to 
miss. I'd rather not build all of LLDB only to find out that it couldn't find 
Python and now I can't run the test suite. Given how "important" some of our 
dependencies really are, I think a warning isn't unreasonable.

For the first approach we'd need 3 variables for every CMake option.

1. The default value.
2. The user provided value, which can override the default value. If the user 
says they want to disable Python, we shouldn't print the aforementioned warning.
3. The value actually used by LLDB. This needs to be different from the one 
provided by the user, because maybe they enabled Python, but the library 
couldn't be found.

What I don't like about this approach is there needs to be a discrepancy 
between the variable provided by the user and the one used in the code. If I 
pass LLDB_DISABLE_PYTHON I want to grep for that and see what it affects.

The second approach is printing the warning once, and modifying the 
user-provided variable in the cache. So if you pass LLDB_DISABLE_PYTHON=OFF and 
CMake can't find it, it would update LLDB_DISABLE_PYTHON=ON, which is what 
you'd probably do in the current situation. This also means the warning is only 
printed once, because once LLDB_DISABLE_PYTHON is set, you wouldn't try looking 
for it again.

What I don't like about this approach is that this is messing with my user 
provided variables behind my back. Sure it prints a warning, but if there were 
other configuration issue I might need to rerun CMake and be oblivious what 
happened.

The third and final approach is doing what LLVM does. If the dependency is 
found, turn the option on (unless the value is overwritten by the user) and 
vice versa. This is by far the cleanest approach from a CMake and UX 
perspective, but I've already stated what I don't like about this.

PS: The diff shows what (2) would look like.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71306

Files:
  lldb/cmake/modules/LLDBConfig.cmake


Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -110,23 +110,29 @@
 
 
 if (NOT LLDB_DISABLE_LIBEDIT)
-  find_package(LibEdit REQUIRED)
-
-  # Check if we libedit capable of handling wide characters (built with
-  # '--enable-widec').
-  set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
-  set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
-  check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
-  set(CMAKE_EXTRA_INCLUDE_FILES histedit.h)
-  check_type_size(el_rfunc_t LLDB_EL_RFUNC_T_SIZE)
-  if (LLDB_EL_RFUNC_T_SIZE STREQUAL "")
-set(LLDB_HAVE_EL_RFUNC_T 0)
+  find_package(LibEdit)
+
+  if (libedit_FOUND)
+# Check if we libedit capable of handling wide characters (built with
+# '--enable-widec').
+set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
+check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
+set(CMAKE_EXTRA_INCLUDE_FILES histedit.h)
+check_type_size(el_rfunc_t LLDB_EL_RFUNC_T_SIZE)
+if (LLDB_EL_RFUNC_T_SIZE STREQUAL "")
+  set(LLDB_HAVE_EL_RFUNC_T 0)
+else()
+  set(LLDB_HAVE_EL_RFUNC_T 1)
+endif()
+set(CMAKE_REQUIRED_LIBRARIES)
+set(CMAKE_REQUIRED_INCLUDES)
+set(CMAKE_EXTRA_INCLUDE_FILES)
   else()
-set(LLDB_HAVE_EL_RFUNC_T 1)
+message(WARNING "LLDB will build without LibEdit support, because it 
coulnd't be found.")
+set(LLDB_DISABLE_LIBEDIT ON FORCE)
   endif()
-  set(CMAKE_REQUIRED_LIBRARIES)
-  set(CMAKE_REQUIRED_INCLUDES)
-  set(CMAKE_EXTRA_INCLUDE_FILES)
+
 endif()
 
 
@@ -488,18 +494,22 @@
 endif()
 
 if (NOT LLDB_DISABLE_CURSES)
-find_package(Curses REQUIRED)
-
-find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel 
library")
-if (NOT CURSES_PANEL_LIBRARY)
-message(FATAL_ERROR "A required curses' panel library not found.")
-endif ()
-
-# Add panels to the library path
-set (CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_PANEL_LIBRARY})
-
-list(APPEND system_libs ${CURSES_LIBRARIES})
-include_directories(${CURSES_INCLUDE_DIR})
+find_package(Curses)
+if (CURSES_FOUND)
+  find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel 
library")
+  

[Lldb-commits] [lldb] f387b99 - [DataFormatters] Change the Get() method to take a LanguageType.

2019-12-10 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2019-12-10T15:21:24-08:00
New Revision: f387b99745101d5843d397a2a65dc4102c6f8e14

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

LOG: [DataFormatters] Change the Get() method to take a LanguageType.

Suggested by Adrian.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/TypeCategory.h
lldb/source/DataFormatters/LanguageCategory.cpp
lldb/source/DataFormatters/TypeCategory.cpp
lldb/source/DataFormatters/TypeCategoryMap.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/TypeCategory.h 
b/lldb/include/lldb/DataFormatters/TypeCategory.h
index f37c661d56d0..513e859815f5 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategory.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -332,16 +332,16 @@ class TypeCategoryImpl {
   return m_enabled_position;
   }
 
-  bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+  bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
lldb::TypeFormatImplSP &entry, uint32_t *reason = nullptr);
 
-  bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+  bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
lldb::TypeSummaryImplSP &entry, uint32_t *reason = nullptr);
 
-  bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+  bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr);
 
-  bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+  bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
lldb::TypeValidatorImplSP &entry, uint32_t *reason = nullptr);
 
   void Clear(FormatCategoryItems items = ALL_ITEM_TYPES);

diff  --git a/lldb/source/DataFormatters/LanguageCategory.cpp 
b/lldb/source/DataFormatters/LanguageCategory.cpp
index 64a891804c57..86de28060254 100644
--- a/lldb/source/DataFormatters/LanguageCategory.cpp
+++ b/lldb/source/DataFormatters/LanguageCategory.cpp
@@ -48,8 +48,8 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
   }
 
   ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
+   match_data.GetMatchesVector(), format_sp);
   if (match_data.GetTypeForCache() &&
   (!format_sp || !format_sp->NonCacheable())) {
 m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
@@ -71,8 +71,8 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
   }
 
   ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
+   match_data.GetMatchesVector(), format_sp);
   if (match_data.GetTypeForCache() &&
   (!format_sp || !format_sp->NonCacheable())) {
 m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
@@ -94,8 +94,8 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
   }
 
   ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
+   match_data.GetMatchesVector(), format_sp);
   if (match_data.GetTypeForCache() &&
   (!format_sp || !format_sp->NonCacheable())) {
 m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
@@ -117,8 +117,8 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
   }
 
   ValueObject &valobj(match_data.GetValueObject());
-  bool result =
-  m_category_sp->Get(valobj, match_data.GetMatchesVector(), format_sp);
+  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
+   match_data.GetMatchesVector(), format_sp);
   if (match_data.GetTypeForCache() &&
   (!format_sp || !format_sp->NonCacheable())) {
 m_format_cache.Set(match_data.GetTypeForCache(), format_sp);

diff  --git a/lldb/source/DataFormatters/TypeCategory.cpp 
b/lldb/source/DataFormatters/TypeCategory.cpp
index 4f8ea5d43411..7a04b59b1c84 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -85,10 +85,10 @@ void TypeCategoryImpl::AddLanguage(lldb::LanguageType lang) 
{
   m_languages.push_back(lang);
 }
 
-bool TypeCategoryImpl::Get(ValueObject &valobj,
+bool TypeCategoryImpl::Get(lldb::LanguageType lang,
const FormattersMatchVector &candidate

[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:28
 set(default_disable_python OFF)
+set(default_disable_lua OFF)
 set(default_disable_curses OFF)

mgorny wrote:
> labath wrote:
> > I think this will tick off some bots (and people) because it means that the 
> > default configuration will not build unless one has (compatible?) lua 
> > installed. Though I don't really like that, the usual way to handle 
> > external dependencies in llvm is to detect their presence and automatically 
> > disable the relevant functionality.
> > 
> > Now, that's not how things work in lldb right now, so it _may_ make sense 
> > to do the same for lua (though it also may make sense to port everything to 
> > the llvm style). However, the current lldb behavior has been a source of 
> > friction in the past and I suspect a fresh build error might reignite some 
> > of that.
> > 
> > Anyway, you have been warned...
> Fixing this is one of the things at the far end of my todo. If you could look 
> into replacing the disable logic with something better, a lot of people would 
> really be grateful.
I've changed the default for now and put up an "RFC" here: 
https://reviews.llvm.org/D71306


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

https://reviews.llvm.org/D71232



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


[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 233203.
JDevlieghere marked 5 inline comments as done.

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

https://reviews.llvm.org/D71232

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Interpreter/OptionArgParser.cpp
  lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h

Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -0,0 +1,47 @@
+//===-- ScriptInterpreterLua.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ScriptInterpreterLua_h_
+#define liblldb_ScriptInterpreterLua_h_
+
+#include "lldb/Interpreter/ScriptInterpreter.h"
+
+namespace lldb_private {
+
+class ScriptInterpreterLua : public ScriptInterpreter {
+public:
+  ScriptInterpreterLua(Debugger &debugger);
+
+  ~ScriptInterpreterLua() override;
+
+  bool ExecuteOneLine(
+  llvm::StringRef command, CommandReturnObject *result,
+  const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
+
+  void ExecuteInterpreterLoop() override;
+
+  // Static Functions
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger);
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static const char *GetPluginDescriptionStatic();
+
+  // PluginInterface protocol
+  lldb_private::ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ScriptInterpreterLua_h_
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -0,0 +1,71 @@
+//===-- ScriptInterpreterLua.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ScriptInterpreterLua.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
+
+#include "llvm/Support/Threading.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+ScriptInterpreterLua::ScriptInterpreterLua(Debugger &debugger)
+: ScriptInterpreter(debugger, eScriptLanguageLua) {}
+
+ScriptInterpreterLua::~ScriptInterpreterLua() {}
+
+bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
+  CommandReturnObject *,
+  const ExecuteScriptOptions &) {
+  m_debugger.GetErrorStream().PutCString(
+  "error: the lua script interpreter is not yet implemented.\n");
+  return false;
+}
+
+void ScriptInterpreterLua::ExecuteInterpreterLoop() {
+  m_debugger.GetErrorStream().PutCString(
+  "error: the lua script interpreter is not yet implemented.\n");
+}
+
+void ScriptInterpreterLua::Initialize() {
+  static llvm::once_flag g_once_flag;
+
+  llvm::call_once(g_once_flag, []() {
+PluginManager::RegisterPlugin(GetPluginNameStatic(),
+  GetPluginDescriptionStatic(),
+  lldb::eScriptLanguageLua, CreateInstance);
+  });
+}
+
+void ScriptInterpreterLua::Terminate() {}
+
+lldb::ScriptInterpreterSP
+ScriptInterpreterLua::CreateInstance(Debugger &debugger) {
+  return std::make_shared(debugger);
+}
+
+lldb_private::ConstString ScriptInterpreterLua::GetPluginNameStatic() {
+  static ConstString g_name("script-lua");
+  return g_name;
+}
+
+const char *ScriptInterpreterLua::GetPluginDescriptionStatic() {
+  return "Lua script interpreter";
+}
+
+lldb_private::ConstString ScriptInterpreterLua::GetPluginName() {
+  return GetPluginNameStatic();
+}
+
+uint32_t ScriptInterpreterLua::GetPluginVersion() { return 1; }
Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- /dev/

[Lldb-commits] [PATCH] D71309: [FormatEntity] Add mangled function name support

2019-12-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added a project: LLDB.

Add `function.mangled-name` key for FormatEntity to show the mangled
function names in backtraces.

rdar://54088244

Signed-off-by: Med Ismail Bennani 

LanguageRuntime: Simplify NSException::GetSummary() output

Right now, NSException::GetSummary() output is the following:
"name: $exception_name - reason: $exception_reason"

It would be better to simplify the output by removing the name and only
showing the exception's reason. This way, annotations would look nicer in
the editor, and would be a shorter summary in the Variables Inspector.

Accessing the exception's name can still be done by expanding the
NSException object in the Variables Inspector.

rdar://54770115

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71309

Files:
  lldb/docs/use/formatting.rst
  lldb/include/lldb/Core/FormatEntity.h
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py
  lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  lldb/source/Core/FormatEntity.cpp
  lldb/source/Plugins/Language/ObjC/NSException.cpp
  lldb/test/Shell/Settings/Inputs/main.cpp
  lldb/test/Shell/Settings/TestFrameFormatMangling.test

Index: lldb/test/Shell/Settings/TestFrameFormatMangling.test
===
--- /dev/null
+++ lldb/test/Shell/Settings/TestFrameFormatMangling.test
@@ -0,0 +1,12 @@
+# UNSUPPORTED: system-windows
+# RUN: %clangxx_host -g -O0 %S/Inputs/main.cpp -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck %s
+br set -p "Set break"
+run
+frame info
+# CHECK: frame #0: {{.*}}Increment::GetValue()
+set set frame-format "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{\`${function.mangled-name}}\n"
+frame info
+# CHECK: frame #0: {{.*}}_ZN9Increment8GetValueEv
+c
+q
Index: lldb/test/Shell/Settings/Inputs/main.cpp
===
--- /dev/null
+++ lldb/test/Shell/Settings/Inputs/main.cpp
@@ -0,0 +1,29 @@
+//===-- main.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+class Increment {
+public:
+  Increment(int value) { Increment::value += value; }
+
+  static const int GetValue();
+
+private:
+  static int value;
+};
+
+int Increment::value = 40;
+
+const int Increment::GetValue() {
+  return value; // Set break point at this line.
+}
+
+int main() {
+  Increment i(2);
+  const int new_val = Increment::GetValue();
+  return new_val;
+}
Index: lldb/source/Plugins/Language/ObjC/NSException.cpp
===
--- lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -96,21 +96,17 @@
 
 bool lldb_private::formatters::NSException_SummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  lldb::ValueObjectSP name_sp;
   lldb::ValueObjectSP reason_sp;
-  if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr, nullptr))
+  if (!ExtractFields(valobj, nullptr, &reason_sp, nullptr, nullptr))
 return false;
 
-  if (!name_sp || !reason_sp)
+  if (!reason_sp)
 return false;
-
-  StreamString name_str_summary;
+  
   StreamString reason_str_summary;
-  if (NSStringSummaryProvider(*name_sp, name_str_summary, options) &&
-  NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
-  !name_str_summary.Empty() && !reason_str_summary.Empty()) {
-stream.Printf("name: %s - reason: %s", name_str_summary.GetData(),
-  reason_str_summary.GetData());
+  if (NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
+  !reason_str_summary.Empty()) {
+stream.Printf("%s", reason_str_summary.GetData());
 return true;
   } else
 return false;
Index: lldb/source/Core/FormatEntity.cpp
===
--- lldb/source/Core/FormatEntity.cpp
+++ lldb/source/Core/FormatEntity.cpp
@@ -125,6 +125,7 @@
 ENTRY("name", FunctionName),
 ENTRY("name-without-args", FunctionNameNoArgs),
 ENTRY("name-with-args", FunctionNameWithArgs),
+ENTRY("mangled-name", FunctionMangledName),
 ENTRY("addr-offset", FunctionAddrOffset),
 ENTRY("concrete-only-addr-offset-no-padding", FunctionAddrOffsetConcrete),
 ENTRY("line-offset", FunctionLineOffset),
@@ -351,6 +352,7 @@
 ENUM_TO_CSTR(FunctionName);
 ENUM_TO_CSTR(FunctionNameWithArgs);
 ENUM_TO_CSTR(FunctionNameNoArgs);
+ENUM_TO_CSTR(FunctionMangledName);
 ENUM_TO_CSTR(FunctionAddrOffset);
 ENUM_TO_CSTR(

[Lldb-commits] [PATCH] D71310: RFC: Remove "Validators"

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, jasonmolenda.
Herald added a subscriber: mgorny.

Data formatter Validators are completely wired up all the way to the SBAPI, but 
as far as I can tell they are not used anywhere (including swift-lldb) and also 
are not tested. I'm puzzled by this, so if anyone can share some info about 
what this was intended for, please let me know.

This patch deletes them as dead code.


https://reviews.llvm.org/D71310

Files:
  lldb/include/lldb/API/SBValue.h
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/DataFormatters/FormatClasses.h
  lldb/include/lldb/DataFormatters/FormatManager.h
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/DataFormatters/LanguageCategory.h
  lldb/include/lldb/DataFormatters/TypeCategory.h
  lldb/include/lldb/DataFormatters/TypeValidator.h
  lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
  lldb/include/lldb/Target/Language.h
  lldb/source/API/SBValue.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/CMakeLists.txt
  lldb/source/DataFormatters/DataVisualization.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp
  lldb/source/DataFormatters/TypeCategory.cpp
  lldb/source/DataFormatters/TypeCategoryMap.cpp
  lldb/source/DataFormatters/TypeValidator.cpp
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/source/Target/Language.cpp

Index: lldb/source/Target/Language.cpp
===
--- lldb/source/Target/Language.cpp
+++ lldb/source/Target/Language.cpp
@@ -134,11 +134,6 @@
   return {};
 }
 
-HardcodedFormatters::HardcodedValidatorFinder
-Language::GetHardcodedValidators() {
-  return {};
-}
-
 std::vector
 Language::GetPossibleFormattersMatches(ValueObject &valobj,
lldb::DynamicValueType use_dynamic) {
Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -75,8 +75,6 @@
 return false;
 
   if (ShouldPrintValueObject()) {
-PrintValidationMarkerIfNeeded();
-
 PrintLocationIfNeeded();
 m_stream->Indent();
 
@@ -94,8 +92,6 @@
   else
 m_stream->EOL();
 
-  PrintValidationErrorIfNeeded();
-
   return true;
 }
 
@@ -790,37 +786,3 @@
   } else
 m_stream->EOL();
 }
-
-bool ValueObjectPrinter::ShouldPrintValidation() {
-  return m_options.m_run_validator;
-}
-
-bool ValueObjectPrinter::PrintValidationMarkerIfNeeded() {
-  if (!ShouldPrintValidation())
-return false;
-
-  m_validation = m_valobj->GetValidationStatus();
-
-  if (TypeValidatorResult::Failure == m_validation.first) {
-m_stream->Printf("! ");
-return true;
-  }
-
-  return false;
-}
-
-bool ValueObjectPrinter::PrintValidationErrorIfNeeded() {
-  if (!ShouldPrintValidation())
-return false;
-
-  if (TypeValidatorResult::Success == m_validation.first)
-return false;
-
-  if (m_validation.second.empty())
-m_validation.second.assign("unknown error");
-
-  m_stream->Printf(" ! validation error: %s", m_validation.second.c_str());
-  m_stream->EOL();
-
-  return true;
-}
Index: lldb/source/DataFormatters/TypeValidator.cpp
===
--- lldb/source/DataFormatters/TypeValidator.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//===-- TypeValidator.cpp ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-
-
-
-#include "lldb/DataFormatters/TypeValidator.h"
-#include "lldb/Utility/StreamString.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-TypeValidatorImpl::TypeValidatorImpl(const Flags &flags)
-: m_flags(flags), m_my_revision(0) {}
-
-TypeValidatorImpl::~TypeValidatorImpl() {}
-
-TypeValidatorImpl::ValidationResult TypeValidatorImpl::Success() {
-  return ValidationResult{TypeValidatorResult::Success, ""};
-}
-
-TypeValidatorImpl::ValidationResult
-TypeValidatorImpl::Failure(std::string message) {
-  return ValidationResult{TypeValidatorResult::Failure, message};
-}
-
-TypeValidatorImpl_CXX::TypeValidatorImpl_CXX(
-ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags &flags)
-: TypeValidatorImpl(flags), m_description(d), m_validator_function(f) {}
-
-TypeValidatorImpl_CXX::~TypeValidatorImpl_CXX() {}
-
-TypeValidatorImpl::ValidationResult
-TypeValidatorImpl_CXX::FormatObject(ValueObject *valobj) const {
-  if (!valobj)
-return Success(); // I guess there's nothing wrong with a null valueobject..
-
-  return m_validator_function(valobj);
-}
-
-std::string TypeValidat

[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-10 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

I personally prefer the third approach. To make sure I understand correctly, 
I'll write it in my own words so you can correct me if I misunderstood.
Try to find the dependency, and if we find it then use it. If not, then we can 
print out something like "Didn't find `DEPENDENCY`" and continue on our merry 
way. If the user overwrites the values and something goes wrong, send a fatal 
error and tell them that what the value they set isn't going to work without 
further work (e.g. explicitly enable python support but didn't find python? 
tell the user that you couldn't find python and maybe suggest setting some 
other CMake variables to help CMake find python).

I think that we should emphasize UX here. While I think that everybody could 
benefit from understanding the build system better, helping the user understand 
that their settings don't work (and why they don't work) goes a long way.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71306



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


[Lldb-commits] [PATCH] D71311: LanguageRuntime: Simplify NSException::GetSummary() output

2019-12-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added a project: LLDB.

Right now, NSException::GetSummary() has the following output:
"name: $exception_name - reason: $exception_reason"

It would be better to simplify the output by removing the name and only
showing the exception's reason. This way, annotations would look nicer in
the editor, and would be a shorter summary in the Variables Inspector.

Accessing the exception's name can still be done by expanding the
NSException object in the Variables Inspector.

rdar://54770115

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71311

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py
  lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  lldb/source/Plugins/Language/ObjC/NSException.cpp

Index: lldb/source/Plugins/Language/ObjC/NSException.cpp
===
--- lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -96,21 +96,17 @@
 
 bool lldb_private::formatters::NSException_SummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  lldb::ValueObjectSP name_sp;
   lldb::ValueObjectSP reason_sp;
-  if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr, nullptr))
+  if (!ExtractFields(valobj, nullptr, &reason_sp, nullptr, nullptr))
 return false;
 
-  if (!name_sp || !reason_sp)
+  if (!reason_sp)
 return false;
 
-  StreamString name_str_summary;
   StreamString reason_str_summary;
-  if (NSStringSummaryProvider(*name_sp, name_str_summary, options) &&
-  NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
-  !name_str_summary.Empty() && !reason_str_summary.Empty()) {
-stream.Printf("name: %s - reason: %s", name_str_summary.GetData(),
-  reason_str_summary.GetData());
+  if (NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
+  !reason_str_summary.Empty()) {
+stream.Printf("%s", reason_str_summary.GetData());
 return true;
   } else
 return false;
Index: lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
===
--- lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -31,7 +31,7 @@
 
 self.expect('thread exception', substrs=[
 '(NSException *) exception = ',
-'name: "ThrownException" - reason: "SomeReason"',
+'"SomeReason"',
 ])
 
 target = self.dbg.GetSelectedTarget()
@@ -63,7 +63,7 @@
 'frame variable e1',
 substrs=[
 '(NSException *) e1 = ',
-'name: "ExceptionName" - reason: "SomeReason"'
+'"SomeReason"'
 ])
 
 self.expect(
@@ -79,7 +79,7 @@
 e1 = frame.FindVariable("e1")
 self.assertTrue(e1)
 self.assertEqual(e1.type.name, "NSException *")
-self.assertEqual(e1.GetSummary(), 'name: "ExceptionName" - reason: "SomeReason"')
+self.assertEqual(e1.GetSummary(), '"SomeReason"')
 self.assertEqual(e1.GetChildMemberWithName("name").description, "ExceptionName")
 self.assertEqual(e1.GetChildMemberWithName("reason").description, "SomeReason")
 userInfo = e1.GetChildMemberWithName("userInfo").dynamic
@@ -92,7 +92,7 @@
 'frame variable e2',
 substrs=[
 '(NSException *) e2 = ',
-'name: "ThrownException" - reason: "SomeReason"'
+'"SomeReason"'
 ])
 
 self.expect(
@@ -108,7 +108,7 @@
 e2 = frame.FindVariable("e2")
 self.assertTrue(e2)
 self.assertEqual(e2.type.name, "NSException *")
-self.assertEqual(e2.GetSummary(), 'name: "ThrownException" - reason: "SomeReason"')
+self.assertEqual(e2.GetSummary(), '"SomeReason"')
 self.assertEqual(e2.GetChildMemberWithName("name").description, "ThrownException")
 self.assertEqual(e2.GetChildMemberWithName("reason").description, "SomeReason")
 userInfo = e2.GetChildMemberWithName("userInfo").dynamic
@@ -141,7 +141,7 @@
 
 self.expect('thread exception', substrs=[
 '(NSException *) exception = ',
-'name: "ThrownException" - reason: "SomeReason"',
+'"SomeReason"',
 'libobjc.A.dylib`objc_exception_throw',
 'a.out`foo', 'at main.mm:24',
 'a.out`rethrow', 'at main.mm:35',
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py
===
--- lldb/packages/Py

Re: [Lldb-commits] [lldb] b0937be - Skip TestGuiBasic.py on ios etc device testing.

2019-12-10 Thread Frédéric Riss via lldb-commits
I think it would be better to stick the equivalent of skipIfRemote in the 
Expect base class.

> On Dec 10, 2019, at 3:15 PM, Jason Molenda via lldb-commits 
>  wrote:
> 
> 
> Author: Jason Molenda
> Date: 2019-12-10T15:15:25-08:00
> New Revision: b0937be06e44c0cdc1c1aac16b76746150e70154
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/b0937be06e44c0cdc1c1aac16b76746150e70154
> DIFF: 
> https://github.com/llvm/llvm-project/commit/b0937be06e44c0cdc1c1aac16b76746150e70154.diff
> 
> LOG: Skip TestGuiBasic.py on ios etc device testing.
> 
> Added: 
> 
> 
> Modified: 
>lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
> 
> Removed: 
> 
> 
> 
> 
> diff  --git 
> a/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
> b/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
> index d501b266cc12..0ee0982a5b42 100644
> --- a/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
> +++ b/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
> @@ -15,6 +15,7 @@ class BasicGuiCommandTest(PExpectTest):
> # under ASAN on a loaded machine..
> @skipIfAsan
> @skipIfCursesSupportMissing
> +@skipIfDarwinEmbedded # "run" command will not work correctly for remote 
> debug
> def test_gui(self):
> self.build()
> 
> 
> 
> 
> ___
> 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


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I'm going to be blunt but if you dislike what LLVM does, improve that rather 
than proliferating inconsistencies between subprojects.

That said, there are few things that could improve this. We could print a nice 
summary of which dependencies were found and which were not at the end of CMake 
run. We could move variables for controlling deps (or maybe even all user-set 
variables) to a separate file (meson does something like this, i think), so 
they're easier to find and track.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71306



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


Re: [Lldb-commits] [lldb] b0937be - Skip TestGuiBasic.py on ios etc device testing.

2019-12-10 Thread Jason Molenda via lldb-commits
That was my first inclination -- I don't see how it can work correctly on a 
remote setup, just like TestMultilineCompletion.py which I added the same skip 
to -- but I know people are doing remote linux testing for android and this 
doesn't seem to have been a problem for them?  I went the conservative approach 
of skipping it for iOS testing, but I think skipIfRemote is the correct 
decorator.

> On Dec 10, 2019, at 3:47 PM, Frédéric Riss  wrote:
> 
> I think it would be better to stick the equivalent of skipIfRemote in the 
> Expect base class.
> 
>> On Dec 10, 2019, at 3:15 PM, Jason Molenda via lldb-commits 
>>  wrote:
>> 
>> 
>> Author: Jason Molenda
>> Date: 2019-12-10T15:15:25-08:00
>> New Revision: b0937be06e44c0cdc1c1aac16b76746150e70154
>> 
>> URL: 
>> https://github.com/llvm/llvm-project/commit/b0937be06e44c0cdc1c1aac16b76746150e70154
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/b0937be06e44c0cdc1c1aac16b76746150e70154.diff
>> 
>> LOG: Skip TestGuiBasic.py on ios etc device testing.
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
>> 
>> Removed: 
>> 
>> 
>> 
>> 
>> diff  --git 
>> a/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py 
>> b/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
>> index d501b266cc12..0ee0982a5b42 100644
>> --- a/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
>> +++ b/lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
>> @@ -15,6 +15,7 @@ class BasicGuiCommandTest(PExpectTest):
>># under ASAN on a loaded machine..
>>@skipIfAsan
>>@skipIfCursesSupportMissing
>> +@skipIfDarwinEmbedded # "run" command will not work correctly for 
>> remote debug
>>def test_gui(self):
>>self.build()
>> 
>> 
>> 
>> 
>> ___
>> 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


[Lldb-commits] [lldb] 62a6d97 - Do not cache hardcoded formats in FormatManager

2019-12-10 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-12-10T15:53:40-08:00
New Revision: 62a6d9770450f93a2dcdf04710a73341af2f54fa

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

LOG: Do not cache hardcoded formats in FormatManager

The cache in FormatCache uses only a type name as key. The hardcoded
formats, synthetic children, etc inspect an entire ValueObject to
determine their eligibility, which isn't modelled in the cache. This
leads to bugs such as the one in this patch (where two similarly named
types in different files have different hardcoded summary
providers). The problem is exaggerated in the Swift language plugin
due to the language's dynamic nature.

rdar://problem/57756763

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

Added: 

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c

Modified: 
lldb/include/lldb/DataFormatters/FormatManager.h
lldb/source/DataFormatters/FormatManager.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormatManager.h 
b/lldb/include/lldb/DataFormatters/FormatManager.h
index dffba1f93987..c57b8c8c64a9 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -209,7 +209,8 @@ class FormatManager : public IFormatChangeListener {
   ConstString m_vectortypes_category_name;
 
   template 
-  ImplSP GetCached(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
+  ImplSP Get(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
+  template  ImplSP GetCached(FormattersMatchData &match_data);
   template  ImplSP GetHardcoded(FormattersMatchData &);
 
   TypeCategoryMap &GetCategories() { return m_categories_map; }

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/Makefile
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/Makefile
new file mode 100644
index ..224ecc3c2f55
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := a.c b.c
+
+include Makefile.rules

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
new file mode 100644
index ..8b906506a5b6
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
@@ -0,0 +1,27 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestDataFormatterCaching(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+def test_with_run_command(self):
+"""
+Test that hardcoded summary formatter matches aren't improperly cached.
+"""
+self.build()
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, 'break here', lldb.SBFileSpec('a.c'))
+valobj = self.frame().FindVariable('f')
+self.assertEqual(valobj.GetValue(), '4')
+bkpt_b = target.BreakpointCreateBySourceRegex('break here',
+  lldb.SBFileSpec('b.c'))
+lldbutil.continue_to_breakpoint(process, bkpt_b)
+valobj = self.frame().FindVariable('f4')
+self.assertEqual(valobj.GetSummary(), '(1, 2, 3, 4)')

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
new file mode 100644
index ..ab0b6f5bd5e0
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
@@ -0,0 +1,7 @@
+typedef float float4;
+
+int main() {
+  float4 f = 4.0f;
+  // break here
+  return a(); 
+}

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
new file mode 100644
index ..0d37c54aa339
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/function

[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D71306#1778484 , @mgorny wrote:

> I'm going to be blunt but if you dislike what LLVM does, improve that rather 
> than proliferating inconsistencies between subprojects.


I think LLVM's behavior makes sense for LLVM but makes less sense for LLDB. I'm 
all for consistency, but that doesn't mean we should shoehorn anything just 
because that's how it's done in LLVM.

> That said, there are few things that could improve this. We could print a 
> nice summary of which dependencies were found and which were not at the end 
> of CMake run. We could move variables for controlling deps (or maybe even all 
> user-set variables) to a separate file (meson does something like this, i 
> think), so they're easier to find and track.




Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71306



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


[Lldb-commits] [PATCH] D71311: LanguageRuntime: Simplify NSException::GetSummary() output

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py:30
 '(NSException *) except1 = ',
-'name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"',
+'@"cuz it\'s funny"',
 '(NSException *) except2 = ',

Can we modify these strings so they're different for the different exceptions? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71311



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


[Lldb-commits] [PATCH] D71297: Remove unsound caching in LanguageCategory

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D71297



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


[Lldb-commits] [PATCH] D71311: LanguageRuntime: Simplify NSException::GetSummary() output

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

This one looks fine -- can you please check that this patch applied on swift 
still produces something reasonable for mixed obj-C/swift formatters?
My guess is that it will, and you probably just need to update some tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71311



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


[Lldb-commits] [PATCH] D71309: [FormatEntity] Add mangled function name support

2019-12-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

Duplicate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71309



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


[Lldb-commits] [PATCH] D71233: Do not cache hardcoded formats in FormatManager

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62a6d9770450: Do not cache hardcoded formats in 
FormatManager (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71233

Files:
  lldb/include/lldb/DataFormatters/FormatManager.h
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
  lldb/source/DataFormatters/FormatManager.cpp

Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -622,11 +622,21 @@
   return retval_sp;
 }
 
-template  ImplSP
-FormatManager::GetCached(ValueObject &valobj,
- lldb::DynamicValueType use_dynamic) {
-  ImplSP retval_sp;
+template 
+ImplSP FormatManager::Get(ValueObject &valobj,
+  lldb::DynamicValueType use_dynamic) {
   FormattersMatchData match_data(valobj, use_dynamic);
+  if (ImplSP retval_sp = GetCached(match_data))
+return retval_sp;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
+  return GetHardcoded(match_data);
+}
+
+template 
+ImplSP FormatManager::GetCached(FormattersMatchData &match_data) {
+  ImplSP retval_sp;
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
   if (match_data.GetTypeForCache()) {
 LLDB_LOGF(log, "\n\n[%s] Looking into cache for type %s", __FUNCTION__,
@@ -659,10 +669,6 @@
   return retval_sp;
 }
   }
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
-retval_sp = GetHardcoded(match_data);
-  }
 
   if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
@@ -678,25 +684,25 @@
 lldb::TypeFormatImplSP
 FormatManager::GetFormat(ValueObject &valobj,
  lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 lldb::TypeSummaryImplSP
 FormatManager::GetSummaryFormat(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 lldb::SyntheticChildrenSP
 FormatManager::GetSyntheticChildren(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 lldb::TypeValidatorImplSP
 FormatManager::GetValidator(ValueObject &valobj,
 lldb::DynamicValueType use_dynamic) {
-  return GetCached(valobj, use_dynamic);
+  return Get(valobj, use_dynamic);
 }
 
 FormatManager::FormatManager()
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/b.c
@@ -0,0 +1,8 @@
+typedef float float4 __attribute__((ext_vector_type(4)));
+void stop() {}
+int a() {
+  float4 f4 = {1, 2, 3, 4};
+  // break here
+  stop();
+  return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
@@ -0,0 +1,7 @@
+typedef float float4;
+
+int main() {
+  float4 f = 4.0f;
+  // break here
+  return a(); 
+}
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py
@@ -0,0 +1,27 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestDataFormatterCaching(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+def test_with_run_command(self):
+"""
+Test that hardcoded summary formatter matches aren't improperly cached.
+  

[Lldb-commits] [lldb] 70e3d0e - [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-12-10T15:57:53-08:00
New Revision: 70e3d0ea55e8b9385168d389fcba16a283f20214

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

LOG: [FormatManager] Move Language lookup into the obviously non-cached part 
(NFC)

This refactoring makes the lookup caching easier to reason about. This
has no observable effect although it does slightly change what is
being cached.

- Before this patch a negative lookup in the LanguageCategory would be
  cached, but a positive wouldn't.

- After this patch LanguageCategory lookups aren't cached by
  FormatManager, period. (LanguageCategory has its own FormatCache for this!)

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

Added: 


Modified: 
lldb/source/DataFormatters/FormatManager.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index db15a7f7a4cc..8c7967aaf1e1 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@ ImplSP FormatManager::Get(ValueObject &valobj,
 return retval_sp;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", 
__FUNCTION__);
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", 
__FUNCTION__);
+  for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
+if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
+  ImplSP retval_sp;
+  if (lang_category->Get(match_data, retval_sp))
+if (retval_sp) {
+  LLDB_LOGF(log, "[%s] Language search success. Returning.",
+__FUNCTION__);
+  return retval_sp;
+}
+}
+  }
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.",
+__FUNCTION__);
   return GetHardcoded(match_data);
 }
 
@@ -655,21 +670,6 @@ ImplSP FormatManager::GetCached(FormattersMatchData 
&match_data) {
   }
 
   m_categories_map.Get(match_data, retval_sp);
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
-  __FUNCTION__);
-for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-  if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) 
{
-if (lang_category->Get(match_data, retval_sp))
-  break;
-  }
-}
-if (retval_sp) {
-  LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
-  return retval_sp;
-}
-  }
-
   if (match_data.GetTypeForCache() && (!retval_sp || 
!retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
   static_cast(retval_sp.get()),



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


[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70e3d0ea55e8: [FormatManager] Move Language lookup into the 
obviously non-cached part (NFC) (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71289

Files:
  lldb/source/DataFormatters/FormatManager.cpp


Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@
 return retval_sp;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", 
__FUNCTION__);
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", 
__FUNCTION__);
+  for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
+if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
+  ImplSP retval_sp;
+  if (lang_category->Get(match_data, retval_sp))
+if (retval_sp) {
+  LLDB_LOGF(log, "[%s] Language search success. Returning.",
+__FUNCTION__);
+  return retval_sp;
+}
+}
+  }
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.",
+__FUNCTION__);
   return GetHardcoded(match_data);
 }
 
@@ -655,21 +670,6 @@
   }
 
   m_categories_map.Get(match_data, retval_sp);
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
-  __FUNCTION__);
-for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-  if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) 
{
-if (lang_category->Get(match_data, retval_sp))
-  break;
-  }
-}
-if (retval_sp) {
-  LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
-  return retval_sp;
-}
-  }
-
   if (match_data.GetTypeForCache() && (!retval_sp || 
!retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
   static_cast(retval_sp.get()),


Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@
 return retval_sp;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
-  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", __FUNCTION__);
+  for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
+if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
+  ImplSP retval_sp;
+  if (lang_category->Get(match_data, retval_sp))
+if (retval_sp) {
+  LLDB_LOGF(log, "[%s] Language search success. Returning.",
+__FUNCTION__);
+  return retval_sp;
+}
+}
+  }
+
+  LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.",
+__FUNCTION__);
   return GetHardcoded(match_data);
 }
 
@@ -655,21 +670,6 @@
   }
 
   m_categories_map.Get(match_data, retval_sp);
-  if (!retval_sp) {
-LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
-  __FUNCTION__);
-for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-  if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
-if (lang_category->Get(match_data, retval_sp))
-  break;
-  }
-}
-if (retval_sp) {
-  LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
-  return retval_sp;
-}
-  }
-
   if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
 LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
   static_cast(retval_sp.get()),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 233218.
JDevlieghere added a comment.

Reuse IOHandlerEditline for the Lua interpreter.


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

https://reviews.llvm.org/D71232

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -10,32 +10,110 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StringList.h"
-
+#include "lldb/Utility/Timer.h"
 #include "llvm/Support/Threading.h"
 
+#ifndef LLDB_DISABLE_LIBEDIT
+#include "lldb/Host/Editline.h"
+#endif
+
+#include "lua.hpp"
+
+#define LUA_PROMPT ">>> "
+
 #include 
 
 using namespace lldb;
 using namespace lldb_private;
 
+class Lua {
+public:
+  Lua() : m_lua_state(luaL_newstate()) {
+assert(m_lua_state);
+luaL_openlibs(m_lua_state);
+  }
+  ~Lua() {
+assert(m_lua_state);
+luaL_openlibs(m_lua_state);
+  }
+
+  lua_State *State() { return m_lua_state; }
+
+private:
+  lua_State *m_lua_state = nullptr;
+};
+
+class IOHandlerLuaInterpreter : public IOHandlerDelegate,
+public IOHandlerEditline {
+public:
+  IOHandlerLuaInterpreter(Debugger &debugger)
+  : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
+  ">>> ", "..> ", true, debugger.GetUseColor(), 0,
+  *this, nullptr),
+m_lua() {}
+
+  void IOHandlerInputComplete(IOHandler &io_handler,
+  std::string &data) override {
+int error =
+luaL_loadbuffer(m_lua.State(), data.c_str(), data.size(), "line") ||
+lua_pcall(m_lua.State(), 0, 0, 0);
+if (error) {
+  fprintf(GetOutputFILE(), "%s\n", lua_tostring(m_lua.State(), -1));
+  // Pop error message from the stack.
+  lua_pop(m_lua.State(), 1);
+}
+  }
+
+  ~IOHandlerLuaInterpreter() override {}
+
+private:
+  Lua m_lua;
+};
+
 ScriptInterpreterLua::ScriptInterpreterLua(Debugger &debugger)
 : ScriptInterpreter(debugger, eScriptLanguageLua) {}
 
 ScriptInterpreterLua::~ScriptInterpreterLua() {}
 
 bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
-  CommandReturnObject *,
-  const ExecuteScriptOptions &) {
-  m_debugger.GetErrorStream().PutCString(
-  "error: the lua script interpreter is not yet implemented.\n");
+  CommandReturnObject *result,
+  const ExecuteScriptOptions &options) {
+  Lua l;
+
+  // FIXME: Redirecting stdin, stdout and stderr.
+  int error =
+  luaL_loadbuffer(l.State(), command.data(), command.size(), "line") ||
+  lua_pcall(l.State(), 0, 0, 0);
+  if (error == 0)
+return true;
+
+  result->AppendErrorWithFormatv("lua failed attempting to evaluate '{0}'\n",
+ command);
   return false;
 }
 
 void ScriptInterpreterLua::ExecuteInterpreterLoop() {
-  m_debugger.GetErrorStream().PutCString(
-  "error: the lua script interpreter is not yet implemented.\n");
+  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+  Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
+
+  Debugger &debugger = m_debugger;
+
+  // At the moment, the only time the debugger does not have an input file
+  // handle is when this is called directly from lua, in which case it is
+  // both dangerous and unnecessary (not to mention confusing) to try to embed
+  // a running interpreter loop inside the already running lua interpreter
+  // loop, so we won't do it.
+
+  if (!debugger.GetInputFile().IsValid())
+return;
+
+  IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(debugger));
+  if (io_handler_sp) {
+debugger.PushIOHandler(io_handler_sp);
+  }
 }
 
 void ScriptInterpreterLua::Initialize() {
Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -4,4 +4,8 @@
   LINK_LIBS
 lldbCore
 lldbInterpreter
-  )
\ No newline at end of file
+  )
+
+find_package(Lua REQUIRED)
+target_include_directories(lldbPluginScriptInterpreterLua PRIVATE ${LUA_INCLUDE_DIR})
+target_link_libraries(lldbPluginScriptInterpreterLua PRIVATE ${LUA_LIBRARIES})
Index: lldb/include/lldb/Core/IOHandler.h
=

[Lldb-commits] [PATCH] D71310: RFC: Remove "Validators"

2019-12-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Adrian and I talked about this some more.  Apparently the idea was that you 
have some type Foo and you want to look for some error state in instances of 
that type (Foo::a + Foo::b < 10).  So you add a Type Validator for Foo that 
does this check, and every time lldb prints a variable of type Foo, it will run 
the Validator on it, and if it fails validation, then the printer will print an 
! at the beginning of the printing, and also there's an SB API to get whether 
the Value passed the validator.

So then you could just debug along, and either look for the ! in the printing, 
or add a stop hook that checks the Validator result on all locals, and if you 
ever saw the error state, you would know to investigate further.  That's 
actually a pretty neat idea.

The current state of the code is that there is actually no way to add a Type 
Validator.  To be really useful, there would need to be a way to create a 
scripted validator, so the Python bindings and some command/SB API to register 
the validator.

The implementation is a little cut-and-paste too.  It shares all the same 
options with the Synthetic child provider & Summaries (skips pointers, cascade, 
etc.) but I don't think you would ever want a type validator that would only 
validate references to a type, but not the type itself.  And then the 
implementation is very cut & paste.  So I'm fine with deleting this for now, 
but maybe adding it as an interesting project idea to the Projects page - with 
a reference to the hash of this commit as a starting point?

It's a neat idea but it's also been 5 years now and it was never made useful...


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

https://reviews.llvm.org/D71310



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


[Lldb-commits] [PATCH] D71313: [AST] Split parent map traversal logic into ParentMapContext.h

2019-12-10 Thread Reid Kleckner via Phabricator via lldb-commits
rnk created this revision.
rnk added reviewers: bkramer, klimek, rsmith.
Herald added subscribers: lldb-commits, kbarton, mgorny, nemanjai.
Herald added projects: clang, LLDB.

The only part of ASTContext.h that requires most AST types to be
complete is the parent map. Nothing in Clang proper uses the ParentMap,
so split it out into its own class. Make ASTContext own the
ParentMapContext so there is still a one-to-one relationship.

After this change, 562 fewer files depend on ASTTypeTraits.h, and 66
fewer depend on TypeLoc.h:

  $ diff -u deps-before.txt deps-after.txt | \
grep '^[-+] ' | sort | uniq -c | sort -nr | less
  562 -../clang/include/clang/AST/ASTTypeTraits.h
  340 +../clang/include/clang/AST/ParentMapContext.h
   66 -../clang/include/clang/AST/TypeLocNodes.def
   66 -../clang/include/clang/AST/TypeLoc.h
   15 -../clang/include/clang/AST/TemplateBase.h
  ...

I computed deps-before.txt and deps-after.txt with `ninja -t deps`.

This removes a common and key dependency on TemplateBase.h and
TypeLoc.h.

This also has the effect of breaking the ParentMap RecursiveASTVisitor
instantiation into its own file, which roughly halves the compilation
time of ASTContext.cpp (29.75s -> 17.66s). The new file takes 13.8s to
compile.

I left behind forwarding methods for getParents(), but clients will need
to include a new header to make them work:

  #include "clang/AST/ParentMapContext.h"

I noticed that this parent map functionality is unfortunately duplicated
in ParentMap.h, which only works for Stmt nodes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71313

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ParentMapContext.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Linkage.h
  clang/lib/AST/ParentMapContext.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/Tooling/ASTDiff/ASTDiff.cpp
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  lldb/include/lldb/Symbol/ClangASTContext.h

Index: lldb/include/lldb/Symbol/ClangASTContext.h
===
--- lldb/include/lldb/Symbol/ClangASTContext.h
+++ lldb/include/lldb/Symbol/ClangASTContext.h
@@ -21,6 +21,7 @@
 #include 
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTFwd.h"
 #include "clang/AST/ExternalASTMerger.h"
 #include "clang/AST/TemplateBase.h"
 #include "llvm/ADT/APSInt.h"
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -15,6 +15,7 @@
 
 #include "clang/Tooling/Refactoring/Rename/USRLocFinder.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
Index: clang/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/Tooling/ASTDiff/ASTDiff.h"
 
+#include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/PriorityQueue.h"
Index: clang/lib/CodeGen/CGCall.h
===
--- clang/lib/CodeGen/CGCall.h
+++ clang/lib/CodeGen/CGCall.h
@@ -16,6 +16,7 @@
 
 #include "CGValue.h"
 #include "EHScopeStack.h"
+#include "clang/AST/ASTFwd.h"
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/AST/Type.h"
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/ParentMapContext.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/LLVM.h"
@@ -222,7 +223,8 @@
   TraversalKindScope RAII(Finder->getASTContext(),
   Implementation->TraversalKind());
 
-  auto N = Finder->getASTContext().traverseIgnored(DynNode);
+  auto N =
+  Finder->getASTContext().getParentMapContext().traverseIgnored(DynNode);
 
   if (RestrictKind.isB

[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 233219.
JDevlieghere added a comment.

^ updated the wrong patch


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

https://reviews.llvm.org/D71232

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Interpreter/OptionArgParser.cpp
  lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h

Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -0,0 +1,47 @@
+//===-- ScriptInterpreterLua.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ScriptInterpreterLua_h_
+#define liblldb_ScriptInterpreterLua_h_
+
+#include "lldb/Interpreter/ScriptInterpreter.h"
+
+namespace lldb_private {
+
+class ScriptInterpreterLua : public ScriptInterpreter {
+public:
+  ScriptInterpreterLua(Debugger &debugger);
+
+  ~ScriptInterpreterLua() override;
+
+  bool ExecuteOneLine(
+  llvm::StringRef command, CommandReturnObject *result,
+  const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
+
+  void ExecuteInterpreterLoop() override;
+
+  // Static Functions
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger);
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static const char *GetPluginDescriptionStatic();
+
+  // PluginInterface protocol
+  lldb_private::ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ScriptInterpreterLua_h_
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -0,0 +1,71 @@
+//===-- ScriptInterpreterLua.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ScriptInterpreterLua.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
+
+#include "llvm/Support/Threading.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+ScriptInterpreterLua::ScriptInterpreterLua(Debugger &debugger)
+: ScriptInterpreter(debugger, eScriptLanguageLua) {}
+
+ScriptInterpreterLua::~ScriptInterpreterLua() {}
+
+bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
+  CommandReturnObject *,
+  const ExecuteScriptOptions &) {
+  m_debugger.GetErrorStream().PutCString(
+  "error: the lua script interpreter is not yet implemented.\n");
+  return false;
+}
+
+void ScriptInterpreterLua::ExecuteInterpreterLoop() {
+  m_debugger.GetErrorStream().PutCString(
+  "error: the lua script interpreter is not yet implemented.\n");
+}
+
+void ScriptInterpreterLua::Initialize() {
+  static llvm::once_flag g_once_flag;
+
+  llvm::call_once(g_once_flag, []() {
+PluginManager::RegisterPlugin(GetPluginNameStatic(),
+  GetPluginDescriptionStatic(),
+  lldb::eScriptLanguageLua, CreateInstance);
+  });
+}
+
+void ScriptInterpreterLua::Terminate() {}
+
+lldb::ScriptInterpreterSP
+ScriptInterpreterLua::CreateInstance(Debugger &debugger) {
+  return std::make_shared(debugger);
+}
+
+lldb_private::ConstString ScriptInterpreterLua::GetPluginNameStatic() {
+  static ConstString g_name("script-lua");
+  return g_name;
+}
+
+const char *ScriptInterpreterLua::GetPluginDescriptionStatic() {
+  return "Lua script interpreter";
+}
+
+lldb_private::ConstString ScriptInterpreterLua::GetPluginName() {
+  return GetPluginNameStatic();
+}
+
+uint32_t ScriptInterpreterLua::GetPluginVersion() { return 1; }
Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
==

[Lldb-commits] [PATCH] D71310: RFC: Remove "Validators"

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In D71310#1778534 , @jingham wrote:

> Adrian and I talked about this some more.  Apparently the idea was that you 
> have some type Foo and you want to look for some error state in instances of 
> that type (Foo::a + Foo::b < 10).  So you add a Type Validator for Foo that 
> does this check, and every time lldb prints a variable of type Foo, it will 
> run the Validator on it, and if it fails validation, then the printer will 
> print an ! at the beginning of the printing, and also there's an SB API to 
> get whether the Value passed the validator.
>
> So then you could just debug along, and either look for the ! in the 
> printing, or add a stop hook that checks the Validator result on all locals, 
> and if you ever saw the error state, you would know to investigate further.  
> That's actually a pretty neat idea.
>
> The current state of the code is that there is actually no way to add a Type 
> Validator.  To be really useful, there would need to be a way to create a 
> scripted validator, so the Python bindings and some command/SB API to 
> register the validator.
>
> The implementation is a little cut-and-paste too.  It shares all the same 
> options with the Synthetic child provider & Summaries (skips pointers, 
> cascade, etc.) but I don't think you would ever want a type validator that 
> would only validate references to a type, but not the type itself.  And then 
> the implementation is very cut & paste.  So I'm fine with deleting this for 
> now, but maybe adding it as an interesting project idea to the Projects page 
> - with a reference to the hash of this commit as a starting point?
>
> It's a neat idea but it's also been 5 years now and it was never made 
> useful...


+1. This code can be resurrected as-needed.


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

https://reviews.llvm.org/D71310



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


[Lldb-commits] [PATCH] D71296: Replace redundant code in LanguageCategory with templates (NFC)

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM, in the same vein as D71231 .


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

https://reviews.llvm.org/D71296



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


[Lldb-commits] [PATCH] D71234: [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype

2019-12-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 233220.
JDevlieghere added a comment.

Reuse IOHandlerEditline


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

https://reviews.llvm.org/D71234

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -10,32 +10,110 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StringList.h"
-
+#include "lldb/Utility/Timer.h"
 #include "llvm/Support/Threading.h"
 
+#ifndef LLDB_DISABLE_LIBEDIT
+#include "lldb/Host/Editline.h"
+#endif
+
+#include "lua.hpp"
+
+#define LUA_PROMPT ">>> "
+
 #include 
 
 using namespace lldb;
 using namespace lldb_private;
 
+class Lua {
+public:
+  Lua() : m_lua_state(luaL_newstate()) {
+assert(m_lua_state);
+luaL_openlibs(m_lua_state);
+  }
+  ~Lua() {
+assert(m_lua_state);
+luaL_openlibs(m_lua_state);
+  }
+
+  lua_State *State() { return m_lua_state; }
+
+private:
+  lua_State *m_lua_state = nullptr;
+};
+
+class IOHandlerLuaInterpreter : public IOHandlerDelegate,
+public IOHandlerEditline {
+public:
+  IOHandlerLuaInterpreter(Debugger &debugger)
+  : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
+  ">>> ", "..> ", true, debugger.GetUseColor(), 0,
+  *this, nullptr),
+m_lua() {}
+
+  void IOHandlerInputComplete(IOHandler &io_handler,
+  std::string &data) override {
+int error =
+luaL_loadbuffer(m_lua.State(), data.c_str(), data.size(), "line") ||
+lua_pcall(m_lua.State(), 0, 0, 0);
+if (error) {
+  fprintf(GetOutputFILE(), "%s\n", lua_tostring(m_lua.State(), -1));
+  // Pop error message from the stack.
+  lua_pop(m_lua.State(), 1);
+}
+  }
+
+  ~IOHandlerLuaInterpreter() override {}
+
+private:
+  Lua m_lua;
+};
+
 ScriptInterpreterLua::ScriptInterpreterLua(Debugger &debugger)
 : ScriptInterpreter(debugger, eScriptLanguageLua) {}
 
 ScriptInterpreterLua::~ScriptInterpreterLua() {}
 
 bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
-  CommandReturnObject *,
-  const ExecuteScriptOptions &) {
-  m_debugger.GetErrorStream().PutCString(
-  "error: the lua script interpreter is not yet implemented.\n");
+  CommandReturnObject *result,
+  const ExecuteScriptOptions &options) {
+  Lua l;
+
+  // FIXME: Redirecting stdin, stdout and stderr.
+  int error =
+  luaL_loadbuffer(l.State(), command.data(), command.size(), "line") ||
+  lua_pcall(l.State(), 0, 0, 0);
+  if (error == 0)
+return true;
+
+  result->AppendErrorWithFormatv("lua failed attempting to evaluate '{0}'\n",
+ command);
   return false;
 }
 
 void ScriptInterpreterLua::ExecuteInterpreterLoop() {
-  m_debugger.GetErrorStream().PutCString(
-  "error: the lua script interpreter is not yet implemented.\n");
+  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+  Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
+
+  Debugger &debugger = m_debugger;
+
+  // At the moment, the only time the debugger does not have an input file
+  // handle is when this is called directly from lua, in which case it is
+  // both dangerous and unnecessary (not to mention confusing) to try to embed
+  // a running interpreter loop inside the already running lua interpreter
+  // loop, so we won't do it.
+
+  if (!debugger.GetInputFile().IsValid())
+return;
+
+  IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(debugger));
+  if (io_handler_sp) {
+debugger.PushIOHandler(io_handler_sp);
+  }
 }
 
 void ScriptInterpreterLua::Initialize() {
Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -4,4 +4,8 @@
   LINK_LIBS
 lldbCore
 lldbInterpreter
-  )
\ No newline at end of file
+  )
+
+find_package(Lua REQUIRED)
+target_include_directories(lldbPluginScriptInterpreterLua PRIVATE ${LUA_INCLUDE_DIR})
+target_link_libraries(lldbPluginScriptInterpreterLua PRIVATE ${LUA_LIBRARIES})
Index: lldb/include/lldb/Core/IOHandler.h
===
--

[Lldb-commits] [lldb] b3801de - Replace redundant code in LanguageCategory with templates (NFC)

2019-12-10 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-12-10T16:11:10-08:00
New Revision: b3801de7c50faa2b730e62e1cfabeec8c5cebae2

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

LOG: Replace redundant code in LanguageCategory with templates (NFC)

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

Added: 


Modified: 
lldb/include/lldb/DataFormatters/LanguageCategory.h
lldb/source/DataFormatters/LanguageCategory.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/LanguageCategory.h 
b/lldb/include/lldb/DataFormatters/LanguageCategory.h
index f109d46194ad..c6604ec80fad 100644
--- a/lldb/include/lldb/DataFormatters/LanguageCategory.h
+++ b/lldb/include/lldb/DataFormatters/LanguageCategory.h
@@ -25,27 +25,11 @@ class LanguageCategory {
 
   LanguageCategory(lldb::LanguageType lang_type);
 
-  bool Get(FormattersMatchData &match_data, lldb::TypeFormatImplSP &format_sp);
-
-  bool Get(FormattersMatchData &match_data, lldb::TypeSummaryImplSP 
&format_sp);
-
-  bool Get(FormattersMatchData &match_data,
-   lldb::SyntheticChildrenSP &format_sp);
-
-  bool Get(FormattersMatchData &match_data,
-   lldb::TypeValidatorImplSP &format_sp);
-
-  bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
-lldb::TypeFormatImplSP &format_sp);
-
+  template 
+  bool Get(FormattersMatchData &match_data, ImplSP &format_sp);
+  template 
   bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
-lldb::TypeSummaryImplSP &format_sp);
-
-  bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
-lldb::SyntheticChildrenSP &format_sp);
-
-  bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
-lldb::TypeValidatorImplSP &format_sp);
+ImplSP &format_sp);
 
   lldb::TypeCategoryImplSP GetCategory() const;
 
@@ -65,6 +49,9 @@ class LanguageCategory {
   HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
   HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
 
+  template 
+  auto &GetHardcodedFinder();
+
   lldb_private::FormatCache m_format_cache;
 
   bool m_enabled;

diff  --git a/lldb/source/DataFormatters/LanguageCategory.cpp 
b/lldb/source/DataFormatters/LanguageCategory.cpp
index 86de28060254..78237e18fb20 100644
--- a/lldb/source/DataFormatters/LanguageCategory.cpp
+++ b/lldb/source/DataFormatters/LanguageCategory.cpp
@@ -34,8 +34,9 @@ LanguageCategory::LanguageCategory(lldb::LanguageType 
lang_type)
   Enable();
 }
 
+template
 bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeFormatImplSP &format_sp) {
+   ImplSP &retval_sp) {
   if (!m_category_sp)
 return false;
 
@@ -43,168 +44,90 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
 return false;
 
   if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
+if (m_format_cache.Get(match_data.GetTypeForCache(), retval_sp))
+  return (bool)retval_sp;
   }
 
   ValueObject &valobj(match_data.GetValueObject());
   bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
-   match_data.GetMatchesVector(), format_sp);
+   match_data.GetMatchesVector(), retval_sp);
   if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
+  (!retval_sp || !retval_sp->NonCacheable())) {
+m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
   }
   return result;
 }
 
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeSummaryImplSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
-   match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
-}
-
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::SyntheticChildrenSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-   

[Lldb-commits] [lldb] 2fb07b9 - Remove unsound caching in LanguageCategory

2019-12-10 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-12-10T16:11:10-08:00
New Revision: 2fb07b90dc1c2c08fe6fc69c9d569a1fc2c8a8e1

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

LOG: Remove unsound caching in LanguageCategory

Analogous to https://reviews.llvm.org/D71233 it is not safe to cache
something that depends on the actual ValueObject in a cache then keys
only off the type name.

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

Added: 


Modified: 
lldb/source/DataFormatters/LanguageCategory.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/LanguageCategory.cpp 
b/lldb/source/DataFormatters/LanguageCategory.cpp
index 78237e18fb20..d4d8bb9cc8d6 100644
--- a/lldb/source/DataFormatters/LanguageCategory.cpp
+++ b/lldb/source/DataFormatters/LanguageCategory.cpp
@@ -110,10 +110,6 @@ bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
   break;
 }
   }
-  if (match_data.GetTypeForCache() &&
-  (!retval_sp || !retval_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
-  }
   return (bool)retval_sp;
 }
 



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


[Lldb-commits] [PATCH] D71311: LanguageRuntime: Simplify NSException::GetSummary() output

2019-12-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/source/Plugins/Language/ObjC/NSException.cpp:107-109
+  if (NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
+  !reason_str_summary.Empty()) {
+stream.Printf("%s", reason_str_summary.GetData());

I wonder if it would be better to print "No reason" as the summary when there's 
not a reason string?  Having the summary generally be there, but then not be 
there at all when the exception wasn't given a reason string, is a little 
disconcerting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71311



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


[Lldb-commits] [PATCH] D71296: Replace redundant code in LanguageCategory with templates (NFC)

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3801de7c50f: Replace redundant code in LanguageCategory 
with templates (NFC) (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D71296?vs=233179&id=233222#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71296

Files:
  lldb/include/lldb/DataFormatters/LanguageCategory.h
  lldb/source/DataFormatters/LanguageCategory.cpp

Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -34,8 +34,9 @@
   Enable();
 }
 
+template
 bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeFormatImplSP &format_sp) {
+   ImplSP &retval_sp) {
   if (!m_category_sp)
 return false;
 
@@ -43,168 +44,90 @@
 return false;
 
   if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
+if (m_format_cache.Get(match_data.GetTypeForCache(), retval_sp))
+  return (bool)retval_sp;
   }
 
   ValueObject &valobj(match_data.GetValueObject());
   bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
-   match_data.GetMatchesVector(), format_sp);
+   match_data.GetMatchesVector(), retval_sp);
   if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
+  (!retval_sp || !retval_sp->NonCacheable())) {
+m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
   }
   return result;
 }
 
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeSummaryImplSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
-   match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
-}
-
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::SyntheticChildrenSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
-   match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
+/// Explicit instantiations for the four types.
+/// \{
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+ lldb::TypeValidatorImplSP &);
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+  lldb::TypeFormatImplSP &);
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+   lldb::TypeSummaryImplSP &);
+template bool
+LanguageCategory::Get(FormattersMatchData &,
+ lldb::SyntheticChildrenSP &);
+/// \}
+
+template <>
+auto &LanguageCategory::GetHardcodedFinder() {
+  return m_hardcoded_formats;
 }
 
-bool LanguageCategory::Get(FormattersMatchData &match_data,
-   lldb::TypeValidatorImplSP &format_sp) {
-  if (!m_category_sp)
-return false;
-
-  if (!IsEnabled())
-return false;
-
-  if (match_data.GetTypeForCache()) {
-if (m_format_cache.Get(match_data.GetTypeForCache(), format_sp))
-  return format_sp.get() != nullptr;
-  }
-
-  ValueObject &valobj(match_data.GetValueObject());
-  bool result = m_category_sp->Get(valobj.GetObjectRuntimeLanguage(),
-   match_data.GetMatchesVector(), format_sp);
-  if (match_data.GetTypeForCache() &&
-  (!format_sp || !format_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), format_sp);
-  }
-  return result;
+template <>
+auto &LanguageCategory::GetHardcodedFinder() {
+  ret

[Lldb-commits] [PATCH] D71297: Remove unsound caching in LanguageCategory

2019-12-10 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2fb07b90dc1c: Remove unsound caching in LanguageCategory 
(authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71297

Files:
  lldb/source/DataFormatters/LanguageCategory.cpp


Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -110,10 +110,6 @@
   break;
 }
   }
-  if (match_data.GetTypeForCache() &&
-  (!retval_sp || !retval_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
-  }
   return (bool)retval_sp;
 }
 


Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -110,10 +110,6 @@
   break;
 }
   }
-  if (match_data.GetTypeForCache() &&
-  (!retval_sp || !retval_sp->NonCacheable())) {
-m_format_cache.Set(match_data.GetTypeForCache(), retval_sp);
-  }
   return (bool)retval_sp;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71311: LanguageRuntime: Simplify NSException::GetSummary() output

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide added inline comments.



Comment at: lldb/source/Plugins/Language/ObjC/NSException.cpp:107-109
+  if (NSStringSummaryProvider(*reason_sp, reason_str_summary, options) &&
+  !reason_str_summary.Empty()) {
+stream.Printf("%s", reason_str_summary.GetData());

jingham wrote:
> I wonder if it would be better to print "No reason" as the summary when 
> there's not a reason string?  Having the summary generally be there, but then 
> not be there at all when the exception wasn't given a reason string, is a 
> little disconcerting.
Arguably.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71311



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


[Lldb-commits] [PATCH] D71316: [FormatManager] Upstream and test swift bits for GetCandidateLanguages().

2019-12-10 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: teemperor, aprantl, labath, friss, jingham.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71316

Files:
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/unittests/DataFormatter/FormatManagerTests.cpp


Index: lldb/unittests/DataFormatter/FormatManagerTests.cpp
===
--- lldb/unittests/DataFormatter/FormatManagerTests.cpp
+++ lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -43,7 +43,11 @@
   EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_14),
 candidates);
 
-  candidates = {eLanguageTypeObjC};
+  candidates = {eLanguageTypeObjC, eLanguageTypeSwift};
   EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeObjC),
 candidates);
+
+  candidates = {eLanguageTypeSwift, eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeSwift),
+candidates);
 }
Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -582,6 +582,10 @@
 std::vector
 FormatManager::GetCandidateLanguages(lldb::LanguageType lang_type) {
   switch (lang_type) {
+  case lldb::eLanguageTypeSwift:
+return {lldb::eLanguageTypeSwift, lldb::eLanguageTypeObjC};
+  case lldb::eLanguageTypeObjC:
+return {lldb::eLanguageTypeObjC, lldb::eLanguageTypeSwift};
   case lldb::eLanguageTypeC:
   case lldb::eLanguageTypeC89:
   case lldb::eLanguageTypeC99:


Index: lldb/unittests/DataFormatter/FormatManagerTests.cpp
===
--- lldb/unittests/DataFormatter/FormatManagerTests.cpp
+++ lldb/unittests/DataFormatter/FormatManagerTests.cpp
@@ -43,7 +43,11 @@
   EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_14),
 candidates);
 
-  candidates = {eLanguageTypeObjC};
+  candidates = {eLanguageTypeObjC, eLanguageTypeSwift};
   EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeObjC),
 candidates);
+
+  candidates = {eLanguageTypeSwift, eLanguageTypeObjC};
+  EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeSwift),
+candidates);
 }
Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -582,6 +582,10 @@
 std::vector
 FormatManager::GetCandidateLanguages(lldb::LanguageType lang_type) {
   switch (lang_type) {
+  case lldb::eLanguageTypeSwift:
+return {lldb::eLanguageTypeSwift, lldb::eLanguageTypeObjC};
+  case lldb::eLanguageTypeObjC:
+return {lldb::eLanguageTypeObjC, lldb::eLanguageTypeSwift};
   case lldb::eLanguageTypeC:
   case lldb::eLanguageTypeC89:
   case lldb::eLanguageTypeC99:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71319: [lldb][dotest] Improve libc++ detection

2019-12-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: labath.
Herald added a reviewer: EricWF.
Herald added subscribers: lldb-commits, ldionne.
Herald added a project: LLDB.

The test logic for running libc++ tests only looks to see if 
`/usr/include/c++/v1` exists. This adds a fallback for including libc++ tests 
as long as `$(CC) -stdlib=libc++` works.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71319

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
 return True, "libc++ always present"
 
 if platform == "linux":
-if not os.path.isdir("/usr/include/c++/v1"):
-return False, "Unable to find libc++ installation"
-return True, "Headers found, let's hope they work"
+if os.path.isdir("/usr/include/c++/v1"):
+return True, "Headers found, let's hope they work"
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", 
f.name, "-"]
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:
+return True, "Compiling with -stdlib=libc++ works"
+return False, "Compiling with -stdlib=libc++ fails with the error: 
%s" % stderr
 
 return False, "Don't know how to build with libc++ on %s" % platform
 


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
 return True, "libc++ always present"
 
 if platform == "linux":
-if not os.path.isdir("/usr/include/c++/v1"):
-return False, "Unable to find libc++ installation"
-return True, "Headers found, let's hope they work"
+if os.path.isdir("/usr/include/c++/v1"):
+return True, "Headers found, let's hope they work"
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:
+return True, "Compiling with -stdlib=libc++ works"
+return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
 
 return False, "Don't know how to build with libc++ on %s" % platform
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >