[Lldb-commits] [PATCH] D42083: [lldb][PPC64] Fixed long double variables dump

2018-01-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This adds a special case to "long double" logic, which is already a special 
case compared to "float" and "double" cases. This was written this way (see 
http://reviews.llvm.org/D8417) because the x86 long double type is special, but 
if I understand this correctly, for the ppc type, the "default" logic of just 
using the item_byte_size would be correct.

What if we reverse the conditions here to be something like?

  offset_t byte_size = item_byte_size;
  if (&semantics == &x87DoubleExtended)
byte_size = (APFloat::getSizeInBits(semantics)+7)/8;


Repository:
  rL LLVM

https://reviews.llvm.org/D42083



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


[Lldb-commits] [PATCH] D42083: [lldb][PPC64] Fixed long double variables dump

2018-01-16 Thread Leandro Lupori via Phabricator via lldb-commits
luporl added a comment.

@labath, the change you suggested really looks better, by reducing the number 
of special cases.

I tested it on PPC64 and it also fixes the issue, as expected.

I'll update the diff.
Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D42083



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


[Lldb-commits] [PATCH] D42083: [lldb][PPC64] Fixed long double variables dump

2018-01-16 Thread Leandro Lupori via Phabricator via lldb-commits
luporl updated this revision to Diff 129939.
luporl added a comment.

Changed implementation to make only x87DoubleExtended a special case.


https://reviews.llvm.org/D42083

Files:
  source/Core/DumpDataExtractor.cpp


Index: source/Core/DumpDataExtractor.cpp
===
--- source/Core/DumpDataExtractor.cpp
+++ source/Core/DumpDataExtractor.cpp
@@ -583,8 +583,10 @@
 } else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
   const auto &semantics =
   ast->getFloatTypeSemantics(ast->LongDoubleTy);
-  const auto byte_size =
-  (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
+
+  offset_t byte_size = item_byte_size;
+  if (&semantics == &llvm::APFloatBase::x87DoubleExtended())
+byte_size = (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
 
   llvm::APInt apint;
   if (GetAPInt(DE, &offset, byte_size, apint)) {


Index: source/Core/DumpDataExtractor.cpp
===
--- source/Core/DumpDataExtractor.cpp
+++ source/Core/DumpDataExtractor.cpp
@@ -583,8 +583,10 @@
 } else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
   const auto &semantics =
   ast->getFloatTypeSemantics(ast->LongDoubleTy);
-  const auto byte_size =
-  (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
+
+  offset_t byte_size = item_byte_size;
+  if (&semantics == &llvm::APFloatBase::x87DoubleExtended())
+byte_size = (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
 
   llvm::APInt apint;
   if (GetAPInt(DE, &offset, byte_size, apint)) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42145: [lldb] Use vFlash commands when writing to target's flash memory regions

2018-01-16 Thread Owen Shaw via Phabricator via lldb-commits
owenpshaw created this revision.
owenpshaw added reviewers: clayborg, labath.
Herald added subscribers: mgorny, emaste.

When writing an object file over gdb-remote, use the vFlashErase, vFlashWrite, 
and vFlashDone commands if the write address is in a flash memory region.  A 
bare metal target may have this kind of setup.

- Update ObjectFileELF to set load addresses using physical addresses.  A 
typical case may be a data section with a physical address in ROM and a virtual 
address in RAM, which should be loaded to the ROM address.
- Add support for querying the target's qXfer:memory-map, which contains 
information about flash memory regions, leveraging MemoryRegionInfo data 
structures with minor modifications
- Update ProcessGDBRemote to use vFlash commands in DoWriteMemory when the 
target address is in a flash region
- Add a new foundation for testing gdb-remote behaviors by using a mock server 
that can respond however the test requires

Original discussion at 
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013093.html

---

A few questions...

1. Leveraging MemoryRegionInfo seemed like the way to go, since 
qXfer:memory-map results are similar to qMemoryRegionInfo results.  But should 
GetMemoryRegionInfo() be changed to use the qXfer results instead of having the 
separate new function I added?
2. Are the new gdb-remote python tests moving in the right direction?  I can 
add more cases, but wanted to first verify the foundation was acceptable.  It's 
similar to some code in the tools/lldb-server tests, but seemed different 
enough to justify its own base.


https://reviews.llvm.org/D42145

Files:
  include/lldb/Host/XML.h
  include/lldb/Target/MemoryRegionInfo.h
  include/lldb/Target/Process.h
  
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  packages/Python/lldbsuite/test/functionalities/gdb_remote_client/a.yaml
  
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
  source/Host/common/XML.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  source/Symbol/ObjectFile.cpp
  unittests/Process/gdb-remote/CMakeLists.txt
  unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp

Index: unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp
===
--- /dev/null
+++ unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp
@@ -0,0 +1,54 @@
+//===-- GDBRemoteCommunicationTest.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include 
+
+#include "GDBRemoteTestUtils.h"
+#include "lldb/Utility/StreamString.h"
+
+using namespace lldb_private::process_gdb_remote;
+using namespace lldb_private;
+
+TEST(GDBRemoteCommunicationTest, WriteEscapedBinary) {
+  StreamString escaped;
+
+  // Nothing gets escaped
+  // Verify null and other control chars don't cause problems
+  const uint8_t data[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+  GDBRemoteCommunication::WriteEscapedBinary(escaped, data, sizeof(data));
+  ASSERT_EQ(sizeof(data), escaped.GetSize());
+  ASSERT_EQ(0x00, escaped.GetString().data()[0]);
+  ASSERT_EQ(0x03, escaped.GetString().data()[3]);
+  ASSERT_EQ(0x07, escaped.GetString().data()[7]);
+
+  // 0x23 and 0x24 should be escaped
+  escaped.Clear();
+  const uint8_t data2[] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27};
+  GDBRemoteCommunication::WriteEscapedBinary(escaped, data2, sizeof(data));
+  ASSERT_EQ(sizeof(data) + 2, escaped.GetSize());
+  ASSERT_EQ(0x20, escaped.GetString().data()[0]);
+  ASSERT_EQ(0x7d, escaped.GetString().data()[3]);
+  ASSERT_EQ(0x23 ^ 0x20, escaped.GetString().data()[4]);
+  ASSERT_EQ(0x7d, escaped.GetString().data()[5]);
+  ASSERT_EQ(0x24 ^ 0x20, escaped.GetString().data()[6]);
+  ASSERT_EQ(0x25, escaped.GetString().data()[7]);
+  ASSERT_EQ(0x27, escaped.GetString().data()[9]);
+
+  // 0x7d should be escaped
+  escaped.Clear();
+  const uint8_t data3[] = {0x7b, 0x74, 0x65, 0x73, 0x74, 0x7d};
+  GDBRemoteCommunication::WriteEscapedBinary(escaped, data3, sizeof(data));
+  ASSERT_EQ(sizeof(data) + 1, escaped.GetSize());
+  ASSERT_EQ(0x7b, escaped.GetString().data()[0]);
+  ASSERT_EQ(0x74, escaped.GetString().data()[1]);
+  ASSERT_EQ(0x65, e

[Lldb-commits] [lldb] r322603 - Remove the hardcoded macos deployment targets altogether

2018-01-16 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Tue Jan 16 16:22:27 2018
New Revision: 322603

URL: http://llvm.org/viewvc/llvm-project?rev=322603&view=rev
Log:
Remove the hardcoded macos deployment targets altogether
from the xcode project files.  We'll build for the current
OS only, by default.  


Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=322603&r1=322602&r2=322603&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jan 16 16:22:27 2018
@@ -8336,7 +8336,6 @@
LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
LLVM_CONFIGURATION = "Release+Asserts";
LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-Wparentheses",
@@ -8427,7 +8426,6 @@
LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
LLVM_CONFIGURATION = "Release+Asserts";
LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-Wparentheses",
@@ -9421,7 +9419,6 @@
LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
LLVM_CONFIGURATION = Release;
LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
@@ -10215,7 +10212,6 @@
LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
LLVM_CONFIGURATION = "Debug+Asserts";
LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-Wparentheses",

Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=322603&r1=322602&r2=322603&view=diff
==
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj 
(original)
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Jan 
16 16:22:27 2018
@@ -720,7 +720,6 @@
LLDB_USE_OS_LOG = 0;
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "";
STRIP_INSTALLED_PRODUCT = NO;
@@ -764,7 +763,6 @@
LLDB_USE_OS_LOG = 0;
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "";
STRIPFLAGS = "-x";
@@ -806,7 +804,6 @@
LLDB_USE_OS_LOG = 1;
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
OTHER_CFLAGS = "";
STRIPFLAGS = "-x";
STRIP_STYLE = debugging;
@@ -858,7 +855,6 @@
"LLDB_ENERGY_LFLAGS[sdk=macosx*]" = 
"-weak-lpmenergy -weak-lpmsample";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
-   MACOSX_DEPLOYMENT_TARGET = 10.11;
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ENERGY_CFLAGS)",
@@ -962,7 +958,6 @@
"LLDB_ENERGY_LFLAGS[sdk=macosx.internal]" 

Re: [Lldb-commits] [lldb] r322603 - Remove the hardcoded macos deployment targets altogether

2018-01-16 Thread Davide Italiano via lldb-commits
This is great, thanks Jason!

On Tue, Jan 16, 2018 at 4:22 PM, Jason Molenda via lldb-commits
 wrote:
> Author: jmolenda
> Date: Tue Jan 16 16:22:27 2018
> New Revision: 322603
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322603&view=rev
> Log:
> Remove the hardcoded macos deployment targets altogether
> from the xcode project files.  We'll build for the current
> OS only, by default.
>
>
> Modified:
> lldb/trunk/lldb.xcodeproj/project.pbxproj
> lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
>
> Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=322603&r1=322602&r2=322603&view=diff
> ==
> --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
> +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jan 16 16:22:27 2018
> @@ -8336,7 +8336,6 @@
> LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
> LLVM_CONFIGURATION = "Release+Asserts";
> LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> ONLY_ACTIVE_ARCH = YES;
> OTHER_CFLAGS = (
> "-Wparentheses",
> @@ -8427,7 +8426,6 @@
> LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
> LLVM_CONFIGURATION = "Release+Asserts";
> LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> ONLY_ACTIVE_ARCH = YES;
> OTHER_CFLAGS = (
> "-Wparentheses",
> @@ -9421,7 +9419,6 @@
> LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
> LLVM_CONFIGURATION = Release;
> LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> OTHER_CFLAGS = (
> "-Wparentheses",
> "$(LLDB_ZLIB_CFLAGS)",
> @@ -10215,7 +10212,6 @@
> LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/";
> LLVM_CONFIGURATION = "Debug+Asserts";
> LLVM_SOURCE_DIR = "$(SRCROOT)/llvm";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> ONLY_ACTIVE_ARCH = YES;
> OTHER_CFLAGS = (
> "-Wparentheses",
>
> Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=322603&r1=322602&r2=322603&view=diff
> ==
> --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj 
> (original)
> +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue 
> Jan 16 16:22:27 2018
> @@ -720,7 +720,6 @@
> LLDB_USE_OS_LOG = 0;
> LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
> LLDB_ZLIB_LDFLAGS = "-lz";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> ONLY_ACTIVE_ARCH = YES;
> OTHER_CFLAGS = "";
> STRIP_INSTALLED_PRODUCT = NO;
> @@ -764,7 +763,6 @@
> LLDB_USE_OS_LOG = 0;
> LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
> LLDB_ZLIB_LDFLAGS = "-lz";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> ONLY_ACTIVE_ARCH = YES;
> OTHER_CFLAGS = "";
> STRIPFLAGS = "-x";
> @@ -806,7 +804,6 @@
> LLDB_USE_OS_LOG = 1;
> LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
> LLDB_ZLIB_LDFLAGS = "-lz";
> -   MACOSX_DEPLOYMENT_TARGET = 10.11;
> OTHER_CFLAGS = "";
> STRIPFLAGS = "-x";
> STRIP_STYLE = debugging;
> @@ -858,7 +855,6 @@
> "LLDB_ENERGY_LFLAGS[sdk=macosx*]" = 
> "-weak-lpmenergy -weak-lpmsample";
> LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
> LLDB_ZLIB_LDFLAGS = "-lz";
> -   MACOSX_DEPLOYMENT_TA

[Lldb-commits] [PATCH] D41427: Fix crash when parsing the type of a function without any arguments, i.e. 'int main()'

2018-01-16 Thread Aaron Smith via Phabricator via lldb-commits
asmith updated this revision to Diff 130088.
asmith retitled this revision from "Fix crash when parsing the type of a 
function without any arguments" to "Fix crash when parsing the type of a 
function without any arguments, i.e. 'int main()'".
asmith edited the summary of this revision.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41427

Files:
  lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
  lit/SymbolFile/PDB/enums-layout.test
  lit/SymbolFile/PDB/typedefs.test
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp


Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -126,14 +126,14 @@
   return CompilerType(ast, ast->WCharTy);
 break;
   case PDB_BuiltinType::Float:
-// Note: Basic type `long double` and `double` have same bit size in MSVC.
-// PDB does not have information to distinguish them. So when falling back
-// to default search, compiler type of `long double` will be represented by
+// Note: types `long double` and `double` have same bit size in MSVC and 
there
+// is no information in the PDB to distinguish them. So when falling back
+// to default search, the compiler type of `long double` will be 
represented by
 // the one generated for `double`.
 break;
   }
-  // If not match up PDB_BuiltinType, fall back to default search by encoding
-  // and width only
+  // If there is no match on PDB_BuiltinType, fall back to default search
+  // by encoding and width only
   return clang_ast->GetBuiltinTypeForEncodingAndBitSize(encoding, width);
 }
 
Index: lit/SymbolFile/PDB/typedefs.test
===
--- lit/SymbolFile/PDB/typedefs.test
+++ lit/SymbolFile/PDB/typedefs.test
@@ -1,16 +1,16 @@
 REQUIRES: windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o 
%T/SimpleTypesTest.cpp.typedefs.obj
-RUN: link %T/SimpleTypesTest.cpp.typedefs.obj /DEBUG /nodefaultlib /Entry:main 
/OUT:%T/SimpleTypesTest.cpp.typedefs.exe
+RUN: link %T/SimpleTypesTest.cpp.typedefs.obj /DEBUG /nodefaultlib /ENTRY:main 
/OUT:%T/SimpleTypesTest.cpp.typedefs.exe
 RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s
 
 ; Generate 32-bit target
 
-; FIXME: For now, PDB does not have line information for typedef statements.
-; So source and line information of them not tested.
+; FIXME: PDB does not have line information for typedef statements so source
+; and line information for them is not tested.
 
-; Note, basic type `long double` and `double` have same bit size in MSVC.
-; There is no information in PDB to distinguish them. So compiler type of them
-; is represented by the one generated for `double`.
+; Note, types `long double` and `double` have same bit size in MSVC and there
+; is no information in the PDB to distinguish them. So the compiler type for 
+; both of them is the same.
 
 CHECK: Module [[CU:.*]]
 CHECK-DAG:  {{^[0-9A-F]+}}: SymbolVendor ([[CU]])
Index: lit/SymbolFile/PDB/enums-layout.test
===
--- lit/SymbolFile/PDB/enums-layout.test
+++ lit/SymbolFile/PDB/enums-layout.test
@@ -1,10 +1,10 @@
 REQUIRES: windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o 
%T/SimpleTypesTest.cpp.enums.obj
-RUN: link %T/SimpleTypesTest.cpp.enums.obj /DEBUG /nodefaultlib /Entry:main 
/OUT:%T/SimpleTypesTest.cpp.enums.exe
+RUN: link %T/SimpleTypesTest.cpp.enums.obj /DEBUG /nodefaultlib /ENTRY:main 
/OUT:%T/SimpleTypesTest.cpp.enums.exe
 RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck %s
 
-; FIXME: For now, PDB does not have information about scoped enumeration (Enum 
class). 
-; So compiler type of it is represented by the one generated for unscoped 
enumeration.
+; FIXME: PDB does not have information about scoped enumeration (Enum class) 
so the  
+; compiler type used is the same as the one for unscoped enumeration.
 
 CHECK: Module [[CU:.*]]
 CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[CU]])
Index: lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
===
--- lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
+++ lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
@@ -19,7 +19,7 @@
 enum Enum { RED, GREEN, BLUE };
 Enum EnumVar;
 
-enum EnumConst {LOW, NORMAL = 10, HIGH };
+enum EnumConst { LOW, NORMAL = 10, HIGH };
 EnumConst EnumConstVar;
 
 enum EnumEmpty {};


Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -126,14 +126,14 @@
   return CompilerType(ast, ast->WCharTy);
 break;
   case PDB_BuiltinType::Float:
-// Note: Basic type `long double` and 

[Lldb-commits] [PATCH] D41427: Fix crash when parsing the type of a function without any arguments, i.e. 'int main()'

2018-01-16 Thread Aaron Smith via Phabricator via lldb-commits
asmith added a comment.

The test is added and this is ready to go. Let me know if there are any other 
changes. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D41427



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


[Lldb-commits] [PATCH] D41427: Fix crash when parsing the type of a function without any arguments, i.e. 'int main()'

2018-01-16 Thread Aaron Smith via Phabricator via lldb-commits
asmith updated this revision to Diff 130089.

Repository:
  rL LLVM

https://reviews.llvm.org/D41427

Files:
  lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp
  lit/SymbolFile/PDB/enums-layout.test
  lit/SymbolFile/PDB/typedefs.test
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-types.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-types.pdb
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -483,7 +483,10 @@
   llvm::DenseSet searched_files;
   TypeMap results;
 
-  const char *TypedefsToCheck[] = {"ClassTypedef", "NSClassTypedef"};
+  const char *TypedefsToCheck[] = {
+  "ClassTypedef", "NSClassTypedef",
+  "FuncPointerTypedef", "VariadicFuncPointerTypedef"
+  };
   for (auto Typedef : TypedefsToCheck) {
 TypeMap results;
 EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Typedef), nullptr, false,
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
===
--- unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
@@ -48,6 +48,10 @@
 
 typedef Class ClassTypedef;
 typedef NS::NSClass NSClassTypedef;
+typedef int(*FuncPointerTypedef)();
+typedef int(*VariadicFuncPointerTypedef)(char,...);
+FuncPointerTypedef GlobalFunc;
+VariadicFuncPointerTypedef GlobalVariadicFunc;
 int GlobalArray[10];
 
 static const int sizeof_NSClass = sizeof(NS::NSClass);
@@ -57,6 +61,8 @@
 static const int sizeof_ShortEnum = sizeof(ShortEnum);
 static const int sizeof_ClassTypedef = sizeof(ClassTypedef);
 static const int sizeof_NSClassTypedef = sizeof(NSClassTypedef);
+static const int sizeof_FuncPointerTypedef = sizeof(FuncPointerTypedef);
+static const int sizeof_VariadicFuncPointerTypedef = sizeof(VariadicFuncPointerTypedef);
 static const int sizeof_GlobalArray = sizeof(GlobalArray);
 
 int main(int argc, char **argv) {
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -20,6 +20,7 @@
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/TypeList.h"
 #include "lldb/Utility/RegularExpression.h"
 
 #include "llvm/DebugInfo/PDB/GenericError.h"
@@ -318,8 +319,33 @@
 }
 
 size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) {
-  // TODO: Implement this
-  return size_t();
+  lldbassert(sc.module_sp.get());
+  size_t num_added = 0;
+  auto results_up = m_session_up->getGlobalScope()->findAllChildren();
+  if (!results_up)
+return 0;
+  while (auto symbol_up = results_up->getNext()) {
+switch (symbol_up->getSymTag()) {
+case PDB_SymType::Enum:
+case PDB_SymType::UDT:
+case PDB_SymType::Typedef:
+  break;
+default:
+  continue;
+}
+
+auto type_uid = symbol_up->getSymIndexId();
+if (m_types.find(type_uid) != m_types.end())
+  continue;
+
+// This should cause the type to get cached and stored in the `m_types`
+// lookup.
+if (!ResolveTypeUID(symbol_up->getSymIndexId()))
+  continue;
+
+++num_added;
+  }
+  return num_added;
 }
 
 size_t
@@ -349,8 +375,11 @@
 return nullptr;
 
   lldb::TypeSP result = pdb->CreateLLDBTypeFromPDBType(*pdb_type);
-  if (result.get())
+  if (result.get()) {
 m_types.insert(std::make_pair(type_uid, result));
+auto type_list = GetTypeList();
+type_list->Insert(result);
+  }
   return result.get();
 }
 
@@ -649,7 +678,9 @@
   return 0;
 }
 
-lldb_private::TypeList *SymbolFilePDB::GetTypeList() { return nullptr; }
+lldb_private::TypeList *SymbolFilePDB::GetTypeList() {
+  return m_obj_file->GetModule()->GetTypeList();
+}
 
 size_t SymbolFilePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
uint32_t type_mask,
Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -26,12 +26,12 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
 
 using namespace lldb;
 using namespace lldb_private;
-using namespace llvm;
 using namespace llvm::pdb;
 
 namespace {
@@ -46,7 +46,7 @@
   case PDB_