[Lldb-commits] [PATCH] D93663: [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

2020-12-22 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

You can't put these declarations inside `do {} while(0)` -- the additional 
scope works against us in this case, and forces a premature timer termination. 
Other than that, this seems fine...


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

https://reviews.llvm.org/D93663

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


[Lldb-commits] [lldb] 0a8a245 - [lldb/test] Add GdbRemoteTestCaseFactory to avoid duplication in lldb-server tests

2020-12-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-12-22T10:07:47+01:00
New Revision: 0a8a2453fb843cf2e0f43e389b58d516525f0b8c

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

LOG: [lldb/test] Add GdbRemoteTestCaseFactory to avoid duplication in 
lldb-server tests

This uses the same approach as the debug info tests to avoid needing to
explicitly spell out the two kinds of tests. I convert a handful of
tests to the new mechanism. The rest will be converted in follow-up
patches.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py
lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
lldb/test/API/tools/lldb-server/TestGdbRemoteSingleStep.py
lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index a17cd6ea33ab..ff445fa0b926 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -373,13 +373,11 @@ def should_skip_simulator_test():
 
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
-func.debug_server = "debugserver"
 return add_test_categories(["debugserver"])(func)
 
 
 def llgs_test(func):
 """Decorate the item as a lldb-server test."""
-func.debug_server = "llgs"
 return add_test_categories(["llgs"])(func)
 
 

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 0e3cde01520a..d9289251d89d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -27,6 +27,39 @@ class _ConnectionRefused(IOError):
 pass
 
 
+class GdbRemoteTestCaseFactory(type):
+
+def __new__(cls, name, bases, attrs):
+newattrs = {}
+for attrname, attrvalue in attrs.items():
+if not attrname.startswith("test"):
+newattrs[attrname] = attrvalue
+continue
+
+# If any debug server categories were explicitly tagged, assume
+# that list to be authoritative. If none were specified, try
+# all of them.
+all_categories = set(["debugserver", "llgs"])
+categories = set(
+getattr(attrvalue, "categories", [])) & all_categories
+if not categories:
+categories = all_categories
+
+for cat in categories:
+@decorators.add_test_categories([cat])
+@wraps(attrvalue)
+def test_method(self, attrvalue=attrvalue):
+return attrvalue(self)
+
+method_name = attrname + "_" + cat
+test_method.__name__ = method_name
+test_method.debug_server = cat
+newattrs[method_name] = test_method
+
+return super(GdbRemoteTestCaseFactory, cls).__new__(
+cls, name, bases, newattrs)
+
+@add_metaclass(GdbRemoteTestCaseFactory)
 class GdbRemoteTestCaseBase(Base):
 
 # Default time out in seconds. The timeout is increased tenfold under Asan.

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
index 96ebbfb09bdc..b42f8431c51e 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
@@ -12,46 +12,23 @@ class TestGdbRemoteExitCode(GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def inferior_exit_0(self):
-self.prep_debug_monitor_and_inferior()
-self.test_sequence.add_log_lines(
-["read packet: $vCont;c#a8",
- "send packet: $W00#00"],
-True)
-
-self.expect_gdbremote_sequence()
-
-@debugserver_test
-@skipIfDarwinEmbedded #  lldb-server tests not 
updated to work on ios etc yet
-def test_inferior_exit_0_debugserver(self):
+def _test_inferior_exit(self, retval):
 self.build()
-self.inferior_exit_0()
-
-@llgs_test
-def test_inferior_exit_0_llgs(self):
-self.build()
-self.inferior_exit_0()
-
-def inferior_exit_42(self):
-RETVAL = 42
 
 procs = self.prep_debug_monitor_and_inferi

[Lldb-commits] [PATCH] D93495: CrashReason: Add MTE tag check faults to the list of crash reasons.

2020-12-22 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Great, thanks for the explanation.

I don't think this needs a test since (for now) it acts just like existing 
signals.

The change looks good to me but @labath should approve since I don't know all 
the signal handling details.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93495

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


[Lldb-commits] [PATCH] D93690: Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat created this revision.
werat requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add a method to check if the type is a scoped enumeration (i.e. "enum 
class/struct").


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93690

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -29,6 +29,8 @@
 {}
 };
 
+enum EnumType {};
+enum class ScopedEnumType {};
 
 int main (int argc, char const *argv[])
 {
@@ -59,5 +61,8 @@
 typedef int myint;
 myint myint_arr[] = {1, 2, 3};
 
+EnumType enum_type;
+ScopedEnumType scoped_enum_type;
+
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -144,3 +144,13 @@
 myint_type = target.FindFirstType('myint')
 self.DebugSBType(myint_type)
 self.assertTrue(myint_arr_element_type == myint_type)
+
+# Test enum methods.
+enum_type = target.FindFirstType('EnumType')
+self.assertTrue(enum_type)
+self.DebugSBType(enum_type)
+self.assertFalse(enum_type.IsScopedEnumerationType())
+scoped_enum_type = target.FindFirstType('ScopedEnumType')
+self.assertTrue(scoped_enum_type)
+self.DebugSBType(scoped_enum_type)
+self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -40,6 +40,12 @@
   return false;
 }
 
+bool CompilerType::IsScopedEnumerationType() const {
+  if (IsValid())
+return m_type_system->IsScopedEnumerationType(m_type);
+  return false;
+}
+
 bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size,
bool *is_incomplete) const {
   if (IsValid())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -612,6 +612,8 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool &is_signed) override;
 
+  bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
+
   static bool IsObjCClassType(const CompilerType &type);
 
   static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3141,6 +3141,20 @@
   return false;
 }
 
+bool TypeSystemClang::IsScopedEnumerationType(
+lldb::opaque_compiler_type_t type) {
+  if (type) {
+const clang::EnumType *enum_type = llvm::dyn_cast(
+GetCanonicalQualType(type)->getCanonicalTypeInternal());
+
+if (enum_type) {
+  return enum_type->isScopedEnumeralType();
+}
+  }
+
+  return false;
+}
+
 bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type,
 CompilerType *pointee_type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -271,6 +271,14 @@
   return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
 }
 
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+
+  if (!IsValid())
+return false;
+  return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
+}
+
 lldb::SBType SBType::GetFunctionReturnType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
 
Index: lldb/include/lldb/Symbol/TypeSystem.h
===
--- lldb/include/lldb/Symbol/TypeSystem.h
+++ lldb/include/lldb/Symbol/TypeSystem.h
@@ -176,6 +176,8 @@
 return false;
   }
 
+  virtual bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) = 0;
+
   virtual bool IsPossibleDynamicType(lldb::opaque_com

[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat created this revision.
werat requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add a method for getting the enumeration underlying type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93696

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -31,6 +31,7 @@
 
 enum EnumType {};
 enum class ScopedEnumType {};
+enum class EnumUChar : unsigned char {};
 
 int main (int argc, char const *argv[])
 {
@@ -63,6 +64,7 @@
 
 EnumType enum_type;
 ScopedEnumType scoped_enum_type;
+EnumUChar scoped_enum_type_uchar;
 
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -150,7 +150,24 @@
 self.assertTrue(enum_type)
 self.DebugSBType(enum_type)
 self.assertFalse(enum_type.IsScopedEnumerationType())
+int_enum_type = enum_type.GetEnumerationIntegerType()
+self.assertTrue(int_enum_type)
+self.DebugSBType(int_enum_type)
+self.assertEquals(int_enum_type.GetName(), 'unsigned int')
+
 scoped_enum_type = target.FindFirstType('ScopedEnumType')
 self.assertTrue(scoped_enum_type)
 self.DebugSBType(scoped_enum_type)
 self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
+self.assertTrue(int_scoped_enum_type)
+self.DebugSBType(int_scoped_enum_type)
+self.assertEquals(int_scoped_enum_type.GetName(), 'int')
+
+enum_uchar = target.FindFirstType('EnumUChar')
+self.assertTrue(enum_uchar)
+self.DebugSBType(enum_uchar)
+int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
+self.assertTrue(int_enum_uchar)
+self.DebugSBType(int_enum_uchar)
+self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -350,6 +350,12 @@
   return CompilerType();
 }
 
+CompilerType CompilerType::GetEnumerationIntegerType() const {
+  if (IsValid())
+return m_type_system->GetEnumerationIntegerType(m_type);
+  return CompilerType();
+}
+
 int CompilerType::GetFunctionArgumentCount() const {
   if (IsValid()) {
 return m_type_system->GetFunctionArgumentCount(m_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -698,6 +698,9 @@
   CompilerType
   GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
 
+  CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override;
+
   // Returns -1 if this isn't a function of if the function doesn't have a
   // prototype Returns a value >= 0 if there is a prototype.
   int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4189,6 +4189,13 @@
   return CompilerType();
 }
 
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+  if (type)
+return GetEnumerationIntegerType(GetType(GetCanonicalQualType(type)));
+  return CompilerType();
+}
+
 int TypeSystemClang::GetFunctionArgumentCount(
 lldb::opaque_compiler_type_t type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -344,6 +344,16 @@
   return LLDB_RECORD_RESULT(SBType());
 }
 
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+  if (IsValid()) {
+return LLDB_RECORD_RESULT(
+SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+  }
+  return LLDB_RECORD_RESU

[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added reviewers: teemperor, JDevlieghere.
werat added a subscriber: jarin.
werat added inline comments.



Comment at: lldb/test/API/python_api/type/TestTypeList.py:156
+self.DebugSBType(int_enum_type)
+self.assertEquals(int_enum_type.GetName(), 'unsigned int')
+

Afaik this is implementation defined, so maybe this we shouldn't test this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

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


[Lldb-commits] [PATCH] D93621: [lldb][wasm] Parse DWO section names

2020-12-22 Thread Philip Pfaffe via Phabricator via lldb-commits
pfaffe updated this revision to Diff 313321.
pfaffe added a comment.

Add the new dwo sections to the testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93621

Files:
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml

Index: lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -40,6 +40,73 @@
 # CHECK: VM size: 0
 # CHECK: File size: 3
 
+# CHECK: Name: .debug_abbrev.dwo
+# CHECK: Type: dwarf-abbrev-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_info.dwo
+# CHECK: Type: dwarf-info-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_line.dwo
+# CHECK: Type: dwarf-line
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_line_str.dwo
+# CHECK: Type: dwarf-line-str
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_loc.dwo
+# CHECK: Type: dwarf-loc-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_loclists.dwo
+# CHECK: Type: dwarf-loclists-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_macro.dwo
+# CHECK: Type: dwarf-macro
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_rnglists.dwo
+# CHECK: Type: dwarf-rnglists-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_str.dwo
+# CHECK: Type: dwarf-str-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_str_offsets.dwo
+# CHECK: Type: dwarf-str-offsets-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+# CHECK: Name: .debug_types.dwo
+# CHECK: Type: dwarf-types-dwo
+# CHECK: VM address: 0x0
+# CHECK: VM size: 0
+# CHECK: File size: 4
+
+
 --- !WASM
 FileHeader:
   Version: 0x0001
@@ -64,4 +131,37 @@
   - Type:CUSTOM
 Name:.debug_str
 Payload: 636CFF
+  - Type:CUSTOM
+Name:.debug_abbrev.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_info.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_line.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_line_str.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_loc.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_loclists.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_macro.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_rnglists.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_str.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_str_offsets.dwo
+Payload: DEADBEEF
+  - Type:CUSTOM
+Name:.debug_types.dwo
+Payload: DEADBEEF
 ...
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -253,6 +253,43 @@
 
 Symtab *ObjectFileWasm::GetSymtab() { return nullptr; }
 
+static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
+  if (Name.consume_front(".debug_") || Name.consume_front(".zdebug_")) {
+return llvm::StringSwitch(Name)
+.Case("abbrev", eSectionTypeDWARFDebugAbbrev)
+.Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
+.Case("addr", eSectionTypeDWARFDebugAddr)
+.Case("aranges", eSectionTypeDWARFDebugAranges)
+.Case("cu_index", eSectionTypeDWARFDebugCuIndex)
+.Case("frame", eSectionTypeDWARFDebugFrame)
+.Case("info", eSectionTypeDWARFDebugInfo)
+.Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
+.Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
+.Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
+.Case("loc", eSectionTypeDWARFDebugLoc)
+.Case("loc.dwo", eSectionTypeDWARFDebugLocDwo)
+.Case("loclists", eSectionTypeDWARFDebugLocLists)
+.Case("loclists.dwo", eSectionTypeDWARFDebugLocListsDwo)
+.Case("macinfo", eSectionTypeDWARFDebugMacInfo)
+.Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
+.Case("names", eSectionTypeDWARFDebugNames)
+ 

[Lldb-commits] [PATCH] D93481: [lldb/Lua] add support for multiline scripted breakpoints

2020-12-22 Thread Pedro Tammela via Phabricator via lldb-commits
tammela added inline comments.



Comment at: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h:39
   llvm::Error LoadModule(llvm::StringRef filename);
+  llvm::Error LoadBuffer(llvm::StringRef buffer, bool pop_result = true);
   llvm::Error ChangeIO(FILE *out, FILE *err);

labath wrote:
> This default value does not seem particularly useful. In fact, I am not sure 
> if this argument should even exist at all. The usage in 
> `IOHandlerIsInputComplete` is sufficiently unorthodox that it might be a good 
> idea to draw attention to the fact that something funky is happening via an 
> explicit pop (and maybe a comment).
We can't explicitly pop, as in calling `lua_pop()`, from 
`ScriptInterpreterLua.cpp` because the `lua_State` is not exposed. Are you 
suggesting to add a method that wraps `lua_pop()` as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93481

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


[Lldb-commits] [PATCH] D93663: [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D93663#2467370 , @labath wrote:

> You can't put these declarations inside `do {} while(0)` -- the additional 
> scope works against us in this case, and forces a premature timer 
> termination. Other than that, this seems fine...

Wow, I totally did that on autopilot 🤡


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

https://reviews.llvm.org/D93663

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


[Lldb-commits] [lldb] 5c1c844 - [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

2020-12-22 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-12-22T09:10:27-08:00
New Revision: 5c1c8443eb7366e6e5086426b5d8dc7d24afc13b

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

LOG: [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

This patch introduces a LLDB_SCOPED_TIMER macro to hide the needlessly
repetitive creation of scoped timers in LLDB. It's similar to the
LLDB_LOG(F) macro.

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

Added: 


Modified: 
lldb/include/lldb/Utility/Timer.h
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Core/Mangled.cpp
lldb/source/Core/Module.cpp
lldb/source/Initialization/SystemInitializerCommon.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/source/Symbol/LocateSymbolFile.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/source/Symbol/Symtab.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetList.cpp
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Timer.h 
b/lldb/include/lldb/Utility/Timer.h
index f97315b2db0f..91f9c57c03c1 100644
--- a/lldb/include/lldb/Utility/Timer.h
+++ b/lldb/include/lldb/Utility/Timer.h
@@ -73,4 +73,11 @@ class Timer {
 
 } // namespace lldb_private
 
+#define LLDB_SCOPED_TIMER()
\
+  static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
+  ::lldb_private::Timer _scoped_timer(_cat, LLVM_PRETTY_FUNCTION)
+#define LLDB_SCOPED_TIMERF(...)
\
+  static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
+  ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__)
+
 #endif // LLDB_UTILITY_TIMER_H

diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index a6421d8f10d0..0530f94580b3 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -69,9 +69,6 @@ llvm::Error SystemInitializerFull::Initialize() {
 }
 
 void SystemInitializerFull::Terminate() {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
-
   Debugger::SettingsTerminate();
 
   // Terminate plug-ins in core LLDB

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index c033493d4196..4bce4e7e0734 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -299,8 +299,7 @@ class CommandObjectTargetCreate : public 
CommandObjectParsed {
   }
 
   const char *file_path = command.GetArgumentAtIndex(0);
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat, "(lldb) target create '%s'", file_path);
+  LLDB_SCOPED_TIMERF("(lldb) target create '%s'", file_path);
   FileSpec file_spec;
 
   if (file_path) {

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 1015eafd252e..3a975d9296f4 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -58,9 +58,7 @@ using namespace lldb_private;
 DisassemblerSP Disassembler::FindPlugin(const ArchSpec &arch,
 const char *flavor,
 const char *plugin_name) {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat,
- "Disassembler::FindPlugin (arch = %s, plugin_name = %s)",
+  LLDB_SCOPED_TIMERF("Disassembler::FindPlugin (arch = %s, plugin_name = %s)",
  

[Lldb-commits] [PATCH] D93663: [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c1c8443eb73: [lldb] Abstract scoped timer logic behind 
LLDB_SCOPED_TIMER (NFC) (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D93663?vs=313191&id=313366#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93663

Files:
  lldb/include/lldb/Utility/Timer.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/Mangled.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Initialization/SystemInitializerCommon.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
  lldb/source/Symbol/CompileUnit.cpp
  lldb/source/Symbol/DWARFCallFrameInfo.cpp
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetList.cpp
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -54,9 +54,6 @@
 }
 
 void SystemInitializerTest::Terminate() {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
-
   Debugger::SettingsTerminate();
 
   // Terminate and unload and loaded system or user LLDB plug-ins
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -286,10 +286,9 @@
 LoadDependentFiles load_dependent_files,
 lldb::PlatformSP &platform_sp,
 lldb::TargetSP &target_sp) {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(
-  func_cat, "TargetList::CreateTarget (file = '%s', arch = '%s')",
-  user_exe_path.str().c_str(), specified_arch.GetArchitectureName());
+  LLDB_SCOPED_TIMERF("TargetList::CreateTarget (file = '%s', arch = '%s')",
+ user_exe_path.str().c_str(),
+ specified_arch.GetArchitectureName());
   Status error;
   const bool is_dummy_target = false;
 
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1400,9 +1400,7 @@
   ClearModules(false);
 
   if (executable_sp) {
-static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-Timer scoped_timer(func_cat,
-   "Target::SetExecutableModule (executable = '%s')",
+LLDB_SCOPED_TIMERF("Target::SetExecutableModule (executable = '%s')",
executable_sp->GetFileSpec().GetPath().c_str());
 
 const bool notify = true;
Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -251,8 +251,7 @@
   // Protected function, no need to lock mutex...
   if (!m_name_indexes_computed) {
 m_name_indexes_computed = true;
-static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-Timer scoped_timer(func_cat, "%s", LLVM_PRETTY_FUNCTION);
+LLDB_SCOPED_TIMER();
 // Create the name index vector to be able to quickly search by name
 const size_t num_symbols = m_symbols.size();
 m_name_to_index.Reserve(num_symbols);
@@ -411,9 +410,8 @@
 void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes,
 bool add_demangled, bool add_mangled,
 NameToIndexMap &name_to_index_map) const {
+  LLDB_SCOPED_TIMER();
   if (add_demangled || add_mangled) {
-static Timer::Category func_cat(

[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBType.cpp:348
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+

You also need to register the new method. You can add the instrumentation 
automatically with the lldb-instr tool if you remove this line (and the 
`LLDB_RECORD_RESULT` or the return value will get wrapped again). 



Comment at: lldb/test/API/python_api/type/TestTypeList.py:156
+self.DebugSBType(int_enum_type)
+self.assertEquals(int_enum_type.GetName(), 'unsigned int')
+

werat wrote:
> Afaik this is implementation defined, so maybe this we shouldn't test this.
Yeah, I would either remove it or add a comment saying that it's implementation 
defined in case someone (downstream) runs into this. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

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


[Lldb-commits] [PATCH] D93690: Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBType.cpp:275
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+

Same comment as in D93696: you need to register your new method. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93690

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


[Lldb-commits] [PATCH] D93690: Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat updated this revision to Diff 313378.
werat added a comment.

Register the new method using lldb-instr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93690

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -29,6 +29,8 @@
 {}
 };
 
+enum EnumType {};
+enum class ScopedEnumType {};
 
 int main (int argc, char const *argv[])
 {
@@ -59,5 +61,8 @@
 typedef int myint;
 myint myint_arr[] = {1, 2, 3};
 
+EnumType enum_type;
+ScopedEnumType scoped_enum_type;
+
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -144,3 +144,13 @@
 myint_type = target.FindFirstType('myint')
 self.DebugSBType(myint_type)
 self.assertTrue(myint_arr_element_type == myint_type)
+
+# Test enum methods.
+enum_type = target.FindFirstType('EnumType')
+self.assertTrue(enum_type)
+self.DebugSBType(enum_type)
+self.assertFalse(enum_type.IsScopedEnumerationType())
+scoped_enum_type = target.FindFirstType('ScopedEnumType')
+self.assertTrue(scoped_enum_type)
+self.DebugSBType(scoped_enum_type)
+self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -40,6 +40,12 @@
   return false;
 }
 
+bool CompilerType::IsScopedEnumerationType() const {
+  if (IsValid())
+return m_type_system->IsScopedEnumerationType(m_type);
+  return false;
+}
+
 bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size,
bool *is_incomplete) const {
   if (IsValid())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -612,6 +612,8 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool &is_signed) override;
 
+  bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
+
   static bool IsObjCClassType(const CompilerType &type);
 
   static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3141,6 +3141,20 @@
   return false;
 }
 
+bool TypeSystemClang::IsScopedEnumerationType(
+lldb::opaque_compiler_type_t type) {
+  if (type) {
+const clang::EnumType *enum_type = llvm::dyn_cast(
+GetCanonicalQualType(type)->getCanonicalTypeInternal());
+
+if (enum_type) {
+  return enum_type->isScopedEnumeralType();
+}
+  }
+
+  return false;
+}
+
 bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type,
 CompilerType *pointee_type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -271,6 +271,14 @@
   return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
 }
 
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+
+  if (!IsValid())
+return false;
+  return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
+}
+
 lldb::SBType SBType::GetFunctionReturnType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
 
@@ -935,6 +943,7 @@
   LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ());
+  LLDB_REGISTER_METHOD(bool, SBType, IsScopedEnumerationType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ());
   LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes,
 

[Lldb-commits] [PATCH] D93690: Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat marked an inline comment as done.
werat added inline comments.



Comment at: lldb/source/API/SBType.cpp:275
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+

JDevlieghere wrote:
> Same comment as in D93696: you need to register your new method. 
Thanks for pointing this out, I totally missed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93690

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


[Lldb-commits] [PATCH] D93690: Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93690

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


[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat updated this revision to Diff 313379.
werat added a comment.

Register the new method using lldb-instr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -31,6 +31,7 @@
 
 enum EnumType {};
 enum class ScopedEnumType {};
+enum class EnumUChar : unsigned char {};
 
 int main (int argc, char const *argv[])
 {
@@ -63,6 +64,7 @@
 
 EnumType enum_type;
 ScopedEnumType scoped_enum_type;
+EnumUChar scoped_enum_type_uchar;
 
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -150,7 +150,24 @@
 self.assertTrue(enum_type)
 self.DebugSBType(enum_type)
 self.assertFalse(enum_type.IsScopedEnumerationType())
+int_enum_type = enum_type.GetEnumerationIntegerType()
+self.assertTrue(int_enum_type)
+self.DebugSBType(int_enum_type)
+self.assertEquals(int_enum_type.GetName(), 'unsigned int')
+
 scoped_enum_type = target.FindFirstType('ScopedEnumType')
 self.assertTrue(scoped_enum_type)
 self.DebugSBType(scoped_enum_type)
 self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
+self.assertTrue(int_scoped_enum_type)
+self.DebugSBType(int_scoped_enum_type)
+self.assertEquals(int_scoped_enum_type.GetName(), 'int')
+
+enum_uchar = target.FindFirstType('EnumUChar')
+self.assertTrue(enum_uchar)
+self.DebugSBType(enum_uchar)
+int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
+self.assertTrue(int_enum_uchar)
+self.DebugSBType(int_enum_uchar)
+self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -350,6 +350,12 @@
   return CompilerType();
 }
 
+CompilerType CompilerType::GetEnumerationIntegerType() const {
+  if (IsValid())
+return m_type_system->GetEnumerationIntegerType(m_type);
+  return CompilerType();
+}
+
 int CompilerType::GetFunctionArgumentCount() const {
   if (IsValid()) {
 return m_type_system->GetFunctionArgumentCount(m_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -698,6 +698,9 @@
   CompilerType
   GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
 
+  CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override;
+
   // Returns -1 if this isn't a function of if the function doesn't have a
   // prototype Returns a value >= 0 if there is a prototype.
   int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4189,6 +4189,13 @@
   return CompilerType();
 }
 
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+  if (type)
+return GetEnumerationIntegerType(GetType(GetCanonicalQualType(type)));
+  return CompilerType();
+}
+
 int TypeSystemClang::GetFunctionArgumentCount(
 lldb::opaque_compiler_type_t type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -344,6 +344,16 @@
   return LLDB_RECORD_RESULT(SBType());
 }
 
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+  if (IsValid()) {
+return LLDB_RECORD_RESULT(
+SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+  }
+  return LLDB_RECORD_RESULT(SBType());
+}
+
 lldb

[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat updated this revision to Diff 313380.
werat marked an inline comment as done.
werat added a comment.

Remove the test case for unscoped enum, because it's implementation defined and 
can break any moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -31,6 +31,7 @@
 
 enum EnumType {};
 enum class ScopedEnumType {};
+enum class EnumUChar : unsigned char {};
 
 int main (int argc, char const *argv[])
 {
@@ -63,6 +64,7 @@
 
 EnumType enum_type;
 ScopedEnumType scoped_enum_type;
+EnumUChar scoped_enum_type_uchar;
 
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -150,7 +150,20 @@
 self.assertTrue(enum_type)
 self.DebugSBType(enum_type)
 self.assertFalse(enum_type.IsScopedEnumerationType())
+
 scoped_enum_type = target.FindFirstType('ScopedEnumType')
 self.assertTrue(scoped_enum_type)
 self.DebugSBType(scoped_enum_type)
 self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
+self.assertTrue(int_scoped_enum_type)
+self.DebugSBType(int_scoped_enum_type)
+self.assertEquals(int_scoped_enum_type.GetName(), 'int')
+
+enum_uchar = target.FindFirstType('EnumUChar')
+self.assertTrue(enum_uchar)
+self.DebugSBType(enum_uchar)
+int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
+self.assertTrue(int_enum_uchar)
+self.DebugSBType(int_enum_uchar)
+self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -350,6 +350,12 @@
   return CompilerType();
 }
 
+CompilerType CompilerType::GetEnumerationIntegerType() const {
+  if (IsValid())
+return m_type_system->GetEnumerationIntegerType(m_type);
+  return CompilerType();
+}
+
 int CompilerType::GetFunctionArgumentCount() const {
   if (IsValid()) {
 return m_type_system->GetFunctionArgumentCount(m_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -698,6 +698,9 @@
   CompilerType
   GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
 
+  CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override;
+
   // Returns -1 if this isn't a function of if the function doesn't have a
   // prototype Returns a value >= 0 if there is a prototype.
   int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4189,6 +4189,13 @@
   return CompilerType();
 }
 
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+  if (type)
+return GetEnumerationIntegerType(GetType(GetCanonicalQualType(type)));
+  return CompilerType();
+}
+
 int TypeSystemClang::GetFunctionArgumentCount(
 lldb::opaque_compiler_type_t type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -344,6 +344,16 @@
   return LLDB_RECORD_RESULT(SBType());
 }
 
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+  if (IsValid()) {
+return LLDB_RECORD_RESULT(
+SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+  }
+  return LLDB_RECORD_RESULT(SBType());
+}
+
 lldb::BasicType SBType::GetBasicType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType);
 
@@

[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

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


[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added inline comments.



Comment at: lldb/source/API/SBType.cpp:348
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+

JDevlieghere wrote:
> You also need to register the new method. You can add the instrumentation 
> automatically with the lldb-instr tool if you remove this line (and the 
> `LLDB_RECORD_RESULT` or the return value will get wrapped again). 
Thanks, done!



Comment at: lldb/test/API/python_api/type/TestTypeList.py:156
+self.DebugSBType(int_enum_type)
+self.assertEquals(int_enum_type.GetName(), 'unsigned int')
+

JDevlieghere wrote:
> werat wrote:
> > Afaik this is implementation defined, so maybe this we shouldn't test this.
> Yeah, I would either remove it or add a comment saying that it's 
> implementation defined in case someone (downstream) runs into this. 
I've removed the test case to avoid potential confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

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


[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added a comment.

Thanks for a quick review! Can you please land these changes for me since I 
don't have commit access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

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


[Lldb-commits] [lldb] e17a00f - [lldb] Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Jonas Devlieghere via lldb-commits

Author: Andy Yankovsky
Date: 2020-12-22T10:08:21-08:00
New Revision: e17a00fc87bc163cc2438ce10faca51d94b91ab3

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

LOG: [lldb] Add SBType::IsScopedEnumerationType method

Add a method to check if the type is a scoped enumeration (i.e. "enum
class/struct").

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

Added: 


Modified: 
lldb/bindings/interface/SBType.i
lldb/include/lldb/API/SBType.h
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBType.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/test/API/python_api/type/TestTypeList.py
lldb/test/API/python_api/type/main.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBType.i 
b/lldb/bindings/interface/SBType.i
index fd2dda188454..b65eddb5fe29 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -220,6 +220,9 @@ public:
 bool
 IsAnonymousType ();
 
+bool
+IsScopedEnumerationType ();
+
 lldb::SBType
 GetPointerType();
 

diff  --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 5f487aa5d258..9ac385c492ed 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -131,6 +131,8 @@ class SBType {
 
   bool IsAnonymousType();
 
+  bool IsScopedEnumerationType();
+
   lldb::SBType GetPointerType();
 
   lldb::SBType GetPointeeType();

diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index f1cde0ac3084..1e0f520ab959 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -82,6 +82,8 @@ class CompilerType {
 
   bool IsAnonymousType() const;
 
+  bool IsScopedEnumerationType() const;
+
   bool IsBeingDefined() const;
 
   bool IsCharType() const;

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 4c51d290ad2c..b8393b9c39e1 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -175,6 +175,8 @@ class TypeSystem : public PluginInterface {
 return false;
   }
 
+  virtual bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) = 0;
+
   virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
  CompilerType *target_type, // Can pass 
NULL
  bool check_cplusplus, bool check_objc) = 
0;

diff  --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 0a99ac0f2292..7d8d4cfeef4f 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -271,6 +271,14 @@ bool SBType::IsAnonymousType() {
   return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
 }
 
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+
+  if (!IsValid())
+return false;
+  return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
+}
+
 lldb::SBType SBType::GetFunctionReturnType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
 
@@ -935,6 +943,7 @@ void RegisterMethods(Registry &R) {
   LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ());
+  LLDB_REGISTER_METHOD(bool, SBType, IsScopedEnumerationType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ());
   LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes,
());

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 894faa847450..d1a9e9387292 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3147,6 +3147,20 @@ bool 
TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
   return false;
 }
 
+bool TypeSystemClang::IsScopedEnumerationType(
+lldb::opaque_compiler_type_t type) {
+  if (type) {
+const clang::EnumType *enum_type = llvm::dyn_cast(
+GetCanonicalQualType(type)->getCanonicalTypeInternal());
+
+if (enum_type) {
+  return enum_type->isScopedEnumeralType();
+}
+  }
+
+  return false;
+}
+
 bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type,
 CompilerType *pointee_type) {
   if (type) {

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemC

[Lldb-commits] [lldb] 1432ae5 - [lldb] Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Jonas Devlieghere via lldb-commits

Author: Andy Yankovsky
Date: 2020-12-22T10:08:22-08:00
New Revision: 1432ae57bf6e4022b6f4541c9225674ee6b19c23

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

LOG: [lldb] Add SBType::GetEnumerationIntegerType method

Add a method for getting the enumeration underlying type.

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

Added: 


Modified: 
lldb/bindings/interface/SBType.i
lldb/include/lldb/API/SBType.h
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBType.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/test/API/python_api/type/TestTypeList.py
lldb/test/API/python_api/type/main.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBType.i 
b/lldb/bindings/interface/SBType.i
index b65eddb5fe29..2d9a4a4d11d1 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -244,6 +244,9 @@ public:
 lldb::SBType
 GetCanonicalType();
 
+lldb::SBType
+GetEnumerationIntegerType();
+
 lldb::SBType
 GetArrayElementType ();
 

diff  --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 9ac385c492ed..529b4d0eeffc 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -152,6 +152,9 @@ class SBType {
   lldb::SBType GetVectorElementType();
 
   lldb::SBType GetCanonicalType();
+
+  lldb::SBType GetEnumerationIntegerType();
+
   // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
   // type eBasicTypeInvalid will be returned
   lldb::BasicType GetBasicType();

diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 1e0f520ab959..5a0e8e57200d 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -187,6 +187,8 @@ class CompilerType {
 
   CompilerType GetFullyUnqualifiedType() const;
 
+  CompilerType GetEnumerationIntegerType() const;
+
   /// Returns -1 if this isn't a function of if the function doesn't
   /// have a prototype Returns a value >= 0 if there is a prototype.
   int GetFunctionArgumentCount() const;

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b8393b9c39e1..1fad8f61ac37 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -227,6 +227,9 @@ class TypeSystem : public PluginInterface {
 
   virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
 
+  virtual CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) = 0;
+
   // Returns -1 if this isn't a function of if the function doesn't have a
   // prototype Returns a value >= 0 if there is a prototype.
   virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;

diff  --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 7d8d4cfeef4f..550c4b065914 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -344,6 +344,16 @@ lldb::SBType SBType::GetCanonicalType() {
   return LLDB_RECORD_RESULT(SBType());
 }
 
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+  if (IsValid()) {
+return LLDB_RECORD_RESULT(
+
SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+  }
+  return LLDB_RECORD_RESULT(SBType());
+}
+
 lldb::BasicType SBType::GetBasicType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType);
 
@@ -952,6 +962,7 @@ void RegisterMethods(Registry &R) {
GetMemberFunctionAtIndex, (uint32_t));
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ());
+  LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetEnumerationIntegerType, ());
   LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType));
   LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ());

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index d1a9e9387292..4f55cf7cfa79 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4195,6 +4195,13 @@ 
TypeSystemClang::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) {
   return CompilerType();
 }
 
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+  if (type)
+retur

[Lldb-commits] [PATCH] D93690: Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe17a00fc87bc: [lldb] Add SBType::IsScopedEnumerationType 
method (authored by werat, committed by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93690

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -29,6 +29,8 @@
 {}
 };
 
+enum EnumType {};
+enum class ScopedEnumType {};
 
 int main (int argc, char const *argv[])
 {
@@ -59,5 +61,8 @@
 typedef int myint;
 myint myint_arr[] = {1, 2, 3};
 
+EnumType enum_type;
+ScopedEnumType scoped_enum_type;
+
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -144,3 +144,13 @@
 myint_type = target.FindFirstType('myint')
 self.DebugSBType(myint_type)
 self.assertTrue(myint_arr_element_type == myint_type)
+
+# Test enum methods.
+enum_type = target.FindFirstType('EnumType')
+self.assertTrue(enum_type)
+self.DebugSBType(enum_type)
+self.assertFalse(enum_type.IsScopedEnumerationType())
+scoped_enum_type = target.FindFirstType('ScopedEnumType')
+self.assertTrue(scoped_enum_type)
+self.DebugSBType(scoped_enum_type)
+self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -40,6 +40,12 @@
   return false;
 }
 
+bool CompilerType::IsScopedEnumerationType() const {
+  if (IsValid())
+return m_type_system->IsScopedEnumerationType(m_type);
+  return false;
+}
+
 bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size,
bool *is_incomplete) const {
   if (IsValid())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -600,6 +600,8 @@
   bool IsEnumerationType(lldb::opaque_compiler_type_t type,
  bool &is_signed) override;
 
+  bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override;
+
   static bool IsObjCClassType(const CompilerType &type);
 
   static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3147,6 +3147,20 @@
   return false;
 }
 
+bool TypeSystemClang::IsScopedEnumerationType(
+lldb::opaque_compiler_type_t type) {
+  if (type) {
+const clang::EnumType *enum_type = llvm::dyn_cast(
+GetCanonicalQualType(type)->getCanonicalTypeInternal());
+
+if (enum_type) {
+  return enum_type->isScopedEnumeralType();
+}
+  }
+
+  return false;
+}
+
 bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type,
 CompilerType *pointee_type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -271,6 +271,14 @@
   return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
 }
 
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+
+  if (!IsValid())
+return false;
+  return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
+}
+
 lldb::SBType SBType::GetFunctionReturnType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
 
@@ -935,6 +943,7 @@
   LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ());
+  LLDB_REGISTER_METHOD(bool, SBType, IsScopedEnumerationType, ());
   LLDB_REGI

[Lldb-commits] [PATCH] D93696: Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1432ae57bf6e: [lldb] Add SBType::GetEnumerationIntegerType 
method (authored by werat, committed by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93696

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp

Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -31,6 +31,7 @@
 
 enum EnumType {};
 enum class ScopedEnumType {};
+enum class EnumUChar : unsigned char {};
 
 int main (int argc, char const *argv[])
 {
@@ -63,6 +64,7 @@
 
 EnumType enum_type;
 ScopedEnumType scoped_enum_type;
+EnumUChar scoped_enum_type_uchar;
 
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -150,7 +150,20 @@
 self.assertTrue(enum_type)
 self.DebugSBType(enum_type)
 self.assertFalse(enum_type.IsScopedEnumerationType())
+
 scoped_enum_type = target.FindFirstType('ScopedEnumType')
 self.assertTrue(scoped_enum_type)
 self.DebugSBType(scoped_enum_type)
 self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
+self.assertTrue(int_scoped_enum_type)
+self.DebugSBType(int_scoped_enum_type)
+self.assertEquals(int_scoped_enum_type.GetName(), 'int')
+
+enum_uchar = target.FindFirstType('EnumUChar')
+self.assertTrue(enum_uchar)
+self.DebugSBType(enum_uchar)
+int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
+self.assertTrue(int_enum_uchar)
+self.DebugSBType(int_enum_uchar)
+self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -350,6 +350,12 @@
   return CompilerType();
 }
 
+CompilerType CompilerType::GetEnumerationIntegerType() const {
+  if (IsValid())
+return m_type_system->GetEnumerationIntegerType(m_type);
+  return CompilerType();
+}
+
 int CompilerType::GetFunctionArgumentCount() const {
   if (IsValid()) {
 return m_type_system->GetFunctionArgumentCount(m_type);
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -678,6 +678,9 @@
   CompilerType
   GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
 
+  CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override;
+
   // Returns -1 if this isn't a function of if the function doesn't have a
   // prototype Returns a value >= 0 if there is a prototype.
   int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4195,6 +4195,13 @@
   return CompilerType();
 }
 
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+  if (type)
+return GetEnumerationIntegerType(GetType(GetCanonicalQualType(type)));
+  return CompilerType();
+}
+
 int TypeSystemClang::GetFunctionArgumentCount(
 lldb::opaque_compiler_type_t type) {
   if (type) {
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -344,6 +344,16 @@
   return LLDB_RECORD_RESULT(SBType());
 }
 
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+  if (IsValid()) {
+return LLDB_RECORD_RESULT(
+SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+  }
+  return LLDB_RECORD_RESULT(SBType());
+}
+
 lldb::BasicType SBType::GetBasicType() {
   LLDB_RECORD_METHOD_

[Lldb-commits] [lldb] 6283d2a - Revert "[LLDB] Unbreak the build after recent clang changes"

2020-12-22 Thread Arthur Eubanks via lldb-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:34:04-08:00
New Revision: 6283d2aa51985d6e6f3404f4b0a3b38b5b05ee6e

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

LOG: Revert "[LLDB] Unbreak the build after recent clang changes"

This reverts commit 430d5d8429473c2b10b109991d7577a3cea41140.

Depends on a reverted change.

Added: 


Modified: 
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index ff4e15e7e070..2679ee52136d 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -816,7 +816,6 @@ enum TemplateArgumentKind {
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
-  eTemplateArgumentKindUncommonValue,
 };
 
 /// Options that can be set for a formatter to alter its behavior. Not

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4f55cf7cfa79..c15b15e736fb 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7002,9 +7002,6 @@ 
TypeSystemClang::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
-
-  case clang::TemplateArgument::UncommonValue:
-return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }



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


[Lldb-commits] [PATCH] D93744: [lldb-vscode] Support processId returned by the IDE in the runInTerminal request

2020-12-22 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: kusmour, clayborg.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently, the runInTerminal is implemented by using --wait-for underneath, 
which is error prone as it often can't attach on Linux. A reason I've found is 
that LLDB does process polling by using commands like "ps", which are not 
standard across distributions. This is a problem that doesn't happen on Mac.

For more context, the debug adapter protocol specifies that the response of the 
"runInTerminal" reverse request doesn't need to provide the pid of the process 
launched by the IDE. VSCode, for example, doesn't return the pid. Without this 
pid, the only way to attach to the process is with --wait-for.

However, IDEs like VSCode support customizations of their debuggers, allowing 
it to return the pid. In this case, lldb-vscode needs to know that the IDE will 
return the pid and therefore it shouldn't use --wait-for. Because of this, 
lldb-vscode will also require the launch request to include 
'runInTerminalRespondsWithPid: true' to work this way. This is acceptable, as 
the user/developer is already customizing the IDE, so doings the pid addition 
and the runInTerminalRespondsWithPid inclusion are simple changes.

This new approach to runInTerminal is guaranteed to attach to the process, as 
long as it doesn't finish right away, which is better than what we had before.

Tested on Mac and Linux


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93744

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/runInTerminal/TestVSCode_runInTerminal.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -178,7 +178,7 @@
 			},
 			"runInTerminal": {
 "type": "boolean",
-"description": "Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs",
+"description": "Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs. If the client IDE returns the \"processId\" as part of the \"runInTerminal\" reverse request, then it's suggested that the client IDE includes the field '\"runInTerminalRespondsWithPid\": true' as part of the \"launch\" request, as LLDB can guarantee attachment to the process this way.",
 "default": false
 			}
 		}
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1449,8 +1449,16 @@
   g_vsc.is_attach = true;
   lldb::SBAttachInfo attach_info;
   lldb::SBError error;
-  attach_info.SetWaitForLaunch(true, /*async*/ true);
-  g_vsc.target.Attach(attach_info, error);
+  const llvm::json::Object *arguments = launch_request.getObject("arguments");
+  bool runInTerminalRespondsWithPid =
+  GetBoolean(*arguments, "runInTerminalRespondsWithPid", false);
+
+  // If the client IDE won't provide the pid of the debuggee, then we attach
+  // with "wait for"
+  if (!runInTerminalRespondsWithPid) {
+attach_info.SetWaitForLaunch(true, /*async*/ true);
+g_vsc.target.Attach(attach_info, error);
+  }
 
   llvm::json::Object reverse_request =
   CreateRunInTerminalReverseRequest(launch_request);
@@ -1461,19 +1469,28 @@
 error.SetErrorString("Process cannot be launched by IDE.");
 
   if (error.Success()) {
-// Wait for the attach stop event to happen or for a timeout.
-g_vsc.waiting_for_run_in_terminal = true;
-static std::mutex mutex;
-std::unique_lock locker(mutex);
-g_vsc.request_in_terminal_cv.wait_for(locker, std::chrono::seconds(10));
-
-auto attached_pid = g_vsc.target.GetProcess().GetProcessID();
-if (attached_pid == LLDB_INVALID_PROCESS_ID)
-  error.SetErrorString("Failed to attach to a process");
-else
-  SendProcessEvent(Attach);
+if (runInTerminalRespondsWithPid) {
+  lldb::pid_t pid =
+  GetUnsigned(reverse_response, "processId", LLDB_INVALID_PROCESS_ID);
+  attach_info.SetProcessID(pid);
+  g_vsc.debugger.SetAsync(false);
+  g_vsc.target.Attach(attach_info, error);
+  g_vsc.debugger.SetAsync(true);
+} else {
+  // Wait for the attach stop event to happen or for a timeout.
+  g_vsc.waiting_for_run_in_terminal = true;
+  static std::mutex mutex;
+  std::unique_lock locker(mutex);
+  g_vsc.request_in_terminal_cv.wait_for(locker, std::chrono::seconds(10));
+}
   }
 
+  auto attached_pid = g_vsc.target.GetProcess().GetProce