[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-03-31 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I think the current separation makes a lot of sense, but I don't like that 
`XcodeSDK` class is part of Utility. I understand the need from a layering 
perspective and I don't really have a better idea, but maybe someone else does?


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

https://reviews.llvm.org/D76471



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


[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-03-31 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

This will do what the user intends more of the time. Good catch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77186



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


[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-03-31 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Just use "llvm::None" instead of "{}" and this is good to go.




Comment at: lldb/tools/lldb-vscode/JSONUtils.h:237
+CreateBreakpoint(lldb::SBBreakpoint ,
+ llvm::Optional request_path = {},
+ llvm::Optional request_line = {});

lets use "llvm::None" here instead of "{}" for clarity



Comment at: lldb/tools/lldb-vscode/JSONUtils.h:238
+ llvm::Optional request_path = {},
+ llvm::Optional request_line = {});
 

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968



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


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-31 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The main issue is that the symbol vendors currently are ELF, macOS and WASM. 
Right now we have one SymbolVendor for a triple, but I can see a SymbolVendor 
wanting to use multiple symbol servers to get information: one for the OS 
binaries (debuginfod or DebugSymbols.framework at Apple) and one for the 
current application with company specific symbol servers. At Apple, they can 
download any symbols for macOS, iOS, watchOS and tvOS OSes and applications. At 
Facebook we can download symbols for android, linux and iOS. Linux distros 
might have ways to download symbols for their OS stuff, which might work along 
side debuginfod? Also windows has the ability to download symbols.

So it might be good to have the SymbolVendors use one or more SymbolServer 
plug-ins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



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


[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-03-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 254071.
aprantl added a comment.

I just had an off-list conversation with @jingham were we discussed what should 
be Platform versus Host in detail. The resulting solution looks even more 
convoluted at first, but it actually solves a bunch of problems that I had with 
either of the previous proposals. Jim argued that an interface that retrieves 
an SDK for the target should live in PlatformDarwin, since we are querying 
something about a Darwin platform, and in principle, this interface should also 
be available if you are (hypothetically) debugging a macOS process from a Linux 
host, even if it isn't implemented at the time. However, the one concrete 
implementation that we have, the one that calls `xcrun` must live in 
HostInfoMacOSX, because xcrun doesn't anywhere else.

With this in mind I arrived at this version of the patch where the 
implementation lives in HostInfoMacOSX, but the interface lives in 
PlatformDarwin, which forwards to the host if an implementation exists. Let me 
(Pavel & Jim) know what you think about this variant!


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

https://reviews.llvm.org/D76471

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Host/HostInfoBase.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Utility/XcodeSDK.h
  lldb/source/Core/Module.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
  lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/XcodeSDK.cpp
  lldb/unittests/Platform/PlatformDarwinTest.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/XcodeSDKTest.cpp

Index: lldb/unittests/Utility/XcodeSDKTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/XcodeSDKTest.cpp
@@ -0,0 +1,83 @@
+//===-- XcodeSDKTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/XcodeSDK.h"
+
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+using namespace lldb_private;
+
+TEST(XcodeSDKTest, ParseTest) {
+  EXPECT_EQ(XcodeSDK("MacOSX.sdk").GetSDKType(), XcodeSDK::MacOSX);
+  EXPECT_EQ(XcodeSDK("iPhoneSimulator.sdk").GetSDKType(), XcodeSDK::iPhoneSimulator);
+  EXPECT_EQ(XcodeSDK("iPhoneOS.sdk").GetSDKType(), XcodeSDK::iPhoneOS);
+  EXPECT_EQ(XcodeSDK("AppleTVSimulator.sdk").GetSDKType(), XcodeSDK::AppleTVSimulator);
+  EXPECT_EQ(XcodeSDK("AppleTVOS.sdk").GetSDKType(), XcodeSDK::AppleTVOS);
+  EXPECT_EQ(XcodeSDK("WatchSimulator.sdk").GetSDKType(), XcodeSDK::WatchSimulator);
+  EXPECT_EQ(XcodeSDK("WatchOS.sdk").GetSDKType(), XcodeSDK::watchOS);
+  EXPECT_EQ(XcodeSDK("Linux.sdk").GetSDKType(), XcodeSDK::Linux);
+  EXPECT_EQ(XcodeSDK("MacOSX.sdk").GetVersion(), llvm::VersionTuple());
+  EXPECT_EQ(XcodeSDK("MacOSX10.9.sdk").GetVersion(), llvm::VersionTuple(10, 9));
+  EXPECT_EQ(XcodeSDK("MacOSX10.15.4.sdk").GetVersion(), llvm::VersionTuple(10, 15));
+}
+
+TEST(XcodeSDKTest, MergeTest) {
+  XcodeSDK sdk("MacOSX.sdk");
+  sdk.Merge(XcodeSDK("WatchOS.sdk"));
+  // This doesn't make any particular sense and shouldn't happen in practice, we
+  // just want to guarantee a well-defined behavior when choosing one
+  // SDK to fit all CUs in an lldb::Module.
+  // -> The higher number wins.
+  EXPECT_EQ(sdk.GetSDKType(), XcodeSDK::watchOS);
+  sdk.Merge(XcodeSDK("WatchOS1.1.sdk"));
+  EXPECT_EQ(sdk.GetVersion(), llvm::VersionTuple(1, 1));
+  sdk.Merge(XcodeSDK("WatchOS2.0.sdk"));
+  EXPECT_EQ(sdk.GetVersion(), llvm::VersionTuple(2, 0));
+}
+
+TEST(XcodeSDKTest, SDKSupportsModules) {
+  std::string base = "/Applications/Xcode.app/Contents/Developer/Platforms/";
+  EXPECT_TRUE(XcodeSDK::SDKSupportsModules(
+  XcodeSDK::Type::iPhoneSimulator,
+  FileSpec(
+  base +
+  "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk")));
+  EXPECT_FALSE(XcodeSDK::SDKSupportsModules(
+  XcodeSDK::Type::iPhoneSimulator,
+  FileSpec(
+  base +
+  

[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254067.
wallace added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107

Files:
  lldb/test/API/tools/intel-features/intel-pt/test/Makefile
  lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
  lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
  lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Index: lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
===
--- lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -290,6 +291,7 @@
  s.GetData());
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -428,6 +430,7 @@
   }
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -480,6 +483,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
Index: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,23 @@
+//===-- main.cpp *- C++ -*-===//
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM
+///Exceptions. / See https://llvm.org/LICENSE.txt for license information. /
+///SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//
+
+#include 
+
+using namespace std;
+
+int fun(int a) { return a * a + 1; }
+
+int main() {
+  int z = 0;
+  for (int i = 0; i < 1; i++) { // Break for loop
+z += fun(z);
+  }
+
+  return 0; // Break 1
+}
Index: lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,59 @@
+from __future__ import print_function
+
+import os
+import lldb
+import time
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(oslist=no_match(['linux']))
+@skipIf(archs=no_match(['i386', 'x86_64']))
+@skipIfRemote
+def test_basic_flow(self):
+"""Test collection, decoding, and dumping instructions"""
+lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+if not os.path.isfile(plugin_file):
+self.skipTest("features plugin missing.")
+
+self.build()
+
+self.runCmd("plugin load " + plugin_file)
+
+exe = self.getBuildArtifact("a.out")
+lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
+# We start tracing from main
+self.runCmd("processor-trace start all")
+
+# We check the trace after the for loop
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+self.runCmd("c")
+
+# We wait a little bit to ensure the processor has send the PT packets to
+# the memory
+time.sleep(.1)
+
+# We find the start address of the 'fun' function for a later check
+target = self.dbg.GetSelectedTarget()
+fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+.GetStartAddress().GetLoadAddress(target)
+
+# We print the last instructions
+self.expect("processor-trace show-instr-log -c 100",
+patterns=[
+# We expect to have seen the first instruction of 'fun'
+hex(fun_start_adddress),  
+# We expect to see the exit condition of the for loop
+"at main.cpp:" + str(line_number('main.cpp', '// Break for loop')) 
+])
+
+self.runCmd("processor-trace stop")
Index: lldb/test/API/tools/intel-features/intel-pt/test/Makefile
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254068.
wallace added a comment.

Noise, for some reason I can't run clang-format as part of arc lint on this 
device. 
I'm running it manually anyway


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107

Files:
  lldb/test/API/tools/intel-features/intel-pt/test/Makefile
  lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
  lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
  lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Index: lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
===
--- lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -290,6 +291,7 @@
  s.GetData());
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -428,6 +430,7 @@
   }
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -480,6 +483,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
Index: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+using namespace std;
+
+int fun(int a) { return a * a + 1; }
+
+int main() {
+  int z = 0;
+  for (int i = 0; i < 1; i++) { // Break for loop
+z += fun(z);
+  }
+
+  return 0; // Break 1
+}
Index: lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,59 @@
+from __future__ import print_function
+
+import os
+import lldb
+import time
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(oslist=no_match(['linux']))
+@skipIf(archs=no_match(['i386', 'x86_64']))
+@skipIfRemote
+def test_basic_flow(self):
+"""Test collection, decoding, and dumping instructions"""
+lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+if not os.path.isfile(plugin_file):
+self.skipTest("features plugin missing.")
+
+self.build()
+
+self.runCmd("plugin load " + plugin_file)
+
+exe = self.getBuildArtifact("a.out")
+lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
+# We start tracing from main
+self.runCmd("processor-trace start all")
+
+# We check the trace after the for loop
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+self.runCmd("c")
+
+# We wait a little bit to ensure the processor has send the PT packets to
+# the memory
+time.sleep(.1)
+
+# We find the start address of the 'fun' function for a later check
+target = self.dbg.GetSelectedTarget()
+fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+.GetStartAddress().GetLoadAddress(target)
+
+# We print the last instructions
+self.expect("processor-trace show-instr-log -c 100",
+patterns=[
+# We expect to have seen the first instruction of 'fun'
+hex(fun_start_adddress),  
+# We expect to see the exit condition of the for loop
+"at main.cpp:" + str(line_number('main.cpp', '// Break for loop')) 
+])
+
+self.runCmd("processor-trace stop")
Index: lldb/test/API/tools/intel-features/intel-pt/test/Makefile
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254065.
wallace added a comment.

Addressed comments

Also ran the test in parallel to a 'stress -c 100 -i 100' invocation, and it
passed correctly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107

Files:
  lldb/test/API/tools/intel-features/intel-pt/test/Makefile
  lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
  lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
  lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp

Index: lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
===
--- lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -191,6 +191,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -290,6 +291,7 @@
  s.GetData());
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -428,6 +430,7 @@
   }
   result.AppendMessage(res.GetOutput());
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
@@ -480,6 +483,7 @@
   result.SetStatus(lldb::eReturnStatusFailed);
   return false;
 }
+result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
 return true;
   }
 
Index: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
@@ -0,0 +1,25 @@
+//===-- main.cpp *- C++ -*-===//
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//
+
+#include 
+
+using namespace std;
+
+int fun(int a) {
+  return a * a + 1;
+}
+
+int main() {
+  int z = 0;
+  for(int i = 0; i < 1; i++) { // Break for loop
+z += fun(z);
+  }
+
+  return 0; // Break 1
+}
Index: lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
===
--- /dev/null
+++ lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
@@ -0,0 +1,59 @@
+from __future__ import print_function
+
+import os
+import lldb
+import time
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestIntelPTSimpleBinary(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIf(oslist=no_match(['linux']))
+@skipIf(archs=no_match(['i386', 'x86_64']))
+@skipIfRemote
+def test_basic_flow(self):
+"""Test collection, decoding, and dumping instructions"""
+lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so")
+if not os.path.isfile(plugin_file):
+self.skipTest("features plugin missing.")
+
+self.build()
+
+self.runCmd("plugin load " + plugin_file)
+
+exe = self.getBuildArtifact("a.out")
+lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
+# We start tracing from main
+self.runCmd("processor-trace start all")
+
+# We check the trace after the for loop
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+self.runCmd("c")
+
+# We wait a little bit to ensure the processor has send the PT packets to
+# the memory
+time.sleep(.1)
+
+# We find the start address of the 'fun' function for a later check
+target = self.dbg.GetSelectedTarget()
+fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
+.GetStartAddress().GetLoadAddress(target)
+
+# We print the last instructions
+self.expect("processor-trace show-instr-log -c 100",
+patterns=[
+# We expect to have seen the first instruction of 'fun'
+hex(fun_start_adddress),  
+# We expect to see the exit condition of the for loop
+"at main.cpp:" + str(line_number('main.cpp', '// Break for loop')) 
+])
+
+self.runCmd("processor-trace stop")
Index: lldb/test/API/tools/intel-features/intel-pt/test/Makefile
===
--- /dev/null
+++ 

[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace marked 2 inline comments as done.
wallace added inline comments.



Comment at: 
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py:50-54
+"rand", # We expect to see a reference to the rand function
+# within the last instructions
+hex(fun_start_adddress),  # We expect to have seen the first
+  # instruction of 'fun'
+"at main.cpp:21" # We expect to see the exit condition of

labath wrote:
> labath wrote:
> > clayborg wrote:
> > > can we guarantee we will see any of these on a fully loaded machine 
> > > running many tests simultaneously? Maybe we need to settle for the header 
> > > of the output only to know that it tried to display something?
> > better avoid referencing functions from the system library... makes the 
> > test more hermetic
> What exactly is the case you're worried about? I'm not very familiar with how 
> all this works, but I would think that the kernel trace buffer for this is 
> application specific, and is automatically switched off when the os schedules 
> a different process (anything else would be a security breach). If that is 
> true, then we should have pretty good control over what goes into the buffer, 
> and we can ensure that it is: (a) big enough; and/or (b) application does not 
> execute too much code and overflows it (not calling rand would help us get a 
> reasonable upper bound on that).
> 
> (Nonetheless it would be good to run some stress tests to verify this is 
> stable.)
This is how it works: by default Intel PT has to be enabled on each logical 
CPU, where it traces everything, regardless of which thread if running. The 
kernel has the ability to switch Intel PT on and off on each logical CPU 
whenever there's a thread context switch, and this kind of filtering is what 
this LLDB plugin is using.

For some context, that kind of filtering is expensive because of the constant 
enabling/disabling of Intel PT and could incur in up to 5% total CPU cost 
according to Intel. Another drawback of this approach is that threads spawned 
by an already traced thread are not traced by default. The user has to enable 
filtered tracing explicitly for these threads.

A faster approach is to enable Intel PT on all CPUs without filtering. That 
leads to a ~2% total CPU cost according to some tests some colleagues and I 
ran. However, this needs having a secondary trace of context switches to be 
able to attribute Intel PT packets to individual threads. We are not following 
that approach in this plugin because of the added complexity. However, I plan 
to make this plugin flexible enough to be able to load Intel PT traces 
collected by other mechanisms which can do global tracing correctly.

Lastly, the PT Trace unit in the cpu writes PT packets on memory without 
interrupting the CPU itself nor the kernel. The only case in which packets 
couldn't be written is when the BUS is completely full. However, this is 
extremely rare and the CPU would retry later.

-
That being said, I see no reason why the trace wouldn't be collected at that 
point. Just in case I'll add a 0.1 ms wait time for the CPU to have enough time 
to send all the packets, which should be more than enough.



Comment at: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp:2-8
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//

labath wrote:
> We're not putting license headers on tests.
> 
> (Do these get automatically created by some IDEs or something? Can they be 
> configured not to do that?)
I just copy pasted it from another test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107



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


[Lldb-commits] [PATCH] D77186: [source maps] Ensure all valid source maps are added instead of failing with the first invalid one

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: clayborg, labath, kusmour, aadsm.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Several lldb-vscode users have noticed that when a source map rule is invalid 
(because a folder doesn't exist anymore), the rest of the source maps from 
their configurations are not applied.
This happens because lldb-vscode executes a single "settings set 
target.source-map" command with all the source maps and LLDB processes them one 
by one until one fails.

Instead of doing this, we can process in LLDB all the source map rules and 
apply the valid ones instead of failing fast.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77186

Files:
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/test/API/functionalities/source-map/TestTargetSourceMap.py

Index: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
===
--- lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
+++ lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
@@ -1,6 +1,7 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
+import os
 
 
 class TestTargetSourceMap(TestBase):
@@ -9,6 +10,20 @@
 
 @no_debug_info_test
 def test_source_map(self):
+def assertSourceMaps(src_path):
+# Set a breakpoint after we remap source and verify that it succeeds
+bp = target.BreakpointCreateByLocation(src_path, 2)
+self.assertEquals(bp.GetNumLocations(), 1,
+"make sure breakpoint was resolved with map")
+
+# Now make sure that we can actually FIND the source file using this
+# remapping:
+retval = lldb.SBCommandReturnObject()
+self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
+self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
+self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
+self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
+
 """Test target.source-map' functionality."""
 # Set the target soure map to map "./" to the current test directory
 src_dir = self.getSourceDir()
@@ -25,19 +40,28 @@
 bp = target.BreakpointCreateByLocation(src_path, 2)
 self.assertEquals(bp.GetNumLocations(), 0,
 "make sure no breakpoints were resolved without map")
-src_map_cmd = 'settings set target.source-map . "%s"' % (src_dir)
+
+src_map_cmd = 'settings set target.source-map . "%s" . "%s"' % (src_dir + "invalid_path", src_dir)
 self.dbg.HandleCommand(src_map_cmd)
+assertSourceMaps(src_path)
 
-# Set a breakpoint after we remap source and verify that it succeeds
-bp = target.BreakpointCreateByLocation(src_path, 2)
-self.assertEquals(bp.GetNumLocations(), 1,
-"make sure breakpoint was resolved with map")
-
-# Now make sure that we can actually FIND the source file using this
-# remapping:
-retval = lldb.SBCommandReturnObject()
-self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
-self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
-self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
-self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
-
+# Index 0 is the valid mapping, and modifying it to an invalid one should have no effect
+src_map_cmd = 'settings replace target.source-map 0 . "%s"' % (src_dir + "invalid_path")
+self.dbg.HandleCommand(src_map_cmd)
+assertSourceMaps(src_path)
+
+# Let's clear and add the mapping in with insert-after
+self.dbg.HandleCommand('settings remove target.source-map 0')
+# We add a valid but useless mapping so that we can use insert-after
+src_map_cmd = 'settings set target.source-map . "%s"' % (os.path.dirname(__file__))
+self.dbg.HandleCommand(src_map_cmd)
+
+src_map_cmd = 'settings insert-after target.source-map 0 . "%s" . "%s"' % (src_dir + "invalid_path", src_dir)
+self.dbg.HandleCommand(src_map_cmd)
+assertSourceMaps(src_path)
+
+# Let's clear and add the mapping in with append
+self.dbg.HandleCommand('settings remove target.source-map 0')
+src_map_cmd = 'settings append target.source-map . "%s" . "%s"' % (src_dir + "invalid_path", src_dir)
+self.dbg.HandleCommand(src_map_cmd)
+assertSourceMaps(src_path)
Index: lldb/source/Interpreter/OptionValuePathMappings.cpp
===
--- lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ 

[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254041.
wallace added a comment.

cleanup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968

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/breakpoint/Makefile
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
  lldb/test/API/tools/lldb-vscode/breakpoint/other.c
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -418,7 +418,16 @@
   bp.MatchesName(BreakpointBase::GetBreakpointLabel())) {
 auto bp_event = CreateEventObject("breakpoint");
 llvm::json::Object body;
-body.try_emplace("breakpoint", CreateBreakpoint(bp));
+// As VSCode already knows the path of this breakpoint, we don't
+// need to send it back as part of a "changed" event. This
+// prevent us from sending to VSCode paths that should be source
+// mapped. Note that CreateBreakpoint doesn't apply source mapping.
+// Besides, the current implementation of VSCode ignores the
+// "source" element of breakpoint events.
+llvm::json::Value source_bp = CreateBreakpoint(bp);
+source_bp.getAsObject()->erase("source");
+
+body.try_emplace("breakpoint", source_bp);
 body.try_emplace("reason", "changed");
 bp_event.try_emplace("body", std::move(body));
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
@@ -1364,13 +1373,13 @@
 llvm::sys::fs::set_current_path(debuggerRoot.data());
   }
 
-  SetSourceMapFromArguments(*arguments);
-
   // Run any initialize LLDB commands the user specified in the launch.json.
   // This is run before target is created, so commands can't do anything with
   // the targets - preRunCommands are run with the target.
   g_vsc.RunInitCommands();
 
+  SetSourceMapFromArguments(*arguments);
+
   lldb::SBError status;
   g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
   if (status.Fail()) {
@@ -1748,13 +1757,14 @@
 const auto _bp = existing_source_bps->second.find(src_bp.line);
 if (existing_bp != existing_source_bps->second.end()) {
   existing_bp->second.UpdateBreakpoint(src_bp);
-  AppendBreakpoint(existing_bp->second.bp, response_breakpoints);
+  AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
+   src_bp.line);
   continue;
 }
   }
   // At this point the breakpoint is new
   src_bp.SetBreakpoint(path.data());
-  AppendBreakpoint(src_bp.bp, response_breakpoints);
+  AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
   g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
 }
   }
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -184,28 +184,58 @@
 void SetValueForKey(lldb::SBValue , llvm::json::Object ,
 llvm::StringRef key);
 
-/// Converts \a bp to a JSON value and appends all locations to the
+/// Converts \a bp to a JSON value and appends the first valid location to the
 /// \a breakpoints array.
 ///
 /// \param[in] bp
-/// A LLDB breakpoint object which will get all locations extracted
-/// and converted into a JSON objects in the \a breakpoints array
+/// A LLDB breakpoint object which will get the first valid location
+/// extracted and converted into a JSON object in the \a breakpoints array
 ///
 /// \param[in] breakpoints
 /// A JSON array that will get a llvm::json::Value for \a bp
 /// appended to it.
-void AppendBreakpoint(lldb::SBBreakpoint , llvm::json::Array );
+///
+/// \param[in] request_path
+/// An optional source path to use when creating the "Source" object of this
+/// breakpoint. If not specified, the "Source" object is created from the
+/// breakpoint's address' LineEntry. It is useful to ensure the same source
+/// paths provided by the setBreakpoints request are returned to the IDE.
+///
+/// \param[in] request_line
+/// An optional line to use when creating the "Breakpoint" object to append.
+/// It is used if the breakpoint has no valid locations.
+/// It is useful to ensure the same line
+/// provided by the setBreakpoints request are returned to the IDE as a
+/// fallback.
+void 

[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Some included changes:

- Removed the "source" element if the "breakpoint" object returned in 
breakpoint events
- CreateBreakpoint now accepts an optional line number, which is used as 
fallback if no location is valid
- Added a test that asserts breakpoints in dynamically loaded libraries

I also tested the entire flow in VSCode and it was all fine


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968



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


[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-03-31 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 254039.
wallace added a comment.

Account for dynamically loaded libraries and update the logic for breakpoint 
events


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968

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/breakpoint/Makefile
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
  lldb/test/API/tools/lldb-vscode/breakpoint/other.c
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -418,7 +418,16 @@
   bp.MatchesName(BreakpointBase::GetBreakpointLabel())) {
 auto bp_event = CreateEventObject("breakpoint");
 llvm::json::Object body;
-body.try_emplace("breakpoint", CreateBreakpoint(bp));
+// As VSCode already knows the path of this breakpoint, we don't
+// need to send it back as part of a "changed" event. This
+// prevent us from sending to VSCode paths that should be source
+// mapped. Note that CreateBreakpoint doesn't apply source mapping.
+// Besides, the current implementation of VSCode ignores the
+// "source" element of breakpoint events.
+llvm::json::Value source_bp = CreateBreakpoint(bp);
+source_bp.getAsObject()->erase("source");
+
+body.try_emplace("breakpoint", source_bp);
 body.try_emplace("reason", "changed");
 bp_event.try_emplace("body", std::move(body));
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
@@ -1364,13 +1373,13 @@
 llvm::sys::fs::set_current_path(debuggerRoot.data());
   }
 
-  SetSourceMapFromArguments(*arguments);
-
   // Run any initialize LLDB commands the user specified in the launch.json.
   // This is run before target is created, so commands can't do anything with
   // the targets - preRunCommands are run with the target.
   g_vsc.RunInitCommands();
 
+  SetSourceMapFromArguments(*arguments);
+
   lldb::SBError status;
   g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
   if (status.Fail()) {
@@ -1748,13 +1757,14 @@
 const auto _bp = existing_source_bps->second.find(src_bp.line);
 if (existing_bp != existing_source_bps->second.end()) {
   existing_bp->second.UpdateBreakpoint(src_bp);
-  AppendBreakpoint(existing_bp->second.bp, response_breakpoints);
+  AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
+   src_bp.line);
   continue;
 }
   }
   // At this point the breakpoint is new
   src_bp.SetBreakpoint(path.data());
-  AppendBreakpoint(src_bp.bp, response_breakpoints);
+  AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
   g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
 }
   }
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -184,28 +184,58 @@
 void SetValueForKey(lldb::SBValue , llvm::json::Object ,
 llvm::StringRef key);
 
-/// Converts \a bp to a JSON value and appends all locations to the
+/// Converts \a bp to a JSON value and appends the first valid location to the
 /// \a breakpoints array.
 ///
 /// \param[in] bp
-/// A LLDB breakpoint object which will get all locations extracted
-/// and converted into a JSON objects in the \a breakpoints array
+/// A LLDB breakpoint object which will get the first valid location
+/// extracted and converted into a JSON object in the \a breakpoints array
 ///
 /// \param[in] breakpoints
 /// A JSON array that will get a llvm::json::Value for \a bp
 /// appended to it.
-void AppendBreakpoint(lldb::SBBreakpoint , llvm::json::Array );
+///
+/// \param[in] request_path
+/// An optional source path to use when creating the "Source" object of this
+/// breakpoint. If not specified, the "Source" object is created from the
+/// breakpoint's address' LineEntry. It is useful to ensure the same source
+/// paths provided by the setBreakpoints request are returned to the IDE.
+///
+/// \param[in] request_line
+/// An optional line to use when creating the "Breakpoint" object to append.
+/// It is used if the breakpoint has no valid locations.
+/// It is useful to ensure the same line
+/// provided by the setBreakpoints request 

Re: [Lldb-commits] [lldb] 64799fb - [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.

2020-03-31 Thread Davidino Italiano via lldb-commits
Folks, I don’t have a Windows or a Linux machine to try this, but please let me 
know or skip this test in case it breaks something.
I’ll try to keep an eye on the bots for notifications.

> On Mar 31, 2020, at 3:56 PM, Davide Italiano via lldb-commits 
>  wrote:
> 
> 
> Author: Davide Italiano
> Date: 2020-03-31T15:56:20-07:00
> New Revision: 64799fbebddc9877f78c7501b0b986b7afe84d6b
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/64799fbebddc9877f78c7501b0b986b7afe84d6b
> DIFF: 
> https://github.com/llvm/llvm-project/commit/64799fbebddc9877f78c7501b0b986b7afe84d6b.diff
> 
> LOG: [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.
> 
> This didn't happen for arm64 if you have watches for variables
> that are contigous in memory.
> 
> 
> 
> Added: 
>lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
>lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
>lldb/test/API/commands/watchpoints/watchpoint_count/main.c
> 
> Modified: 
>lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/test/API/commands/watchpoints/watchpoint_count/Makefile 
> b/lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
> new file mode 100644
> index ..10495940055b
> --- /dev/null
> +++ b/lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
> @@ -0,0 +1,3 @@
> +C_SOURCES := main.c
> +
> +include Makefile.rules
> 
> diff  --git 
> a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py 
> b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
> new file mode 100644
> index ..18667e913a94
> --- /dev/null
> +++ 
> b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
> @@ -0,0 +1,43 @@
> +import lldb
> +from lldbsuite.test.decorators import *
> +from lldbsuite.test.lldbtest import *
> +from lldbsuite.test import lldbutil
> +
> +class TestWatchpointCount(TestBase):
> +mydir = TestBase.compute_mydir(__file__)
> +NO_DEBUG_INFO_TESTCASE = True
> +
> +def setUp(self):
> +TestBase.setUp(self)
> +
> +def test_watchpoint_count(self):
> +self.build()
> +(_, process, thread, _) = lldbutil.run_to_source_breakpoint(self, 
> "patatino", lldb.SBFileSpec("main.c"))
> +frame = thread.GetFrameAtIndex(0)
> +first_var = frame.FindVariable("x1")
> +second_var = frame.FindVariable("x2")
> +
> +error = lldb.SBError()
> +first_watch = first_var.Watch(True, False, True, error)
> +if not error.Success():
> +self.fail(
> +"Failed to make watchpoint for x1: %s" %
> +(error.GetCString()))
> +
> +second_watch = second_var.Watch(True, False, True, error)
> +if not error.Success():
> +self.fail(
> +"Failed to make watchpoint for x2: %s" %
> +(error.GetCString()))
> +process.Continue()
> +
> +stop_reason = thread.GetStopReason()
> +self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, 
> "watchpoint for x1 not hit")
> +stop_reason_descr = thread.GetStopDescription(256)
> +self.assertEqual(stop_reason_descr, "watchpoint 1")
> +
> +process.Continue()
> +stop_reason = thread.GetStopReason()
> +self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, 
> "watchpoint for x2 not hit")
> +stop_reason_descr = thread.GetStopDescription(256)
> +self.assertEqual(stop_reason_descr, "watchpoint 2")
> 
> diff  --git a/lldb/test/API/commands/watchpoints/watchpoint_count/main.c 
> b/lldb/test/API/commands/watchpoints/watchpoint_count/main.c
> new file mode 100644
> index ..fc9a370e41f3
> --- /dev/null
> +++ b/lldb/test/API/commands/watchpoints/watchpoint_count/main.c
> @@ -0,0 +1,13 @@
> +#include 
> +#include 
> +
> +int main() {
> +  uint8_t x1 = 0;
> +  uint16_t x2 = 0;
> +
> +  printf("patatino\n");
> +
> +  x1 += 1;
> +  x2 += 2;
> +  return 0;
> +}
> 
> diff  --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
> b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
> index e5d4b05d987c..3e7bda88e6af 100644
> --- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
> +++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
> @@ -1067,31 +1067,34 @@ uint32_t 
> DNBArchMachARM64::GetHardwareWatchpointHit(nub_addr_t ) {
>"DNBArchMachARM64::GetHardwareWatchpointHit() addr = 
> 0x%llx",
>(uint64_t)addr);
> 
> -  // This is the watchpoint value to match against, i.e., word address.
> -  nub_addr_t wp_val = addr & ~((nub_addr_t)3);
>   if (kret == KERN_SUCCESS) {
> DBG _state = m_state.dbg;
> uint32_t i, num = NumSupportedHardwareWatchpoints();
> for (i = 0; i < num; ++i) {
> 

[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked an inline comment as done.
aprantl added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1260
+
+  module->Name = name.str();
+  return ast_source->RegisterModule(module);

teemperor wrote:
> Why is that done? The module should already have the correct name when it is 
> returned from findOrCreateModule (where we pass the same name and then create 
> the new module with that name).
> 
> If this line is removed, do we still need D75561?
Good catch! This is a leftover from my first version of the patch where I 
created the Module object manually without instantiating a clang::ModuleMap.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1256
+  name,
+  parent_desc ? const_cast(parent_desc->getModuleOrNull())
+  : nullptr,

here ^^


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

https://reviews.llvm.org/D75488



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


[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 254027.
aprantl marked an inline comment as done.
aprantl added a comment.

(Made const_cast explicit to illustrate mismatch.)

However, I still need to de-constify in order to create the module.


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

https://reviews.llvm.org/D75488

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/TypeSystem.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/A.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/B.h
  lldb/test/Shell/SymbolFile/DWARF/Inputs/ModuleOwnership/module.modulemap
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
  lldb/unittests/Symbol/TestTypeSystemClang.cpp
  lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Index: lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
===
--- lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
+++ lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h
@@ -28,8 +28,8 @@
 
 inline CompilerType createRecord(TypeSystemClang , llvm::StringRef name) {
   return ast.CreateRecordType(ast.getASTContext().getTranslationUnitDecl(),
-  lldb::AccessType::eAccessPublic, name, 0,
-  lldb::LanguageType::eLanguageTypeC);
+  OptionalClangModuleID(), lldb::AccessType::eAccessPublic, name,
+  0, lldb::LanguageType::eLanguageTypeC);
 }
 
 /// Create a record with the given name and a field with the given type
Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/Declaration.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "gtest/gtest.h"
 
@@ -257,9 +258,10 @@
   CompilerType basic_compiler_type = ast.GetBasicType(basic_type);
   EXPECT_TRUE(basic_compiler_type.IsValid());
 
-  CompilerType enum_type =
-  ast.CreateEnumerationType("my_enum", ast.GetTranslationUnitDecl(),
-Declaration(), basic_compiler_type, scoped);
+  CompilerType enum_type = ast.CreateEnumerationType(
+  "my_enum", ast.GetTranslationUnitDecl(), OptionalClangModuleID(), Declaration(),
+  basic_compiler_type, scoped);
+
   CompilerType t = ast.GetEnumerationIntegerType(enum_type);
   // Check that the type we put in at the start is found again.
   EXPECT_EQ(basic_compiler_type.GetTypeName(), t.GetTypeName());
@@ -267,14 +269,38 @@
   }
 }
 
+TEST_F(TestTypeSystemClang, TestOwningModule) {
+  TypeSystemClang ast("module_ast", HostInfo::GetTargetTriple());
+  CompilerType basic_compiler_type = ast.GetBasicType(BasicType::eBasicTypeInt);
+  CompilerType enum_type = ast.CreateEnumerationType(
+  "my_enum", ast.GetTranslationUnitDecl(), OptionalClangModuleID(100), Declaration(),
+  basic_compiler_type, false);
+  auto *ed = TypeSystemClang::GetAsEnumDecl(enum_type);
+  EXPECT_FALSE(!ed);
+  EXPECT_EQ(ed->getOwningModuleID(), 100u);
+
+  CompilerType record_type = ast.CreateRecordType(
+  nullptr, OptionalClangModuleID(200), lldb::eAccessPublic, "FooRecord",
+  clang::TTK_Struct, lldb::eLanguageTypeC_plus_plus, nullptr);
+  auto *rd = TypeSystemClang::GetAsRecordDecl(record_type);
+  EXPECT_FALSE(!rd);
+  EXPECT_EQ(rd->getOwningModuleID(), 200u);
+
+  CompilerType class_type = ast.CreateObjCClass(
+  "objc_class", ast.GetTranslationUnitDecl(), OptionalClangModuleID(300), false, false);
+  auto *cd = TypeSystemClang::GetAsObjCInterfaceDecl(class_type);
+  EXPECT_FALSE(!cd);
+  EXPECT_EQ(cd->getOwningModuleID(), 300u);
+}
+
 TEST_F(TestTypeSystemClang, TestIsClangType) {
   clang::ASTContext  = 

[Lldb-commits] [lldb] 64799fb - [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.

2020-03-31 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-03-31T15:56:20-07:00
New Revision: 64799fbebddc9877f78c7501b0b986b7afe84d6b

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

LOG: [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.

This didn't happen for arm64 if you have watches for variables
that are contigous in memory.



Added: 
lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
lldb/test/API/commands/watchpoints/watchpoint_count/main.c

Modified: 
lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Removed: 




diff  --git a/lldb/test/API/commands/watchpoints/watchpoint_count/Makefile 
b/lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
new file mode 100644
index ..10495940055b
--- /dev/null
+++ b/lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py 
b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
new file mode 100644
index ..18667e913a94
--- /dev/null
+++ b/lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
@@ -0,0 +1,43 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestWatchpointCount(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+
+def test_watchpoint_count(self):
+self.build()
+(_, process, thread, _) = lldbutil.run_to_source_breakpoint(self, 
"patatino", lldb.SBFileSpec("main.c"))
+frame = thread.GetFrameAtIndex(0)
+first_var = frame.FindVariable("x1")
+second_var = frame.FindVariable("x2")
+
+error = lldb.SBError()
+first_watch = first_var.Watch(True, False, True, error)
+if not error.Success():
+self.fail(
+"Failed to make watchpoint for x1: %s" %
+(error.GetCString()))
+
+second_watch = second_var.Watch(True, False, True, error)
+if not error.Success():
+self.fail(
+"Failed to make watchpoint for x2: %s" %
+(error.GetCString()))
+process.Continue()
+
+stop_reason = thread.GetStopReason()
+self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint 
for x1 not hit")
+stop_reason_descr = thread.GetStopDescription(256)
+self.assertEqual(stop_reason_descr, "watchpoint 1")
+
+process.Continue()
+stop_reason = thread.GetStopReason()
+self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint 
for x2 not hit")
+stop_reason_descr = thread.GetStopDescription(256)
+self.assertEqual(stop_reason_descr, "watchpoint 2")

diff  --git a/lldb/test/API/commands/watchpoints/watchpoint_count/main.c 
b/lldb/test/API/commands/watchpoints/watchpoint_count/main.c
new file mode 100644
index ..fc9a370e41f3
--- /dev/null
+++ b/lldb/test/API/commands/watchpoints/watchpoint_count/main.c
@@ -0,0 +1,13 @@
+#include 
+#include 
+
+int main() {
+  uint8_t x1 = 0;
+  uint16_t x2 = 0;
+
+  printf("patatino\n");
+
+  x1 += 1;
+  x2 += 2;
+  return 0;
+}

diff  --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index e5d4b05d987c..3e7bda88e6af 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -1067,31 +1067,34 @@ uint32_t 
DNBArchMachARM64::GetHardwareWatchpointHit(nub_addr_t ) {
"DNBArchMachARM64::GetHardwareWatchpointHit() addr = 
0x%llx",
(uint64_t)addr);
 
-  // This is the watchpoint value to match against, i.e., word address.
-  nub_addr_t wp_val = addr & ~((nub_addr_t)3);
   if (kret == KERN_SUCCESS) {
 DBG _state = m_state.dbg;
 uint32_t i, num = NumSupportedHardwareWatchpoints();
 for (i = 0; i < num; ++i) {
   nub_addr_t wp_addr = GetWatchAddress(debug_state, i);
-  DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchMachARM64::"
-"GetHardwareWatchpointHit() slot: %u "
-"(addr = 0x%llx).",
-   i, (uint64_t)wp_addr);
-  if (wp_val == wp_addr) {
-uint32_t byte_mask = bits(debug_state.__wcr[i], 12, 5);
-
-// Sanity check the byte_mask, first.
-if (LowestBitSet(byte_mask) < 0)
-  continue;
-
-  

[Lldb-commits] [PATCH] D77173: [PATCH] [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.

2020-03-31 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

I was a little worried about the case where we have an 8-byte region being 
watched that is 4-byte aligned (so it's spanning two 8-byte watchpoints), but a 
quick test of that with this patch shows it works correctly.  This is fine with 
me.


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

https://reviews.llvm.org/D77173



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


[Lldb-commits] [lldb] ec11c56 - Replace uint32_t with typedef (NFC)

2020-03-31 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-03-31T14:58:25-07:00
New Revision: ec11c5615a7c153a68d098903edebbb92719f5f9

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

LOG: Replace uint32_t with typedef (NFC)

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 7be259a85669..f355681f2679 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -61,7 +61,7 @@ class TypePayloadClang {
   TypePayloadClang() = default;
   explicit TypePayloadClang(bool is_complete_objc_class);
   explicit TypePayloadClang(uint32_t opaque_payload) : 
m_payload(opaque_payload) {}
-  operator uint32_t() { return m_payload; }
+  operator Type::Payload() { return m_payload; }
 
   static constexpr unsigned ObjCClassBit = 1 << 31;
   bool IsCompleteObjCClass() { return Flags(m_payload).Test(ObjCClassBit); }



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


[Lldb-commits] [lldb] 00efcd6 - Add a Type::Payload typedef. (NFC)

2020-03-31 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-03-31T14:32:53-07:00
New Revision: 00efcd6fffa533e5a4aa5646e678d57df0f9aca8

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

LOG: Add a Type::Payload typedef. (NFC)

This addresses review feedback from Raphael that I missed before
landing the change that introduced the payload field.

Added: 


Modified: 
lldb/include/lldb/Symbol/Type.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index d18027c7248c..dfff30029168 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -196,10 +196,11 @@ class Type : public std::enable_shared_from_this, 
public UserID {
 
   uint32_t GetEncodingMask();
 
+  typedef uint32_t Payload;
   /// Return the language-specific payload.
-  uint32_t GetPayload() { return m_payload; }
+  Payload GetPayload() { return m_payload; }
   /// Return the language-specific payload.
-  void SetPayload(uint32_t opaque_payload) { m_payload = opaque_payload; }
+  void SetPayload(Payload opaque_payload) { m_payload = opaque_payload; }
 
 protected:
   ConstString m_name;
@@ -215,7 +216,7 @@ class Type : public std::enable_shared_from_this, 
public UserID {
   CompilerType m_compiler_type;
   ResolveState m_compiler_type_resolve_state;
   /// Language-specific flags.
-  uint32_t m_payload;
+  Payload m_payload;
 
   Type *GetEncodingType();
 

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index a609b06d4e13..7be259a85669 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -56,7 +56,7 @@ class Declaration;
 /// The implementation of lldb::Type's m_payload field for TypeSystemClang.
 class TypePayloadClang {
   /// Layout: bit 31 ... IsCompleteObjCClass.
-  uint32_t m_payload = 0;
+  Type::Payload m_payload = 0;
 public:
   TypePayloadClang() = default;
   explicit TypePayloadClang(bool is_complete_objc_class);



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


[Lldb-commits] [PATCH] D77173: [PATCH] [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.

2020-03-31 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added a reviewer: jasonmolenda.
davide added a project: LLDB.
Herald added subscribers: danielkiss, kristof.beyls.

>From e330facaea0c3780734a6a061134551662fb9d74 Mon Sep 17 00:00:00 2001
From: Davide Italiano 
Date: Tue, 31 Mar 2020 13:55:36 -0700
Subject: [PATCH] [debugserver/ARM64] Make sure watchpoints hit are attributed
 correctly.

This didn't happen for arm64 if you have watches for variables
that are contigous in memory.


-

.../watchpoints/watchpoint_count/Makefile |  3 ++
 .../watchpoint_count/TestWatchpointCount.py   | 43 +++
 .../watchpoints/watchpoint_count/main.c   | 13 ++
 .../source/MacOSX/arm64/DNBArchImplARM64.cpp  | 43 ++-
 4 files changed, 82 insertions(+), 20 deletions(-)
 create mode 100644 lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
 create mode 100644 
lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
 create mode 100644 lldb/test/API/commands/watchpoints/watchpoint_count/main.c


https://reviews.llvm.org/D77173

Files:
  lldb/test/API/commands/watchpoints/watchpoint_count/Makefile
  lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
  lldb/test/API/commands/watchpoints/watchpoint_count/main.c
  lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Index: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
===
--- lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -1067,31 +1067,34 @@
"DNBArchMachARM64::GetHardwareWatchpointHit() addr = 0x%llx",
(uint64_t)addr);
 
-  // This is the watchpoint value to match against, i.e., word address.
-  nub_addr_t wp_val = addr & ~((nub_addr_t)3);
   if (kret == KERN_SUCCESS) {
 DBG _state = m_state.dbg;
 uint32_t i, num = NumSupportedHardwareWatchpoints();
 for (i = 0; i < num; ++i) {
   nub_addr_t wp_addr = GetWatchAddress(debug_state, i);
-  DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchMachARM64::"
-"GetHardwareWatchpointHit() slot: %u "
-"(addr = 0x%llx).",
-   i, (uint64_t)wp_addr);
-  if (wp_val == wp_addr) {
-uint32_t byte_mask = bits(debug_state.__wcr[i], 12, 5);
-
-// Sanity check the byte_mask, first.
-if (LowestBitSet(byte_mask) < 0)
-  continue;
-
-// Check that the watchpoint is enabled.
-if (!IsWatchpointEnabled(debug_state, i))
-  continue;
-
-// Compute the starting address (from the point of view of the
-// debugger).
-addr = wp_addr + LowestBitSet(byte_mask);
+  uint32_t byte_mask = bits(debug_state.__wcr[i], 12, 5);
+
+  DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::"
+   "GetHardwareWatchpointHit() slot: %u "
+   "(addr = 0x%llx; byte_mask = 0x%x)",
+   i, static_cast(wp_addr),
+   byte_mask);
+
+  if (!IsWatchpointEnabled(debug_state, i))
+continue;
+
+  if (bits(wp_addr, 48, 3) != bits(addr, 48, 3))
+continue;
+
+  // Sanity check the byte_mask
+  uint32_t lsb = LowestBitSet(byte_mask);
+  if (lsb < 0)
+continue;
+
+  uint64_t byte_to_match = bits(addr, 2, 0);
+
+  if (byte_mask & (1 << byte_to_match)) {
+addr = wp_addr + lsb;
 return i;
   }
 }
Index: lldb/test/API/commands/watchpoints/watchpoint_count/main.c
===
--- /dev/null
+++ lldb/test/API/commands/watchpoints/watchpoint_count/main.c
@@ -0,0 +1,13 @@
+#include 
+#include 
+
+int main() {
+  uint8_t x1 = 0;
+  uint16_t x2 = 0;
+
+  printf("patatino\n");
+
+  x1 += 1;
+  x2 += 2;
+  return 0;
+}
Index: lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
===
--- /dev/null
+++ lldb/test/API/commands/watchpoints/watchpoint_count/TestWatchpointCount.py
@@ -0,0 +1,43 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestWatchpointCount(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+
+def test_watchpoint_count(self):
+self.build()
+(_, process, thread, _) = lldbutil.run_to_source_breakpoint(self, "patatino", lldb.SBFileSpec("main.c"))
+frame = thread.GetFrameAtIndex(0)
+first_var = frame.FindVariable("x1")
+second_var = frame.FindVariable("x2")
+
+error = lldb.SBError()
+first_watch = first_var.Watch(True, False, True, error)
+if 

[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

CC'ing the DWARF cabal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D77108#1952818 , @aprantl wrote:

> For the future, a clean solution would be extending the macros in Dwarf.def 
> to list the stack effects in the definitions of the DW_OP_*, for example
>
>   // opcode, name, version, vendor, in, out
>   HANDLE_DW_OP(0x12, dup, 2, DWARF, 1, 2)
>


That sounds very interesting. However,

> Is there any DWARF operator where the stack effect (number of consumes & 
> produced stack elements) isn't statically known?

`DW_OP_pick` comes to mind.  It always produces one item, but it can reach 
arbitrarily deep into the dwarf stack (without consuming that item). Glancing 
through the dwarf spec, it looks like this is the only such operator, so 
special-casing that wouldn't be too bad...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [lldb] 015c6cd - Re-land "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"

2020-03-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-03-31T12:47:12-07:00
New Revision: 015c6cd47557272bb8b92fbf9f5bd2bcb8fa8989

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

LOG: Re-land "[lldb/Reproducers] Always collect the whole dSYM in the 
reproducer"

The FileCollector in LLDB collects every files that's used during a
debug session when capture is enabled. This ensures that the reproducer
only contains the files necessary to reproduce. This approach is not a
good fit for the dSYM bundle, which is a directory on disk, but should
be treated as a single unit.

On macOS LLDB have automatically find the matching dSYM for a binary by
its UUID. Having a incomplete dSYM in a reproducer can break debugging
even when reproducers are disabled.

This patch adds a was to specify a directory of interest to the
reproducers. It is called from SymbolVendorMacOSX with the path of the
dSYMs used by LLDB.

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

Added: 
lldb/test/Shell/Reproducer/TestDSYM.test

Modified: 
lldb/include/lldb/Utility/Reproducer.h
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/source/Utility/Reproducer.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index bffb0f7c0647..b8b897d02ea2 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -98,6 +98,8 @@ class FileProvider : public Provider {
 return m_collector;
   }
 
+  void recordInterestingDirectory(const llvm::Twine );
+
   void Keep() override {
 auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
 // Temporary files that are removed during execution can cause copy errors.

diff  --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp 
b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index 2b67fee70617..fc426d1c9c37 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -20,6 +20,7 @@
 #include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 
@@ -145,6 +146,11 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP 
_sp,
 }
 
 if (dsym_fspec) {
+  // Compute dSYM root.
+  std::string dsym_root = dsym_fspec.GetPath();
+  const size_t pos = dsym_root.find("/Contents/Resources/");
+  dsym_root = pos != std::string::npos ? dsym_root.substr(0, pos) : "";
+
   DataBufferSP dsym_file_data_sp;
   lldb::offset_t dsym_file_data_offset = 0;
   dsym_objfile_sp =
@@ -154,136 +160,132 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP 
_sp,
   if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get(), feedback_strm)) {
 // We need a XML parser if we hope to parse a plist...
 if (XMLDocument::XMLEnabled()) {
-  char dsym_path[PATH_MAX];
-  if (module_sp->GetSourceMappingList().IsEmpty() &&
-  dsym_fspec.GetPath(dsym_path, sizeof(dsym_path))) {
+  if (module_sp->GetSourceMappingList().IsEmpty()) {
 lldb_private::UUID dsym_uuid = dsym_objfile_sp->GetUUID();
 if (dsym_uuid) {
   std::string uuid_str = dsym_uuid.GetAsString();
-  if (!uuid_str.empty()) {
-char *resources = strstr(dsym_path, "/Contents/Resources/");
-if (resources) {
-  char dsym_uuid_plist_path[PATH_MAX];
-  resources[strlen("/Contents/Resources/")] = '\0';
-  snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path),
-   "%s%s.plist", dsym_path, uuid_str.c_str());
-  FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path);
-  if (FileSystem::Instance().Exists(dsym_uuid_plist_spec)) {
-ApplePropertyList plist(dsym_uuid_plist_path);
-if (plist) {
-  std::string DBGBuildSourcePath;
-  std::string DBGSourcePath;
-
-  // DBGSourcePathRemapping is a dictionary in the plist
-  // with keys which are DBGBuildSourcePath file paths and
-  // values which are DBGSourcePath file paths
-
-  StructuredData::ObjectSP plist_sp =
-  plist.GetStructuredData();
-  if (plist_sp.get() && plist_sp->GetAsDictionary() &&
-  plist_sp->GetAsDictionary()->HasKey(
-  "DBGSourcePathRemapping") &&
-  

[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-03-31 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp:13
 std::basic_string uchar(5, 'a');
+std::string *null = nullptr;
 S.assign(L"!"); // Set break point at this line.

How about `string_ptr_null` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77153



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


[Lldb-commits] [lldb] e8f13f4 - Replace std::string::find == 0 with StringRef::startswith

2020-03-31 Thread Benjamin Kramer via lldb-commits

Author: Benjamin Kramer
Date: 2020-03-31T21:01:09+02:00
New Revision: e8f13f4f62f52067cadb55f3c746ccf9d26ee2ce

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

LOG: Replace std::string::find == 0 with StringRef::startswith

This is both more readable and faster. Found by clang-tidy's
abseil-string-find-startswith.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/unittests/Analysis/CloneDetectionTest.cpp
lldb/source/Core/Module.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Symbol/Variable.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index dc31a5ab7b0f..b21cfac6e7ed 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -140,7 +140,8 @@ getAArch64MicroArchFeaturesFromMtune(const Driver , 
StringRef Mtune,
   // Handle CPU name is 'native'.
   if (MtuneLowerCase == "native")
 MtuneLowerCase = std::string(llvm::sys::getHostCPUName());
-  if (MtuneLowerCase == "cyclone" || MtuneLowerCase.find("apple") == 0) {
+  if (MtuneLowerCase == "cyclone" ||
+  StringRef(MtuneLowerCase).startswith("apple")) {
 Features.push_back("+zcm");
 Features.push_back("+zcz");
   }

diff  --git a/clang/unittests/Analysis/CloneDetectionTest.cpp 
b/clang/unittests/Analysis/CloneDetectionTest.cpp
index 03b63c400434..e09d0733f044 100644
--- a/clang/unittests/Analysis/CloneDetectionTest.cpp
+++ b/clang/unittests/Analysis/CloneDetectionTest.cpp
@@ -42,7 +42,7 @@ class NoBarFunctionConstraint {
   for (const StmtSequence  : {A, B}) {
 if (const auto *D =
 dyn_cast(Arg.getContainingDecl())) {
-  if (D->getNameAsString().find("bar") == 0)
+  if (StringRef(D->getNameAsString()).startswith("bar"))
 return false;
 }
   }

diff  --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index cff74dc9d518..fefc23a9b1c5 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1414,7 +1414,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec ) {
 if (FileSystem::Instance().IsDirectory(file)) {
   std::string new_path(file.GetPath());
   std::string old_path(obj_file->GetFileSpec().GetPath());
-  if (old_path.find(new_path) == 0) {
+  if (llvm::StringRef(old_path).startswith(new_path)) {
 // We specified the same bundle as the symbol file that we already
 // have
 return;

diff  --git 
a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp 
b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 47c7ae8c8d63..83cf9f8bd269 100644
--- 
a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ 
b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -88,7 +88,7 @@ ObjectContainerBSDArchive::Object::Extract(const 
DataExtractor ,
 return LLDB_INVALID_OFFSET;
 
   str.assign((const char *)data.GetData(, 16), 16);
-  if (str.find("#1/") == 0) {
+  if (llvm::StringRef(str).startswith("#1/")) {
 // If the name is longer than 16 bytes, or contains an embedded space then
 // it will use this format where the length of the name is here and the
 // name characters are after this header.

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index f5c84c6a6151..5044bed309dc 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5140,10 +5140,10 @@ uint32_t 
ObjectFileMachO::GetDependentModules(FileSpecList ) {
   std::string loader_path("@loader_path");
   std::string executable_path("@executable_path");
   for (auto  : rpath_paths) {
-if (rpath.find(loader_path) == 0) {
+if (llvm::StringRef(rpath).startswith(loader_path)) {
   rpath.erase(0, loader_path.size());
   rpath.insert(0, this_file_spec.GetDirectory().GetCString());
-} else if (rpath.find(executable_path) == 0) {
+} else if (llvm::StringRef(rpath).startswith(executable_path)) {
   rpath.erase(0, executable_path.size());
   rpath.insert(0, this_file_spec.GetDirectory().GetCString());
 }

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 

[Lldb-commits] [PATCH] D76872: [intel-pt] Fix existing support in LLDB

2020-03-31 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG128c0d037d32: [intel-pt] Fix existing support in LLDB 
(authored by Walter Erquinigo wall...@fb.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76872

Files:
  lldb/tools/intel-features/CMakeLists.txt
  lldb/tools/intel-features/intel-pt/Decoder.cpp
  lldb/tools/intel-features/intel-pt/Decoder.h

Index: lldb/tools/intel-features/intel-pt/Decoder.h
===
--- lldb/tools/intel-features/intel-pt/Decoder.h
+++ lldb/tools/intel-features/intel-pt/Decoder.h
@@ -245,6 +245,22 @@
   lldb::SBError ) const;
   void DecodeTrace(struct pt_insn_decoder *decoder,
Instructions _list, lldb::SBError );
+  int HandlePTInstructionEvents(pt_insn_decoder *decoder, int errcode,
+Instructions _list,
+lldb::SBError );
+
+  int AppendErrorToInstructionList(int errcode, pt_insn_decoder *decoder,
+   Instructions _list,
+   lldb::SBError );
+
+  void AppendErrorWithOffsetToInstructionList(int errcode,
+  uint64_t decoder_offset,
+  Instructions _list,
+  lldb::SBError );
+
+  void AppendErrorWithoutOffsetToInstructionList(int errcode,
+ Instructions _list,
+ lldb::SBError );
 
   // Function to diagnose and indicate errors during raw trace decoding
   void Diagnose(struct pt_insn_decoder *decoder, int errcode,
Index: lldb/tools/intel-features/intel-pt/Decoder.cpp
===
--- lldb/tools/intel-features/intel-pt/Decoder.cpp
+++ lldb/tools/intel-features/intel-pt/Decoder.cpp
@@ -564,6 +564,61 @@
   }
 }
 
+void Decoder::AppendErrorWithOffsetToInstructionList(
+int errcode, uint64_t decoder_offset, Instructions _list,
+lldb::SBError ) {
+  sberror.SetErrorStringWithFormat(
+  "processor trace decoding library: \"%s\"  [decoder_offset] => "
+  "[0x%" PRIu64 "]",
+  pt_errstr(pt_errcode(errcode)), decoder_offset);
+  instruction_list.emplace_back(sberror.GetCString());
+}
+
+void Decoder::AppendErrorWithoutOffsetToInstructionList(
+int errcode, Instructions _list, lldb::SBError ) {
+  sberror.SetErrorStringWithFormat("processor trace decoding library: \"%s\"",
+   pt_errstr(pt_errcode(errcode)));
+  instruction_list.emplace_back(sberror.GetCString());
+}
+
+int Decoder::AppendErrorToInstructionList(int errcode, pt_insn_decoder *decoder,
+  Instructions _list,
+  lldb::SBError ) {
+  uint64_t decoder_offset = 0;
+  int errcode_off = pt_insn_get_offset(decoder, _offset);
+  if (errcode_off < 0) {
+AppendErrorWithoutOffsetToInstructionList(errcode, instruction_list,
+  sberror);
+return errcode_off;
+  }
+  AppendErrorWithOffsetToInstructionList(errcode, decoder_offset,
+ instruction_list, sberror);
+  return 0;
+}
+
+int Decoder::HandlePTInstructionEvents(pt_insn_decoder *decoder, int errcode,
+   Instructions _list,
+   lldb::SBError ) {
+  while (errcode & pts_event_pending) {
+pt_event event;
+errcode = pt_insn_event(decoder, , sizeof(event));
+if (errcode < 0)
+  return errcode;
+
+// The list of events are in
+// https://github.com/intel/libipt/blob/master/doc/man/pt_qry_event.3.md
+if (event.type == ptev_overflow) {
+  int append_errcode = AppendErrorToInstructionList(
+  errcode, decoder, instruction_list, sberror);
+  if (append_errcode < 0)
+return append_errcode;
+}
+// Other events don't signal stream errors
+  }
+
+  return 0;
+}
+
 // Start actual decoding of raw trace
 void Decoder::DecodeTrace(struct pt_insn_decoder *decoder,
   Instructions _list,
@@ -585,10 +640,8 @@
 
   int errcode_off = pt_insn_get_offset(decoder, _offset);
   if (errcode_off < 0) {
-sberror.SetErrorStringWithFormat(
-"processor trace decoding library: \"%s\"",
-pt_errstr(pt_errcode(errcode)));
-instruction_list.emplace_back(sberror.GetCString());
+AppendErrorWithoutOffsetToInstructionList(errcode, instruction_list,
+  sberror);
 return;
   }
 
@@ -619,16 +672,22 @@
   // progress further. Hence, returning in this situation.
   return;
 }
-

[Lldb-commits] [lldb] 128c0d0 - [intel-pt] Fix existing support in LLDB

2020-03-31 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2020-03-31T11:32:34-07:00
New Revision: 128c0d037d32c929c58d63fd7f324038430f73ba

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

LOG: [intel-pt] Fix existing support in LLDB

Summary:
//reviews.llvm.org/D33035 added in 2017 basic support for intel-pt. I
plan to improve it and use it to support reverse debugging.

I fixed a couple of issues and now this plugin works again:
1. pythonlib needed to be linked against it for the SB framework.
Linking was failing because of this
2. the decoding functionality was broken because it lacked handling for
instruction events. It seems old versions of libipt, the actual decoding
library, didn't require these, but modern version require it (you can
read more here
https://github.com/intel/libipt/blob/master/doc/howto_libipt.md). These
events signal overflows of the internal PT buffer in the CPU,
enable/disable events of tracing, async cpu events, interrupts, etc.

I ended up refactoring a little bit the code to reduce code duplication.

In another diff I'll implement some basic tests.

This is a simple execution of the library:

(lldb) target create "/data/users/wallace/rr-project/a.out"
Current executable set to '/data/users/wallace/rr-project/a.out' (x86_64).
(lldb) plugin load liblldbIntelFeatures.so
(lldb) b main
Breakpoint 1: where = a.out`main + 8 at test.cpp:10, address = 
0x004007fa
(lldb) b test.cpp:14
Breakpoint 2: where = a.out`main + 50 at test.cpp:14, address = 
0x00400824
(lldb) r
Process 902754 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x004007fa a.out`main at test.cpp:10
   7}
   8
   9int main() {
-> 10 int z = 0;
   11 for(int i = 0; i < 1; i++)
   12   z += fun(z);
   13

Process 902754 launched: '/data/users/wallace/rr-project/a.out' (x86_64)
(lldb) processor-trace start all
(lldb) c
Process 902754 resuming
Process 902754 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 2.1
frame #0: 0x00400824 a.out`main at test.cpp:14
   11 for(int i = 0; i < 1; i++)
   12   z += fun(z);
   13
-> 14 cout << z<< endl;
   15 return 0;
   16   }

(lldb) processor-trace show-instr-log
thread #1: tid=902754
0x772299b9 <+9>: addq   $0x8, %rsp
0x772299bd <+13>: retq
0x4007ed <+16>: addl   $0x1, %eax
0x4007f0 <+19>: leave
0x4007f1 <+20>: retq
0x400814 <+34>: addl   %eax, -0x4(%rbp)
0x400817 <+37>: addl   $0x1, -0x8(%rbp)
0x40081b <+41>: cmpl   $0x270f, -0x8(%rbp)   ; imm = 0x270F
0x400822 <+48>: jle0x40080a  ; <+24> at test.cpp:12
0x400822 <+48>: jle0x40080a  ; <+24> at test.cpp:12
```

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/tools/intel-features/CMakeLists.txt
lldb/tools/intel-features/intel-pt/Decoder.cpp
lldb/tools/intel-features/intel-pt/Decoder.h

Removed: 




diff  --git a/lldb/tools/intel-features/CMakeLists.txt 
b/lldb/tools/intel-features/CMakeLists.txt
index aff75d7db334..efba2f74904f 100644
--- a/lldb/tools/intel-features/CMakeLists.txt
+++ b/lldb/tools/intel-features/CMakeLists.txt
@@ -56,6 +56,7 @@ add_lldb_library(lldbIntelFeatures SHARED
 
   LINK_LIBS
 ${FEATURE_LIBS}
+${PYTHON_LIBRARY}
   )
 
 # Add link dependencies for python wrapper

diff  --git a/lldb/tools/intel-features/intel-pt/Decoder.cpp 
b/lldb/tools/intel-features/intel-pt/Decoder.cpp
index 2ce5c985c546..21642c75327a 100644
--- a/lldb/tools/intel-features/intel-pt/Decoder.cpp
+++ b/lldb/tools/intel-features/intel-pt/Decoder.cpp
@@ -564,6 +564,61 @@ void Decoder::InitializePTInstDecoder(
   }
 }
 
+void Decoder::AppendErrorWithOffsetToInstructionList(
+int errcode, uint64_t decoder_offset, Instructions _list,
+lldb::SBError ) {
+  sberror.SetErrorStringWithFormat(
+  "processor trace decoding library: \"%s\"  [decoder_offset] => "
+  "[0x%" PRIu64 "]",
+  pt_errstr(pt_errcode(errcode)), decoder_offset);
+  instruction_list.emplace_back(sberror.GetCString());
+}
+
+void Decoder::AppendErrorWithoutOffsetToInstructionList(
+int errcode, Instructions _list, lldb::SBError ) {
+  sberror.SetErrorStringWithFormat("processor trace decoding library: \"%s\"",
+   pt_errstr(pt_errcode(errcode)));
+  instruction_list.emplace_back(sberror.GetCString());
+}
+
+int Decoder::AppendErrorToInstructionList(int errcode, pt_insn_decoder 
*decoder,
+  Instructions _list,
+  lldb::SBError ) {
+  uint64_t decoder_offset = 0;
+  int errcode_off = pt_insn_get_offset(decoder, _offset);
+  if (errcode_off < 

[Lldb-commits] [PATCH] D75562: Add an opque payload field to lldb::Type (NFC).

2020-03-31 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b06cb452308: Add an opque payload field to lldb::Type 
(NFC). (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D75562?vs=253226=253937#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75562

Files:
  lldb/include/lldb/Symbol/Type.h
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/Type.cpp

Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -143,15 +143,14 @@
llvm::Optional byte_size, SymbolContextScope *context,
user_id_t encoding_uid, EncodingDataType encoding_uid_type,
const Declaration , const CompilerType _type,
-   ResolveState compiler_type_resolve_state)
+   ResolveState compiler_type_resolve_state, uint32_t opaque_payload)
 : std::enable_shared_from_this(), UserID(uid), m_name(name),
   m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr),
   m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
   m_decl(decl), m_compiler_type(compiler_type),
-  m_compiler_type_resolve_state(
-  compiler_type ? compiler_type_resolve_state
-: ResolveState::Unresolved),
-  m_is_complete_objc_class(false) {
+  m_compiler_type_resolve_state(compiler_type ? compiler_type_resolve_state
+  : ResolveState::Unresolved),
+  m_payload(opaque_payload) {
   if (byte_size) {
 m_byte_size = *byte_size;
 m_byte_size_has_value = true;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -33,6 +33,7 @@
 #include "lldb/Symbol/TypeSystem.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Logging.h"
 #include "lldb/lldb-enumerations.h"
@@ -42,7 +43,9 @@
 
 namespace clang {
 class FileManager;
-}
+class HeaderSearch;
+class ModuleMap;
+} // namespace clang
 
 namespace lldb_private {
 
@@ -50,6 +53,24 @@
 class ClangASTSource;
 class Declaration;
 
+/// The implementation of lldb::Type's m_payload field for TypeSystemClang.
+class TypePayloadClang {
+  /// Layout: bit 31 ... IsCompleteObjCClass.
+  uint32_t m_payload = 0;
+public:
+  TypePayloadClang() = default;
+  explicit TypePayloadClang(bool is_complete_objc_class);
+  explicit TypePayloadClang(uint32_t opaque_payload) : m_payload(opaque_payload) {}
+  operator uint32_t() { return m_payload; }
+
+  static constexpr unsigned ObjCClassBit = 1 << 31;
+  bool IsCompleteObjCClass() { return Flags(m_payload).Test(ObjCClassBit); }
+  void SetIsCompleteObjCClass(bool is_complete_objc_class) {
+m_payload = is_complete_objc_class ? Flags(m_payload).Set(ObjCClassBit)
+   : Flags(m_payload).Clear(ObjCClassBit);
+  }
+};
+  
 /// A TypeSystem implementation based on Clang.
 ///
 /// This class uses a single clang::ASTContext as the backend for storing
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -316,6 +316,10 @@
   return *g_map_ptr;
 }
 
+TypePayloadClang::TypePayloadClang(bool is_complete_objc_class) {
+  SetIsCompleteObjCClass(is_complete_objc_class);
+}
+
 char TypeSystemClang::ID;
 
 bool TypeSystemClang::IsOperator(llvm::StringRef name,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1634,12 +1634,11 @@
   // parameters in any class methods need it for the clang types for
   // function prototypes.
   LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
-  type_sp = std::make_shared(die.GetID(), dwarf, attrs.name,
-   attrs.byte_size, nullptr, LLDB_INVALID_UID,
-   Type::eEncodingIsUID, ,
-   clang_type, Type::ResolveState::Forward);
-
-  type_sp->SetIsCompleteObjCClass(attrs.is_complete_objc_class);
+  type_sp = std::make_shared(
+  

[Lldb-commits] [lldb] 7b06cb4 - Add an opque payload field to lldb::Type (NFC).

2020-03-31 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-03-31T11:14:12-07:00
New Revision: 7b06cb4523083206ad79776c80a564cd26bd8326

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

LOG: Add an opque payload field to lldb::Type (NFC).

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

Added: 


Modified: 
lldb/include/lldb/Symbol/Type.h
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/Type.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 11b83d7734b9..d18027c7248c 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -97,7 +97,7 @@ class Type : public std::enable_shared_from_this, 
public UserID {
llvm::Optional byte_size, SymbolContextScope *context,
lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type,
const Declaration , const CompilerType _qual_type,
-   ResolveState compiler_type_resolve_state);
+   ResolveState compiler_type_resolve_state, uint32_t opaque_payload = 0);
 
   // This makes an invalid type.  Used for functions that return a Type when
   // they get an error.
@@ -196,11 +196,10 @@ class Type : public std::enable_shared_from_this, 
public UserID {
 
   uint32_t GetEncodingMask();
 
-  bool IsCompleteObjCClass() { return m_is_complete_objc_class; }
-
-  void SetIsCompleteObjCClass(bool is_complete_objc_class) {
-m_is_complete_objc_class = is_complete_objc_class;
-  }
+  /// Return the language-specific payload.
+  uint32_t GetPayload() { return m_payload; }
+  /// Return the language-specific payload.
+  void SetPayload(uint32_t opaque_payload) { m_payload = opaque_payload; }
 
 protected:
   ConstString m_name;
@@ -215,7 +214,8 @@ class Type : public std::enable_shared_from_this, 
public UserID {
   Declaration m_decl;
   CompilerType m_compiler_type;
   ResolveState m_compiler_type_resolve_state;
-  bool m_is_complete_objc_class;
+  /// Language-specific flags.
+  uint32_t m_payload;
 
   Type *GetEncodingType();
 

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 459e02e55745..5fb03a67fcf9 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -129,7 +129,7 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString 
) {
 
   if (TypeSystemClang::IsObjCObjectOrInterfaceType(
   type_sp->GetForwardCompilerType())) {
-if (type_sp->IsCompleteObjCClass()) {
+if (TypePayloadClang(type_sp->GetPayload()).IsCompleteObjCClass()) {
   m_complete_class_cache[name] = type_sp;
   return type_sp;
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 760933bf898e..96500da4c516 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1634,12 +1634,11 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext ,
   // parameters in any class methods need it for the clang types for
   // function prototypes.
   LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
-  type_sp = std::make_shared(die.GetID(), dwarf, attrs.name,
-   attrs.byte_size, nullptr, LLDB_INVALID_UID,
-   Type::eEncodingIsUID, ,
-   clang_type, Type::ResolveState::Forward);
-
-  type_sp->SetIsCompleteObjCClass(attrs.is_complete_objc_class);
+  type_sp = std::make_shared(
+  die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
+  LLDB_INVALID_UID, Type::eEncodingIsUID, , clang_type,
+  Type::ResolveState::Forward,
+  TypePayloadClang(attrs.is_complete_objc_class));
 
   // Add our type to the unique type map so we don't end up creating many
   // copies of the same type over and over in the ASTContext for our

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index a94e5a15fa68..22f401fa4e95 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -316,6 +316,10 @@ static ClangASTMap () {
   return *g_map_ptr;
 }
 
+TypePayloadClang::TypePayloadClang(bool is_complete_objc_class) {
+  SetIsCompleteObjCClass(is_complete_objc_class);
+}
+
 

[Lldb-commits] [lldb] 75cfd38 - Revert "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"

2020-03-31 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-03-31T10:56:02-07:00
New Revision: 75cfd382201978615cca1c91c2d9f14f8b7af56d

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

LOG: Revert "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"

This reverts commit 38ddb49e5242920e44a982cff7bbe2e86bd23a69 as it
breaks the macOS bots.

Added: 


Modified: 
lldb/include/lldb/Utility/Reproducer.h
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/source/Utility/Reproducer.cpp

Removed: 
lldb/test/Shell/Reproducer/TestDSYM.test



diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index b8b897d02ea2..bffb0f7c0647 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -98,8 +98,6 @@ class FileProvider : public Provider {
 return m_collector;
   }
 
-  void recordInterestingDirectory(const llvm::Twine );
-
   void Keep() override {
 auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
 // Temporary files that are removed during execution can cause copy errors.

diff  --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp 
b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index e819c342c6ec..2b67fee70617 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -20,7 +20,6 @@
 #include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 
@@ -146,11 +145,6 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP 
_sp,
 }
 
 if (dsym_fspec) {
-  // Compute dSYM root.
-  std::string dsym_root = dsym_fspec.GetPath();
-  const size_t pos = dsym_root.find("/Contents/Resources/");
-  dsym_root = pos != std::string::npos ? dsym_root.substr(0, pos) : "";
-
   DataBufferSP dsym_file_data_sp;
   lldb::offset_t dsym_file_data_offset = 0;
   dsym_objfile_sp =
@@ -160,132 +154,136 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP 
_sp,
   if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get(), feedback_strm)) {
 // We need a XML parser if we hope to parse a plist...
 if (XMLDocument::XMLEnabled()) {
-  if (module_sp->GetSourceMappingList().IsEmpty()) {
+  char dsym_path[PATH_MAX];
+  if (module_sp->GetSourceMappingList().IsEmpty() &&
+  dsym_fspec.GetPath(dsym_path, sizeof(dsym_path))) {
 lldb_private::UUID dsym_uuid = dsym_objfile_sp->GetUUID();
 if (dsym_uuid) {
   std::string uuid_str = dsym_uuid.GetAsString();
-  if (!uuid_str.empty() && !dsym_root.empty()) {
-char dsym_uuid_plist_path[PATH_MAX];
-snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path),
- "%s/Contents/Resources/%s.plist", dsym_root.c_str(),
- uuid_str.c_str());
-FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path);
-if (FileSystem::Instance().Exists(dsym_uuid_plist_spec)) {
-  ApplePropertyList plist(dsym_uuid_plist_path);
-  if (plist) {
-std::string DBGBuildSourcePath;
-std::string DBGSourcePath;
-
-// DBGSourcePathRemapping is a dictionary in the plist
-// with keys which are DBGBuildSourcePath file paths and
-// values which are DBGSourcePath file paths
-
-StructuredData::ObjectSP plist_sp =
-plist.GetStructuredData();
-if (plist_sp.get() && plist_sp->GetAsDictionary() &&
-plist_sp->GetAsDictionary()->HasKey(
-"DBGSourcePathRemapping") &&
-plist_sp->GetAsDictionary()
-->GetValueForKey("DBGSourcePathRemapping")
-->GetAsDictionary()) {
-
-  // If DBGVersion 1 or DBGVersion missing, ignore
-  // DBGSourcePathRemapping. If DBGVersion 2, strip last 
two
-  // components of path remappings from
-  //  entries to fix an issue with a
-  //  specific set of 
DBGSourcePathRemapping
-  //  entries that lldb worked with.
-  // If DBGVersion 3, trust & use the source path 
remappings
-  // as-is.
-  //
-
- 

[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-03-31 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

I haven't tested the libstdc++ part, would be great if someone could confirm 
this works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77153



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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-03-31 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: jingham, labath.
Herald added a project: LLDB.
friss added a comment.

I haven't tested the libstdc++ part, would be great if someone could confirm 
this works.


The original motivation for this patch was to display a null
std::string pointer as nullptr instead of "", but the fix
seemed generic enough to be done for all C++ summary providers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77153

Files:
  lldb/source/DataFormatters/TypeSummary.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
@@ -10,6 +10,7 @@
 std::string q("hello world");
 std::string Q("quite a long std::strin with lots of info inside it");
 std::basic_string uchar(5, 'a');
+std::string *null = nullptr;
 S.assign(L"!"); // Set break point at this line.
 return 0;
 }
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
@@ -59,6 +59,7 @@
 var_q = self.frame().FindVariable('q')
 var_Q = self.frame().FindVariable('Q')
 var_uchar = self.frame().FindVariable('uchar')
+var_null = self.frame().FindVariable('null')
 
 self.assertEqual(var_wempty.GetSummary(), 'L""', "wempty summary 
wrong")
 self.assertEqual(
@@ -76,6 +77,7 @@
 var_Q.GetSummary(), '"quite a long std::strin with lots of info 
inside it"',
 "Q summary wrong")
 self.assertEqual(var_uchar.GetSummary(), '"a"', "u summary wrong")
+self.assertEqual(var_null.GetSummary(), 'nullptr', "null summary 
wrong")
 
 self.runCmd("next")
 
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
@@ -71,6 +71,7 @@
 std::u32string u32_string(U"");
 std::u32string u32_empty(U"");
 std::basic_string uchar(5, 'a');
+std::string *null = nullptr;
 
 #if _LIBCPP_ABI_VERSION == 1
 std::string garbage1, garbage2, garbage3, garbage4, garbage5;
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -77,6 +77,7 @@
 '(%s::u32string) u32_empty = ""'%ns,
 '(%s::basic_string, '
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
+'(std::string *) null = nullptr',
 ])
 
 self.runCmd("n")
@@ -114,6 +115,7 @@
 '(%s::u32string) u32_empty = ""'%ns,
 '(%s::basic_string, '
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
+'(std::string *) null = nullptr',
 ])
 
 # The test assumes that std::string is in its cap-size-data layout.
Index: lldb/source/DataFormatters/TypeSummary.cpp
===
--- lldb/source/DataFormatters/TypeSummary.cpp
+++ lldb/source/DataFormatters/TypeSummary.cpp
@@ -123,6 +123,17 @@
 std::string ,
 const TypeSummaryOptions ) 
{
   dest.clear();
+
+  if (valobj && valobj->IsPointerType()) {
+bool success = true;
+if (!valobj->GetValueAsUnsigned(0, )) {
+  if (!success)
+return false;
+  dest = "nullptr";
+  return true;
+}
+  }
+
   StreamString stream;
   if (!m_impl || !m_impl(*valobj, stream, options))
 return false;


Index: 

[Lldb-commits] [PATCH] D75562: Add an opque payload field to lldb::Type (NFC).

2020-03-31 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Could you make the `uint32_t` a typedef? I'm fine with this not being 
type-safe, but a typedef would at least allow me to search for where this 
information is used. Grepping/searching for `uint32_t` isn't a great 
experience. It would also make this interface more self-documenting.

Beside that LGTM.


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

https://reviews.llvm.org/D75562



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


[Lldb-commits] [lldb] 5c2bf57 - [lldb/API] Add missing reproducer instrumentation to GetHostPlatform.

2020-03-31 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-03-31T10:45:25-07:00
New Revision: 5c2bf577dcd34b0f4a20360d411e410d739b752f

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

LOG: [lldb/API] Add missing reproducer instrumentation to GetHostPlatform.

SBPlatform::GetHostPlatform was missing the reproducer instrumentation
macros. Fixed by running lldb-instr on SBPlatform.cpp:

$ ./bin/lldb-instr ../llvm-project/lldb/source/API/SBPlatform.cpp

Added: 


Modified: 
lldb/source/API/SBPlatform.cpp

Removed: 




diff  --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index ddb77f4f008a..7ac852488ffb 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -306,9 +306,12 @@ SBPlatform ::operator=(const SBPlatform ) {
 SBPlatform::~SBPlatform() = default;
 
 SBPlatform SBPlatform::GetHostPlatform() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBPlatform, SBPlatform,
+GetHostPlatform);
+
   SBPlatform host_platform;
   host_platform.m_opaque_sp = Platform::GetHostPlatform();
-  return host_platform;
+  return LLDB_RECORD_RESULT(host_platform);
 }
 
 bool SBPlatform::IsValid() const {
@@ -756,6 +759,8 @@ void RegisterMethods(Registry ) {
   LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBPlatform, GetEnvironment, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals,
  ());
+  LLDB_REGISTER_STATIC_METHOD(lldb::SBPlatform, SBPlatform, GetHostPlatform,
+  ());
 }
 
 }



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


[Lldb-commits] [PATCH] D75488: Preserve the owning module information from DWARF in the synthesized AST

2020-03-31 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

Sorry for resetting this back from accepted :)




Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1260
+
+  module->Name = name.str();
+  return ast_source->RegisterModule(module);

Why is that done? The module should already have the correct name when it is 
returned from findOrCreateModule (where we pass the same name and then create 
the new module with that name).

If this line is removed, do we still need D75561?


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

https://reviews.llvm.org/D75488



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

For the future, a clean solution would be extending the macros in Dwarf.def to 
list the stack effects in the definitions of the DW_OP_*, for example

  // opcode, name, version, vendor, in, out
  HANDLE_DW_OP(0x12, dup, 2, DWARF, 1, 2)

and then we could write a static verifier that ensures that the stack effects 
of an entire expression is sound. (And we could check this in LLVM, already, 
too).

Is there any DWARF operator where the stack effect (number of consumes & 
produced stack elements) isn't statically known?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf3a7d790df33: [lldb/DWARF] Fix evaluator crash when 
accessing empty stack. (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@
   llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
+  if (stack.empty()) {
+if (error_ptr)
+  error_ptr->SetErrorString(
+  "Expression stack needs at least 1 item for DW_OP_stack_value.");
+return false;
+  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@
   llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
+  if (stack.empty()) {
+if (error_ptr)
+  error_ptr->SetErrorString(
+  "Expression stack needs at least 1 item for DW_OP_stack_value.");
+return false;
+  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 253895.
mib marked an inline comment as done.
mib added a comment.

Addressed Pavel's request.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@
   llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
+  if (stack.empty()) {
+if (error_ptr)
+  error_ptr->SetErrorString(
+  "Expression stack needs at least 1 item for DW_OP_stack_value.");
+return false;
+  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 


Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@
   llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
+  if (stack.empty()) {
+if (error_ptr)
+  error_ptr->SetErrorString(
+  "Expression stack needs at least 1 item for DW_OP_stack_value.");
+return false;
+  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D77108#1951610 , @aprantl wrote:

> This is obviously good! Do you think that a similar error handling bug might 
> exist in other cases that depend top-of-stack?


I quickly ran through the function, and it seems this was the only location 
where we were missing the check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [lldb] e4a7780 - Revert "[lldb/DWARF] Fix evaluator crash when accessing empty stack."

2020-03-31 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-03-31T17:44:17+02:00
New Revision: e4a778052e98c6d67f601342a7ca3b3c52ce7fbd

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

LOG: Revert "[lldb/DWARF] Fix evaluator crash when accessing empty stack."

This reverts commit e26eece1e2e7d7e6fbadb1207afef9b6353b5330.

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 04fbfccd0c2e..7f12d06450c6 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2318,12 +2318,6 @@ bool DWARFExpression::Evaluate(
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
-  if (stack.empty()) {
-if (error_ptr)
-  error_ptr->SetErrorString(
-  "Expression stack needs at least 1 item for DW_OP_stack_value.");
-return false;
-  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 4c4281983078..64755a9066de 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,10 +234,6 @@ TEST(DWARFExpression, DW_OP_convert) {
   llvm::Failed());
 }
 
-TEST(DWARFExpression, DW_OP_stack_value) {
-  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
-}
-
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),



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


[Lldb-commits] [lldb] f3a7d79 - [lldb/DWARF] Fix evaluator crash when accessing empty stack.

2020-03-31 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-03-31T17:44:57+02:00
New Revision: f3a7d790df3357d52c10ec5ef48606944bcf5c6c

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

LOG: [lldb/DWARF] Fix evaluator crash when accessing empty stack.

This patch fixes a crash that happens on the DWARF expression evaluator
when trying to access the top of the stack while it's empty.

rdar://60512489

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 7f12d06450c6..04fbfccd0c2e 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@ bool DWARFExpression::Evaluate(
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
+  if (stack.empty()) {
+if (error_ptr)
+  error_ptr->SetErrorString(
+  "Expression stack needs at least 1 item for DW_OP_stack_value.");
+return false;
+  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 64755a9066de..4c4281983078 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@ TEST(DWARFExpression, DW_OP_convert) {
   llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),



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


[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-31 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 253874.
ikudrin marked 4 inline comments as done.
ikudrin added a comment.

- Updated the comment for `DWARFSectionKind`.
- Simplified the storing of raw section identifiers.
- Moved independent changes into separate patches.


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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0

[Lldb-commits] [PATCH] D74023: [RISCV] ELF attribute section for RISC-V

2020-03-31 Thread Hsiangkai Wang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG581ba35291a6: [RISCV] ELF attribute section for RISC-V. 
(authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74023

Files:
  lld/ELF/InputFiles.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/Object/ELFObjectFile.h
  llvm/include/llvm/Support/ARMAttributeParser.h
  llvm/include/llvm/Support/ARMBuildAttributes.h
  llvm/include/llvm/Support/ELFAttributeParser.h
  llvm/include/llvm/Support/ELFAttributes.h
  llvm/include/llvm/Support/RISCVAttributeParser.h
  llvm/include/llvm/Support/RISCVAttributes.h
  llvm/lib/Object/ELF.cpp
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Support/ARMAttributeParser.cpp
  llvm/lib/Support/ARMBuildAttrs.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/ELFAttributeParser.cpp
  llvm/lib/Support/ELFAttributes.cpp
  llvm/lib/Support/RISCVAttributeParser.cpp
  llvm/lib/Support/RISCVAttributes.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/attribute-with-insts.s
  llvm/test/MC/RISCV/attribute.s
  llvm/test/MC/RISCV/invalid-attribute.s
  llvm/test/tools/llvm-objdump/RISCV/lit.local.cfg
  llvm/test/tools/llvm-objdump/RISCV/unknown-arch-attr.test
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/unittests/Support/ARMAttributeParser.cpp
  llvm/unittests/Support/CMakeLists.txt
  llvm/unittests/Support/ELFAttributeParserTest.cpp
  llvm/unittests/Support/RISCVAttributeParserTest.cpp

Index: llvm/unittests/Support/RISCVAttributeParserTest.cpp
===
--- /dev/null
+++ llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -0,0 +1,70 @@
+//===- unittests/RISCVAttributeParserTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "llvm/Support/RISCVAttributeParser.h"
+#include "llvm/Support/ARMBuildAttributes.h"
+#include "llvm/Support/ELFAttributes.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+
+struct RISCVAttributeSection {
+  unsigned Tag;
+  unsigned Value;
+
+  RISCVAttributeSection(unsigned tag, unsigned value)
+  : Tag(tag), Value(value) {}
+
+  void write(raw_ostream ) {
+OS.flush();
+// length = length + "riscv\0" + TagFile + ByteSize + Tag + Value;
+// length = 17 bytes
+
+OS << 'A' << (uint8_t)17 << (uint8_t)0 << (uint8_t)0 << (uint8_t)0;
+OS << "riscv" << '\0';
+OS << (uint8_t)1 << (uint8_t)7 << (uint8_t)0 << (uint8_t)0 << (uint8_t)0;
+OS << (uint8_t)Tag << (uint8_t)Value;
+  }
+};
+
+static bool testAttribute(unsigned Tag, unsigned Value, unsigned ExpectedTag,
+  unsigned ExpectedValue) {
+  std::string buffer;
+  raw_string_ostream OS(buffer);
+  RISCVAttributeSection Section(Tag, Value);
+  Section.write(OS);
+  ArrayRef Bytes(reinterpret_cast(OS.str().c_str()),
+  OS.str().size());
+
+  RISCVAttributeParser Parser;
+  cantFail(Parser.parse(Bytes, support::little));
+
+  Optional Attr = Parser.getAttributeValue(ExpectedTag);
+  return Attr.hasValue() && Attr.getValue() == ExpectedValue;
+}
+
+static bool testTagString(unsigned Tag, const char *name) {
+  return ELFAttrs::attrTypeAsString(Tag, RISCVAttrs::RISCVAttributeTags)
+ .str() == name;
+}
+
+TEST(StackAlign, testAttribute) {
+  EXPECT_TRUE(testTagString(4, "Tag_stack_align"));
+  EXPECT_TRUE(
+  testAttribute(4, 4, RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_4));
+  EXPECT_TRUE(
+  testAttribute(4, 16, RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16));
+}
+
+TEST(UnalignedAccess, testAttribute) {
+  EXPECT_TRUE(testTagString(6, "Tag_unaligned_access"));
+  EXPECT_TRUE(testAttribute(6, 0, RISCVAttrs::UNALIGNED_ACCESS,
+RISCVAttrs::NOT_ALLOWED));
+  EXPECT_TRUE(
+  testAttribute(6, 1, RISCVAttrs::UNALIGNED_ACCESS, RISCVAttrs::ALLOWED));
+}
Index: llvm/unittests/Support/ELFAttributeParserTest.cpp
===
--- /dev/null
+++ llvm/unittests/Support/ELFAttributeParserTest.cpp
@@ -0,0 +1,63 @@

[Lldb-commits] [PATCH] D77141: [DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.

2020-03-31 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: lldb-commits, arphaman, hiraditya.
Herald added a project: LLDB.
ikudrin added a parent revision: D76067: [llvm-dwp] Refactor handling of 
section identifiers. NFCI..

This is a preparation for an upcoming patch which adds support for DWARFv5 unit 
index sections. The patch adds tag "_EXT_" to identifiers which reference 
sections that are deprecated in the DWARFv5 standard.

See D75929  for the discussion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77141

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -259,7 +259,7 @@
   C.Length = I->Length;
   ++I;
 }
-const unsigned TypesIndex = getContributionIndex(DW_SECT_TYPES);
+const unsigned TypesIndex = getContributionIndex(DW_SECT_EXT_TYPES);
 auto  = Entry.Contributions[TypesIndex];
 Out.emitBytes(Types.substr(
 C.Offset - TUEntry.Contributions[TypesIndex].Offset, C.Length));
@@ -281,7 +281,7 @@
   UnitIndexEntry Entry = CUEntry;
   // Zero out the debug_info contribution
   Entry.Contributions[0] = {};
-  auto  = Entry.Contributions[getContributionIndex(DW_SECT_TYPES)];
+  auto  = Entry.Contributions[getContributionIndex(DW_SECT_EXT_TYPES)];
   C.Offset = TypesOffset;
   auto PrevOffset = Offset;
   // Length of the unit, including the 4 byte length field.
@@ -452,7 +452,7 @@
 
   if (DWARFSectionKind Kind = SectionPair->second.second) {
 auto Index = getContributionIndex(Kind);
-if (Kind != DW_SECT_TYPES) {
+if (Kind != DW_SECT_EXT_TYPES) {
   CurEntry.Contributions[Index].Offset = ContributionOffsets[Index];
   ContributionOffsets[Index] +=
   (CurEntry.Contributions[Index].Length = Contents.size());
@@ -536,10 +536,10 @@
   MCSection *const TUIndexSection = MCOFI.getDwarfTUIndexSection();
   const StringMap> KnownSections = {
   {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}},
-  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}},
+  {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_EXT_TYPES}},
   {"debug_str_offsets.dwo", {StrOffsetSection, DW_SECT_STR_OFFSETS}},
   {"debug_str.dwo", {StrSection, static_cast(0)}},
-  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}},
+  {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_EXT_LOC}},
   {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}},
   {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}},
   {"debug_cu_index", {CUIndexSection, static_cast(0)}},
@@ -603,7 +603,7 @@
   P.first->second.DWOName = ID.DWOName;
   addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
   CurEntry,
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
   continue;
 }
 
@@ -642,13 +642,14 @@
 if (!CurTypesSection.empty()) {
   if (CurTypesSection.size() != 1)
 return make_error("multiple type unit sections in .dwp file");
-  DWARFUnitIndex TUIndex(DW_SECT_TYPES);
+  DWARFUnitIndex TUIndex(DW_SECT_EXT_TYPES);
   DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0);
   if (!TUIndex.parse(TUIndexData))
 return make_error("failed to parse tu_index");
   addAllTypesFromDWP(
   Out, TypeIndexEntries, TUIndex, TypesSection, CurTypesSection.front(),
-  CurEntry, ContributionOffsets[getContributionIndex(DW_SECT_TYPES)]);
+  CurEntry,
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)]);
 }
   }
 
@@ -659,7 +660,7 @@
  TypeIndexEntries);
 
   // Lie about the type contribution
-  ContributionOffsets[getContributionIndex(DW_SECT_TYPES)] = 0;
+  ContributionOffsets[getContributionIndex(DW_SECT_EXT_TYPES)] = 0;
   // Unlie about the info contribution
   ContributionOffsets[0] = 1;
 
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -352,7 +352,7 @@
 
   OS << "Verifying .debug_types Unit Header Chain...\n";
   DObj.forEachTypesSections([&](const 

[Lldb-commits] [PATCH] D75929: [DebugInfo] Support DWARFv5 index sections.

2020-03-31 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin updated this revision to Diff 253879.
ikudrin added a comment.

- Removed `DWARFUnitIndex::getVersion()` as it is related to the other patch.


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

https://reviews.llvm.org/D75929

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
  llvm/test/DebugInfo/X86/dwp-v2-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v2-tu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
  llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -216,11 +216,12 @@
   StringRef DWPName;
 };
 
-// Convert a section identifier into the index to use with
+// Convert an internal section identifier into the index to use with
 // UnitIndexEntry::Contributions.
 static unsigned getContributionIndex(DWARFSectionKind Kind) {
-  assert(Kind >= DW_SECT_INFO);
-  return Kind - DW_SECT_INFO;
+  // Assuming the pre-standard DWP format.
+  assert(serializeSectionKind(Kind, 2) >= DW_SECT_INFO);
+  return serializeSectionKind(Kind, 2) - DW_SECT_INFO;
 }
 
 // Convert a UnitIndexEntry::Contributions index to the corresponding on-disk
Index: llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s
@@ -0,0 +1,43 @@
+## The test checks that we can parse and dump a TU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-tu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_tu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE STR_OFFSETS
+# CHECK-NEXT: - --    
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040)
+
+.section .debug_tu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 4 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 # DW_SECT_INFO
+.long 3 # DW_SECT_ABBREV
+.long 4 # DW_SECT_LINE
+.long 6 # DW_SECT_STR_OFFSETS
+## Row 1:
+.long 0x1000# Offset in .debug_info.dwo
+.long 0x2000# Offset in .debug_abbrev.dwo
+.long 0x3000# Offset in .debug_line.dwo
+.long 0x4000# Offset in .debug_str_offsets.dwo
+## Table of Section Sizes:
+.long 0x10  # Size in .debug_info.dwo
+.long 0x20  # Size in .debug_abbrev.dwo
+.long 0x30  # Size in .debug_line.dwo
+.long 0x40  # Size in .debug_str_offsets.dwo
Index: llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwp-v5-cu-index.s
@@ -0,0 +1,52 @@
+## The test checks that we can parse and dump a CU index section that is
+## compliant to the DWARFv5 standard.
+
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-cu-index - | \
+# RUN:   FileCheck %s
+
+# CHECK:  .debug_cu_index contents:
+# CHECK-NEXT: version = 5 slots = 2
+# CHECK-EMPTY:
+# CHECK-NEXT: Index Signature  INFO ABBREV   LINE LOCLISTS STR_OFFSETS  MACRORNGLISTS
+# CHECK-NEXT: - --       
+# CHECK-NEXT: 1 0x1111 [0x1000, 0x1010) [0x2000, 0x2020) [0x3000, 0x3030) [0x4000, 0x4040) [0x5000, 0x5050) [0x6000, 0x6060) [0x7000, 0x7070)
+
+.section .debug_cu_index, "", @progbits
+## Header:
+.short 5# Version
+.space 2# Padding
+.long 7 # Section count
+.long 1 # Unit count
+.long 2 # Slot count
+## Hash Table of Signatures:
+.quad 0x1111
+.quad 0
+## Parallel Table of Indexes:
+.long 1
+.long 0
+## Table of Section Offsets:
+## Row 0:
+.long 1 

[Lldb-commits] [lldb] e26eece - [lldb/DWARF] Fix evaluator crash when accessing empty stack.

2020-03-31 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-03-31T17:28:15+02:00
New Revision: e26eece1e2e7d7e6fbadb1207afef9b6353b5330

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

LOG: [lldb/DWARF] Fix evaluator crash when accessing empty stack.

This patch fixes a crash that happens on the DWARF expression evaluator
when trying to access the top of the stack while it's empty.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 7f12d06450c6..04fbfccd0c2e 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2318,6 +2318,12 @@ bool DWARFExpression::Evaluate(
 // rather is a constant value.  The value from the top of the stack is the
 // value to be used.  This is the actual object value and not the location.
 case DW_OP_stack_value:
+  if (stack.empty()) {
+if (error_ptr)
+  error_ptr->SetErrorString(
+  "Expression stack needs at least 1 item for DW_OP_stack_value.");
+return false;
+  }
   stack.back().SetValueType(Value::eValueTypeScalar);
   break;
 

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 64755a9066de..4c4281983078 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -234,6 +234,10 @@ TEST(DWARFExpression, DW_OP_convert) {
   llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
+}
+
 TEST(DWARFExpression, DW_OP_piece) {
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
  DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),



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


[Lldb-commits] [PATCH] D77123: [lldb] Inherit host environment when running shell commands

2020-03-31 Thread Frederic Riss via Phabricator via lldb-commits
friss accepted this revision.
friss added a comment.
This revision is now accepted and ready to land.

I agree host shell command should run with the host environment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77123



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


[Lldb-commits] [PATCH] D77000: [LLDB] [PECOFF] Only use PECallFrameInfo on the one supported architecture

2020-03-31 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov accepted this revision.
aleksandr.urakov added a comment.
This revision is now accepted and ready to land.

Sorry for the long delay, LGTM now, thanks!


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

https://reviews.llvm.org/D77000



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


[Lldb-commits] [PATCH] D77000: [LLDB] [PECOFF] Only use PECallFrameInfo on the one supported architecture

2020-03-31 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

@labath @aleksandr.urakov Does this version look good to you?


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

https://reviews.llvm.org/D77000



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


[Lldb-commits] [PATCH] D75750: [lldb] integrate debuginfod

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Making a plugin out of this sounds like a good idea to me, and I could 
immediately find several downstream users for it. However, it seems to me there 
is a great deal of overlap between this SymbolServer thingy and the existing 
SymbolVendor plugin (I mean, "vend" and "serve" are basically synonyms in this 
context). The main difference is that SymbolVendor is responsible for just 
finding the symbol file (in case it is not in the main executable), where as 
this new thing could also be used for finding the main executable too (as well 
as the relevant source files).

I think it would be very confusing to have both symbol "vendors" and "servers" 
and we should try hard to implement that with a single interface. The 
SymbolVendor doesn't do much nowadays (it's basically just a single function 
that tries to search in various locations -- the rest is boilerplate). If we 
add more functionality to it, it might make it seem less baroque.

That might also help the path remapping situation. Since symbol vendors sort of 
sit in between the SymbolFile and Module classes, it should be possible to 
arrange things such that they see the raw paths coming out of the symbol file, 
before they are mangled by various mappings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75750



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


[Lldb-commits] [PATCH] D77096: Correct the duplicate pragma marks in CommandObjectTarget.cpp

2020-03-31 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd30e9ad34519: Correct the duplicate pragma marks in 
CommandObjectTarget.cpp (authored by shivammittal99, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77096

Files:
  lldb/source/Commands/CommandObjectTarget.cpp


Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -571,7 +571,7 @@
   }
 };
 
-#pragma mark CommandObjectTargetSelect
+#pragma mark CommandObjectTargetDelete
 
 // "target delete"
 
@@ -2198,7 +2198,7 @@
   }
 };
 
-#pragma mark CommandObjectTargetModulesDumpSections
+#pragma mark CommandObjectTargetModulesDumpClangAST
 
 // Clang AST dumping command
 


Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -571,7 +571,7 @@
   }
 };
 
-#pragma mark CommandObjectTargetSelect
+#pragma mark CommandObjectTargetDelete
 
 // "target delete"
 
@@ -2198,7 +2198,7 @@
   }
 };
 
-#pragma mark CommandObjectTargetModulesDumpSections
+#pragma mark CommandObjectTargetModulesDumpClangAST
 
 // Clang AST dumping command
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76471: Remap the target SDK directory to the host SDK directory

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Having this in the host layer sounds good to me.


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

https://reviews.llvm.org/D76471



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


[Lldb-commits] [PATCH] D77123: [lldb] Inherit host environment when running shell commands

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This stems from D76835  -- when the inherit 
fallback on windows gets removed some tests fail bacause the can't find `ls`. 
This is used in `lldbutil.wait_for_file_on_target`. The inheritance was not a 
problem because `ls` is normally in the hardcoded default path, but that is not 
the case on windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77123



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D77108#1951997 , @kwk wrote:

> In D77108#1951879 , @labath wrote:
>
> > Most DW_OP cases check their stack, but it's quite possible that others 
> > were missed too. It might be a nice cleanup to make a function like 
> > (`getMinimalStackSize(op)`) and move this check up in front of the big 
> > switch. That could not handle all operators, as for some of them, the value 
> > is not statically known, but it would handle the vast majority of them.
>
>
> @labath I somewhat like that the logic for each `op` is close to the `case` 
> statement. Creating the function that you suggested would separate this check 
> out somewhere else and you would have to look at two places. At least for 
> code review, the current solution is much clearer to me.


I don't have a problem with the current patch (modulo the test tweak) -- it 
fixes a real problem and it follows the style of the surrounding code. However, 
DWARFExpression::Evaluate is gigantic (2600LOC), and nearly half of that is 
error handling. Tastes may vary, but I think that's a bigger readability 
problem than having to look at two places to understand an opcode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [PATCH] D77096: Correct the duplicate pragma marks in CommandObjectTarget.cpp

2020-03-31 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77096



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


[Lldb-commits] [PATCH] D77123: [lldb] Inherit host environment when running shell commands

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jingham, friss.
Herald added a project: LLDB.
labath added a comment.

This stems from D76835  -- when the inherit 
fallback on windows gets removed some tests fail bacause the can't find `ls`. 
This is used in `lldbutil.wait_for_file_on_target`. The inheritance was not a 
problem because `ls` is normally in the hardcoded default path, but that is not 
the case on windows.


On most hosts we were running shell commands with an empty environment.
The only exception was windows, which was inheriting the host enviroment
mostly by accident.

Running the commands in an empty environment does not sound like a
sensible default, so this patch changes Host::RunShellCommand to inherit
the host environment.  This impacts both commands run via
SBPlatform::Run (in case of host platforms), as well as the "platform
shell" CLI command.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77123

Files:
  lldb/source/Host/common/Host.cpp
  lldb/test/API/python_api/sbplatform/Makefile
  lldb/test/API/python_api/sbplatform/TestSBPlatform.py
  lldb/test/API/python_api/sbplatform/main.cpp


Index: lldb/test/API/python_api/sbplatform/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include 
+
+int main() {
+  printf("MY_TEST_ENV_VAR=%s\n", getenv("MY_TEST_ENV_VAR"));
+
+  return 0;
+}
Index: lldb/test/API/python_api/sbplatform/TestSBPlatform.py
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/TestSBPlatform.py
@@ -0,0 +1,22 @@
+"""Test the SBPlatform APIs."""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class SBPlatformAPICase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(['pyapi'])
+def test_run(self):
+self.build()
+plat = lldb.SBPlatform.GetHostPlatform()
+
+os.environ["MY_TEST_ENV_VAR"]="SBPlatformAPICase.test_run"
+def cleanup():
+del os.environ["MY_TEST_ENV_VAR"]
+self.addTearDownHook(cleanup)
+cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out"))
+self.assertTrue(plat.Run(cmd).Success())
+self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", 
cmd.GetOutput())
Index: lldb/test/API/python_api/sbplatform/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -501,6 +501,8 @@
 launch_info.SetArguments(args, first_arg_is_executable);
   }
 
+  launch_info.GetEnvironment() = Host::GetEnvironment();
+
   if (working_dir)
 launch_info.SetWorkingDirectory(working_dir);
   llvm::SmallString<64> output_file_path;


Index: lldb/test/API/python_api/sbplatform/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include 
+
+int main() {
+  printf("MY_TEST_ENV_VAR=%s\n", getenv("MY_TEST_ENV_VAR"));
+
+  return 0;
+}
Index: lldb/test/API/python_api/sbplatform/TestSBPlatform.py
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/TestSBPlatform.py
@@ -0,0 +1,22 @@
+"""Test the SBPlatform APIs."""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class SBPlatformAPICase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@add_test_categories(['pyapi'])
+def test_run(self):
+self.build()
+plat = lldb.SBPlatform.GetHostPlatform()
+
+os.environ["MY_TEST_ENV_VAR"]="SBPlatformAPICase.test_run"
+def cleanup():
+del os.environ["MY_TEST_ENV_VAR"]
+self.addTearDownHook(cleanup)
+cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out"))
+self.assertTrue(plat.Run(cmd).Success())
+self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", cmd.GetOutput())
Index: lldb/test/API/python_api/sbplatform/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/sbplatform/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -501,6 +501,8 @@
 launch_info.SetArguments(args, first_arg_is_executable);
   

[Lldb-commits] [lldb] d30e9ad - Correct the duplicate pragma marks in CommandObjectTarget.cpp

2020-03-31 Thread Raphael Isemann via lldb-commits

Author: Shivam Mittal
Date: 2020-03-31T11:16:40+02:00
New Revision: d30e9ad34519cb0ec17d411bc103af7bb76da77e

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

LOG: Correct the duplicate pragma marks in CommandObjectTarget.cpp

Summary: Resolve the two duplicated pragma marks in 
lldb/source/Commands/CommandObjectTarget.cpp

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: teemperor, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectTarget.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 95f81fc6cd54..fb2854d90ba8 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -571,7 +571,7 @@ class CommandObjectTargetSelect : public 
CommandObjectParsed {
   }
 };
 
-#pragma mark CommandObjectTargetSelect
+#pragma mark CommandObjectTargetDelete
 
 // "target delete"
 
@@ -2198,7 +2198,7 @@ class CommandObjectTargetModulesDumpSections
   }
 };
 
-#pragma mark CommandObjectTargetModulesDumpSections
+#pragma mark CommandObjectTargetModulesDumpClangAST
 
 // Clang AST dumping command
 



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

In D77108#1951879 , @labath wrote:

> In D77108#1951610 , @aprantl wrote:
>
> > This is obviously good! Do you think that a similar error handling bug 
> > might exist in other cases that depend top-of-stack?
>
>
> Most DW_OP cases check their stack, but it's quite possible that others were 
> missed too. It might be a nice cleanup to make a function like 
> (`getMinimalStackSize(op)`) and move this check up in front of the big 
> switch. That could not handle all operators, as for some of them, the value 
> is not statically known, but it would handle the vast majority of them.


@labath I somewhat like that the logic for each `op` is close to the `case` 
statement. Creating the function that you suggested would separate this check 
out somewhere else and you would have to look at two places. At least for code 
review, the current solution is much clearer to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [PATCH] D74398: [lldb-server] jThreadsInfo returns stack memory

2020-03-31 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

In D74398#1939372 , @jarin wrote:

> In D74398#1935438 , @jasonmolenda 
> wrote:
>
> > (and if you're still seeing mystery reads, put a breakpoint on 
> > ProcessGDBRemote::DoReadMemory and see who is doing it)
>
>
> Thanks for the great explanations! I did put a breakpoint into DoReadMemory, 
> and the unwinder doing the reads for each thread (called from 
> https://github.com/llvm/llvm-project/blob/master/lldb/source/Target/ThreadList.cpp#L349).
>  If I understand correctly, the Thread::WillStop/SelectMostRelevantFrame 
> should care only about the current PC of each thread, but not about the stack 
> contents. Let me double check that.


Looking at this in more detail, Thread::WillStop will unwind more than one 
frame (for each thread), the stack trace is below. I guess the surprising bit 
is that UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid (frame #11) always 
unwinds one more frame. Is that expected?

#0: process_gdb_remote::ProcessGDBRemote::DoReadMemory() at 
ProcessGDBRemote.cpp:2694:54
#1: Process::ReadMemoryFromInferior() at Process.cpp:2092:21
#2: Process::ReadMemoryFromInferior() at Process.cpp:2081
#3: MemoryCache::Read() at Memory.cpp:229:69
#4: RegisterContext::ReadRegisterValueFromMemory() at RegisterContext.cpp:337:31
#5: RegisterContextUnwind::ReadRegisterValueFromRegisterLocation() at 
RegisterContextUnwind.cpp:1040:15
#6: RegisterContextUnwind::ReadGPRValue() at RegisterContextUnwind.cpp:2008:44
#7: RegisterContextUnwind::InitializeNonZerothFrame() at 
RegisterContextUnwind.cpp:287:20
#8: RegisterContextUnwind::RegisterContextUnwind() at 
RegisterContextUnwind.cpp:70:29
#9: UnwindLLDB::GetOneMoreFrame() at UnwindLLDB.cpp:129:77
#10: UnwindLLDB::AddOneMoreFrame() at UnwindLLDB.cpp:332:32
#11: UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid() at 
UnwindLLDB.cpp:305:18
#12: UnwindLLDB::AddFirstFrame() at UnwindLLDB.cpp:99:41
#13: UnwindLLDB::AddFirstFrame() at UnwindLLDB.cpp:70
#14: UnwindLLDB::DoGetFrameInfoAtIndex() at UnwindLLDB.cpp:395:23
#15: StackFrameList::GetFramesUpTo() at Unwind.h:53:33
#16: StackFrameList::GetFrameAtIndex() at StackFrameList.cpp:660:16
#17: Thread::SelectMostRelevantFrame() at Thread.cpp:612:52
#18: Thread::WillStop() at Thread.cpp:634:26
#19: ThreadList::ShouldStop() at ThreadList.cpp:349:26
#20: Process::ShouldBroadcastEvent() at Process.cpp:3427:50
#21: Process::HandlePrivateEvent() at Process.cpp:3652:53
#22: Process::RunPrivateStateThread() at Process.cpp:3846:25


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74398



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


[Lldb-commits] [PATCH] D77108: [lldb/DWARF] Fix evaluator crash when accessing empty stack

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D77108#1951610 , @aprantl wrote:

> This is obviously good! Do you think that a similar error handling bug might 
> exist in other cases that depend top-of-stack?


Most DW_OP cases check their stack, but it's quite possible that others were 
missed too. It might be a nice cleanup to make a function like 
(`getMinimalStackSize(op)`) and move this check up in front of the big switch. 
That could not handle all operators, as for some of them, the value is not 
statically known, but it would handle the vast majority of them.




Comment at: lldb/unittests/Expression/DWARFExpressionTest.cpp:238
+TEST(DWARFExpression, DW_OP_stack_value) {
+  EXPECT_THAT_ERROR(Evaluate({DW_OP_stack_value}).takeError(), llvm::Failed());
+}

`EXPECT_THAT_EXPECTED(Evaluate(...), Failed())` is better, as it will produce 
an error (instead of a crash) in case the evaluation does succeed for any 
reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77108



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


[Lldb-commits] [PATCH] D76968: [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D76968#1951707 , @clayborg wrote:

> Looks good as long as with we have "llvm::Optional 
> request_path = {}" in the arguments for a function, that "{}" will turn into 
> llvm::None and not an empty StringRef? Unclear to me. As long as this is what 
> is happening and as long is this coding convention is used elsewhere in llvm 
> (using "{}" instead of "llvm::None") I am ok. Pavel?


The two expressions are equivalent here. We're currently using both styles in 
lldb. I have a slight preference for the explicit None version, but I don't 
think it's worth the trouble to standardize on one or the other.




Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1974
   // Add this breakpoint info to the response
   AppendBreakpoint(pair.second.bp, response_breakpoints);
 }

wallace wrote:
> labath wrote:
> > What about breakpoints in dynamically loaded shared libraries? Should you 
> > be remembering the original path somewhere so that one you can set it here 
> > too?
> This case is different, as function breakpoints are set by the IDE without 
> referring to any source path, as they are equivalent to making 'b 
> function_name'. Probably function breakpoints are not working correctly, so 
> I'll have to fix it any of these days using the expensive query I mentioned 
> above.
Ah, sorry. I misplaced this comment. It was meant to go above to line 417, 
where the `eBreakpointEventTypeLocationsAdded` event is handled. That code 
should be reached for "regular" file+line breakpoints in case a breakpoint gets 
new locations (e.g.) in response to a shared library being loaded.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:421
 llvm::json::Object body;
 body.try_emplace("breakpoint", CreateBreakpoint(bp));
 body.try_emplace("reason", "changed");

The comment was supposed to be here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76968



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


[Lldb-commits] [PATCH] D77107: [intel-pt] Implement a basic test case

2020-03-31 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It's nice to see this code getting some use. I was starting to think we should 
delete it...




Comment at: 
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py:30-36
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+self.runCmd("b main")
+self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
+
+self.runCmd("r")

`lldbutil.run_to_name_breakpoint`



Comment at: 
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py:50
+patterns=[
+"rand", # We expect to see a reference to the rand function
+# within the last instructions

clayborg wrote:
> can we guarantee we will see any of these on a fully loaded machine running 
> many tests simultaneously? Maybe we need to settle for the header of the 
> output only to know that it tried to display something?
better avoid referencing functions from the system library... makes the test 
more hermetic



Comment at: 
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py:50-54
+"rand", # We expect to see a reference to the rand function
+# within the last instructions
+hex(fun_start_adddress),  # We expect to have seen the first
+  # instruction of 'fun'
+"at main.cpp:21" # We expect to see the exit condition of

labath wrote:
> clayborg wrote:
> > can we guarantee we will see any of these on a fully loaded machine running 
> > many tests simultaneously? Maybe we need to settle for the header of the 
> > output only to know that it tried to display something?
> better avoid referencing functions from the system library... makes the test 
> more hermetic
What exactly is the case you're worried about? I'm not very familiar with how 
all this works, but I would think that the kernel trace buffer for this is 
application specific, and is automatically switched off when the os schedules a 
different process (anything else would be a security breach). If that is true, 
then we should have pretty good control over what goes into the buffer, and we 
can ensure that it is: (a) big enough; and/or (b) application does not execute 
too much code and overflows it (not calling rand would help us get a reasonable 
upper bound on that).

(Nonetheless it would be good to run some stress tests to verify this is 
stable.)



Comment at: lldb/test/API/tools/intel-features/intel-pt/test/main.cpp:2-8
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+===--===//
+//

We're not putting license headers on tests.

(Do these get automatically created by some IDEs or something? Can they be 
configured not to do that?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77107



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