[Lldb-commits] [lldb] r334697 - Fix includes in PlatformAppleSimulator.h

2018-06-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun 14 02:08:54 2018
New Revision: 334697

URL: http://llvm.org/viewvc/llvm-project?rev=334697&view=rev
Log:
Fix includes in PlatformAppleSimulator.h

This unbreaks the cmake build. Other plugins also use the include paths
starting with Plugins/..., so I am hoping this will work for the xcode build
too.

Modified:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h?rev=334697&r1=334696&r2=334697&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h 
(original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h Thu Jun 
14 02:08:54 2018
@@ -16,8 +16,8 @@
 
 // Other libraries and framework includes
 // Project includes
-#include "PlatformDarwin.h"
-#include "PlatformiOSSimulatorCoreSimulatorSupport.h"
+#include "Plugins/Platform/MacOSX/PlatformDarwin.h"
+#include 
"Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h"
 #include "lldb/Utility/FileSpec.h"
 
 #include "llvm/ADT/Optional.h"


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


[Lldb-commits] [lldb] r334702 - Fix PathMappingListTest on windows

2018-06-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun 14 03:31:06 2018
New Revision: 334702

URL: http://llvm.org/viewvc/llvm-project?rev=334702&view=rev
Log:
Fix PathMappingListTest on windows

r334615 changed the the value of FileSpec.IsRelative("/") for windows
path syntax. We previously considered it absolute but now it is
considered relative (I guess because it's interpretation depends on the
current drive).

This cause a failure in PathMappingList test, which assumed that "/"
will not get remapped as it is an absolute path. As this is no longer
true on windows, I replace "/" with a really absolute path.

Modified:
lldb/trunk/unittests/Target/PathMappingListTest.cpp

Modified: lldb/trunk/unittests/Target/PathMappingListTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Target/PathMappingListTest.cpp?rev=334702&r1=334701&r2=334702&view=diff
==
--- lldb/trunk/unittests/Target/PathMappingListTest.cpp (original)
+++ lldb/trunk/unittests/Target/PathMappingListTest.cpp Thu Jun 14 03:31:06 2018
@@ -29,9 +29,12 @@ static void TestPathMappings(const PathM
  llvm::ArrayRef fails) {
   ConstString actual_remapped;
   for (const auto &fail : fails) {
-EXPECT_FALSE(map.RemapPath(fail, actual_remapped));
+SCOPED_TRACE(fail.GetCString());
+EXPECT_FALSE(map.RemapPath(fail, actual_remapped))
+<< "actual_remapped: " << actual_remapped.GetCString();
   }
   for (const auto &match : matches) {
+SCOPED_TRACE(match.original.GetPath() + " -> " + match.remapped.GetPath());
 std::string orig_normalized = match.original.GetPath();
 EXPECT_TRUE(
 map.RemapPath(ConstString(match.original.GetPath()), actual_remapped));
@@ -54,8 +57,13 @@ TEST(PathMappingListTest, RelativeTests)
 {"bar/foo.c", "/tmp/bar/foo.c"},
   };
   ConstString fails[] = {
-ConstString("/a"),
-ConstString("/"),
+#ifdef _WIN32
+  ConstString("C:\\"),
+  ConstString("C:\\a"),
+#else
+  ConstString("/a"),
+  ConstString("/"),
+#endif
   };
   PathMappingList map;
   map.Append(ConstString("."), ConstString("/tmp"), false);


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


[Lldb-commits] [PATCH] D24960: Remove unreachable from apis in posix terminal compat windows and return 0

2018-06-14 Thread Carlo Kok via Phabricator via lldb-commits
carlokok abandoned this revision.
carlokok added a comment.
Herald added a subscriber: llvm-commits.

This is from 2016; the code doesn't exist anaymore in this form.


Repository:
  rL LLVM

https://reviews.llvm.org/D24960



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


[Lldb-commits] [lldb] r334717 - DebugNamesDWARFIndex: fix handling of compressed sections

2018-06-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun 14 07:41:30 2018
New Revision: 334717

URL: http://llvm.org/viewvc/llvm-project?rev=334717&view=rev
Log:
DebugNamesDWARFIndex: fix handling of compressed sections

This fixes a silly bug where we were accidentally freeing the memory
used to store the decompressed .debug_names data. I had actually
considered this scenario when writing the class and put appropriate
precautions in place -- I just failed to wire it all up correctly.

This was only an issue for compressed sections because in case of
uncompressed ones we would access the data straight out of the mmapped
object file.

Added:
lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Added: lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp?rev=334717&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp Thu Jun 14 
07:41:30 2018
@@ -0,0 +1,14 @@
+// Test for a bug where we crashed while processing a compressed debug_names
+// section (use after free).
+
+// REQUIRES: lld, zlib
+
+// RUN: clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm 
-accel-tables=Dwarf %s
+// RUN: ld.lld %t.o -o %t --compress-debug-sections=zlib
+// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s
+
+// CHECK: Found 1 variables:
+int foo;
+// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = 
debug-names-compressed.cpp:[[@LINE-1]]
+
+extern "C" void _start() {}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=334717&r1=334716&r2=334717&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Thu Jun 
14 07:41:30 2018
@@ -53,6 +53,7 @@ private:
DWARFDataExtractor debug_str_data,
DWARFDebugInfo &debug_info)
   : DWARFIndex(module), m_debug_info(debug_info),
+m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data),
 m_debug_names_up(std::move(debug_names_up)),
 m_fallback(module, &debug_info, GetUnits(*m_debug_names_up)) {}
 


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


[Lldb-commits] [PATCH] D24960: Remove unreachable from apis in posix terminal compat windows and return 0

2018-06-14 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

shouldn't these be returning -1 for some of these? Zero usually means no error. 
You would need to check each unix function and return the right error code for 
failure.


Repository:
  rL LLVM

https://reviews.llvm.org/D24960



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


[Lldb-commits] [PATCH] D48177: Suppress SIGSEGV on Android when the program will recover

2018-06-14 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added a reviewer: labath.
Herald added a subscriber: srhines.

SIGSEGV signals are sent to Android processes when a NULL dereference happens 
in Java code that is being run as native code in dex, odex and oat files. In 
this patch I modified the Platforms to be allowed to modify a stop reason for a 
thread. The PlatformAndroid will watch for SIGSEGV stop reasons and see if the 
frame that caused the SIGSEGV comes from a dex, odex or oat file, and if so, it 
will suppress the stop reason. Many IDEs are manually figuring this out and 
learning to skip the signal so users don't see it. Even when IDEs do this, the 
IDE might end up showing a SIGSEGV as a valid stop reason for a thread. Also, a 
SIGSEGV thread might be selected when another thread hits a breakpoint. So we 
suppress these signals to avoid spurious thread changes and improve android 
debugging.


https://reviews.llvm.org/D48177

Files:
  include/lldb/Target/Platform.h
  source/Plugins/Platform/Android/PlatformAndroid.cpp
  source/Plugins/Platform/Android/PlatformAndroid.h
  source/Target/Thread.cpp

Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -439,9 +439,16 @@
 if (m_stop_info_override_stop_id != process_stop_id) {
   m_stop_info_override_stop_id = process_stop_id;
   if (m_stop_info_sp) {
+// If there is an architecture plug-in for this target architecture,
+// let it possibly modify the stop reason.
 if (Architecture *arch =
 process_sp->GetTarget().GetArchitecturePlugin())
   arch->OverrideStopInfo(*this);
+// Let the platform get a chance to modify the stop reason.
+auto platform_sp = GetProcess()->GetTarget().GetPlatform();
+if (platform_sp) {
+  platform_sp->OverrideStopInfo(*this);
+}
   }
 }
   }
Index: source/Plugins/Platform/Android/PlatformAndroid.h
===
--- source/Plugins/Platform/Android/PlatformAndroid.h
+++ source/Plugins/Platform/Android/PlatformAndroid.h
@@ -66,6 +66,8 @@
 
   uint32_t GetDefaultMemoryCacheLineSize() override;
 
+  void OverrideStopInfo(Thread &thread) override;
+
 protected:
   const char *GetCacheHostname() override;
 
Index: source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -14,6 +14,9 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/StringConvert.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Thread.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/UriParser.h"
 
@@ -392,11 +395,44 @@
   return PlatformPOSIX::GetLibdlFunctionDeclarations(process);
 }
 
+// Define a SIGSEGV that doesn't require any headers
+#define ANDROID_SIGSEGV 11
+
+void PlatformAndroid::OverrideStopInfo(Thread &thread) {
+  auto stop_info_sp = thread.GetStopInfo();
+  if (!stop_info_sp)
+return;
+  // Check for SIGSEGV that is called from a .dex, .odex or .oat file.
+  // These are going to be dealt with by the runtime so we can just erase
+  // the stop reason.
+  const auto reason = stop_info_sp->GetStopReason();
+  if (reason != eStopReasonSignal)
+return;
+  if (stop_info_sp->GetValue() != ANDROID_SIGSEGV)
+return;
+  auto frame_sp = thread.GetStackFrameAtIndex(0);
+  if (!frame_sp)
+return;
+  auto module_sp = frame_sp->GetSymbolContext(eSymbolContextModule).module_sp;
+  if (!module_sp)
+return;
+  auto ext = module_sp->GetFileSpec().GetFileNameExtension();
+  if (!ext)
+return;
+  llvm::StringRef ext_ref(ext.GetCString(), ext.GetLength());
+  // We are lookking for .dex, .odex, and .oat files.
+  if (ext_ref.endswith("dex") || ext_ref.endswith("oat")) {
+// We have a SIGSEGV we need to mute
+thread.SetStopInfo(lldb::StopInfoSP());
+  }
+}
+
 AdbClient::SyncService *PlatformAndroid::GetSyncService(Status &error) {
   if (m_adb_sync_svc && m_adb_sync_svc->IsConnected())
 return m_adb_sync_svc.get();
 
   AdbClient adb(m_device_id);
   m_adb_sync_svc = adb.GetSyncService(error);
   return (error.Success()) ? m_adb_sync_svc.get() : nullptr;
 }
+
Index: include/lldb/Target/Platform.h
===
--- include/lldb/Target/Platform.h
+++ include/lldb/Target/Platform.h
@@ -858,6 +858,16 @@
   virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Status &error);
 
+  //--
+  /// Allow platforms to modify thread stop info.
+  ///
+  /// Platforms might have specific signals or stop reasons that are
+  /// ov

[Lldb-commits] [lldb] r334743 - Add a script to setup codesigning on macOS.

2018-06-14 Thread Frederic Riss via lldb-commits
Author: friss
Date: Thu Jun 14 11:04:13 2018
New Revision: 334743

URL: http://llvm.org/viewvc/llvm-project?rev=334743&view=rev
Log:
Add a script to setup codesigning on macOS.

I've been using this script on a couple machines and it seems to work
so I'm putting it out there, maybe other people will find it useful.
It is strongly inspired from a similar script in the delve project.

Added:
lldb/trunk/scripts/macos-setup-codesign.sh   (with props)

Added: lldb/trunk/scripts/macos-setup-codesign.sh
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/macos-setup-codesign.sh?rev=334743&view=auto
==
--- lldb/trunk/scripts/macos-setup-codesign.sh (added)
+++ lldb/trunk/scripts/macos-setup-codesign.sh Thu Jun 14 11:04:13 2018
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+CERT="lldb_codesign"
+
+function error() {
+echo error: "$@"
+exit 1
+}
+
+function cleanup {
+# Remove generated files
+rm -f "$TMPDIR/$CERT.tmpl" "$TMPDIR/$CERT.cer" "$TMPDIR/$CERT.key" > 
/dev/null 2>&1
+}
+
+trap cleanup EXIT
+
+# Check if the certificate is already present in the system keychain
+security find-certificate -Z -p -c "$CERT" /Library/Keychains/System.keychain 
> /dev/null 2>&1
+if [ $? -eq 0 ]; then
+echo Certificate has already been generated and installed
+exit 0
+fi
+
+# Create the certificate template
+cat <$TMPDIR/$CERT.tmpl
+[ req ]
+default_bits   = 2048# RSA key size
+encrypt_key= no  # Protect private key
+default_md = sha512  # MD to use
+prompt = no  # Prompt for DN
+distinguished_name = codesign_dn # DN template
+[ codesign_dn ]
+commonName = "$CERT"
+[ codesign_reqext ]
+keyUsage   = critical,digitalSignature
+extendedKeyUsage   = critical,codeSigning
+EOF
+
+echo Generating and installing lldb_codesign certificate
+
+# Generate a new certificate
+openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config 
"$TMPDIR/$CERT.tmpl" -extensions codesign_reqext -batch -out 
"$TMPDIR/$CERT.cer" -keyout "$TMPDIR/$CERT.key" > /dev/null 2>&1
+[ $? -eq 0 ] || error Something went wrong when generating the certificate
+
+# Install the certificate in the system keychain
+sudo security add-trusted-cert -d -r trustRoot -p codeSign -k 
/Library/Keychains/System.keychain "$TMPDIR/$CERT.cer" > /dev/null 2>&1
+[ $? -eq 0 ] || error Something went wrong when installing the certificate
+
+# Install the key for the certificate in the system keychain
+sudo security import "$TMPDIR/$CERT.key" -A -k 
/Library/Keychains/System.keychain > /dev/null 2>&1
+[ $? -eq 0 ] || error Something went wrong when installing the key
+
+# Kill task_for_pid access control daemon
+sudo pkill -f /usr/libexec/taskgated > /dev/null 2>&1
+
+# Exit indicating the certificate is now generated and installed
+exit 0

Propchange: lldb/trunk/scripts/macos-setup-codesign.sh
--
svn:executable = *


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


Re: [Lldb-commits] [lldb] r334743 - Add a script to setup codesigning on macOS.

2018-06-14 Thread Greg Clayton via lldb-commits
Nice! I never took the time to get this working from the command line. Thanks 
for this. 

> On Jun 14, 2018, at 11:04 AM, Frederic Riss via lldb-commits 
>  wrote:
> 
> Author: friss
> Date: Thu Jun 14 11:04:13 2018
> New Revision: 334743
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=334743&view=rev
> Log:
> Add a script to setup codesigning on macOS.
> 
> I've been using this script on a couple machines and it seems to work
> so I'm putting it out there, maybe other people will find it useful.
> It is strongly inspired from a similar script in the delve project.
> 
> Added:
>lldb/trunk/scripts/macos-setup-codesign.sh   (with props)
> 
> Added: lldb/trunk/scripts/macos-setup-codesign.sh
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/macos-setup-codesign.sh?rev=334743&view=auto
> ==
> --- lldb/trunk/scripts/macos-setup-codesign.sh (added)
> +++ lldb/trunk/scripts/macos-setup-codesign.sh Thu Jun 14 11:04:13 2018
> @@ -0,0 +1,57 @@
> +#!/bin/bash
> +
> +CERT="lldb_codesign"
> +
> +function error() {
> +echo error: "$@"
> +exit 1
> +}
> +
> +function cleanup {
> +# Remove generated files
> +rm -f "$TMPDIR/$CERT.tmpl" "$TMPDIR/$CERT.cer" "$TMPDIR/$CERT.key" > 
> /dev/null 2>&1
> +}
> +
> +trap cleanup EXIT
> +
> +# Check if the certificate is already present in the system keychain
> +security find-certificate -Z -p -c "$CERT" 
> /Library/Keychains/System.keychain > /dev/null 2>&1
> +if [ $? -eq 0 ]; then
> +echo Certificate has already been generated and installed
> +exit 0
> +fi
> +
> +# Create the certificate template
> +cat <$TMPDIR/$CERT.tmpl
> +[ req ]
> +default_bits   = 2048# RSA key size
> +encrypt_key= no  # Protect private key
> +default_md = sha512  # MD to use
> +prompt = no  # Prompt for DN
> +distinguished_name = codesign_dn # DN template
> +[ codesign_dn ]
> +commonName = "$CERT"
> +[ codesign_reqext ]
> +keyUsage   = critical,digitalSignature
> +extendedKeyUsage   = critical,codeSigning
> +EOF
> +
> +echo Generating and installing lldb_codesign certificate
> +
> +# Generate a new certificate
> +openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config 
> "$TMPDIR/$CERT.tmpl" -extensions codesign_reqext -batch -out 
> "$TMPDIR/$CERT.cer" -keyout "$TMPDIR/$CERT.key" > /dev/null 2>&1
> +[ $? -eq 0 ] || error Something went wrong when generating the certificate
> +
> +# Install the certificate in the system keychain
> +sudo security add-trusted-cert -d -r trustRoot -p codeSign -k 
> /Library/Keychains/System.keychain "$TMPDIR/$CERT.cer" > /dev/null 2>&1
> +[ $? -eq 0 ] || error Something went wrong when installing the certificate
> +
> +# Install the key for the certificate in the system keychain
> +sudo security import "$TMPDIR/$CERT.key" -A -k 
> /Library/Keychains/System.keychain > /dev/null 2>&1
> +[ $? -eq 0 ] || error Something went wrong when installing the key
> +
> +# Kill task_for_pid access control daemon
> +sudo pkill -f /usr/libexec/taskgated > /dev/null 2>&1
> +
> +# Exit indicating the certificate is now generated and installed
> +exit 0
> 
> Propchange: lldb/trunk/scripts/macos-setup-codesign.sh
> --
>svn:executable = *
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] r334755 - One ShortFract ought to be enough for everyone.

2018-06-14 Thread Benjamin Kramer via lldb-commits
Author: d0k
Date: Thu Jun 14 12:20:48 2018
New Revision: 334755

URL: http://llvm.org/viewvc/llvm-project?rev=334755&view=rev
Log:
One ShortFract ought to be enough for everyone.

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=334755&r1=334754&r2=334755&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Jun 14 12:20:48 2018
@@ -4942,7 +4942,6 @@ lldb::Encoding ClangASTContext::GetEncod
 case clang::BuiltinType::UAccum:
 case clang::BuiltinType::ULongAccum:
 case clang::BuiltinType::ShortFract:
-case clang::BuiltinType::ShortFract:
 case clang::BuiltinType::Fract:
 case clang::BuiltinType::LongFract:
 case clang::BuiltinType::UShortFract:


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


[Lldb-commits] [PATCH] D48177: Suppress SIGSEGV on Android when the program will recover

2018-06-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

If you can get the address of the bad access from the signal, you could also 
check that it was 0x0 and only suppress the SIGSEGV if it is?

Also, do you want to put in a setting to turn this behavior off?  If the code 
in any of the files of this type were to crash for some other reason than a 
Java NULL dereference, you'd have no way to use lldb to debug the issue.   lldb 
will just auto-continue and then either the program will terminate because the 
SIGSEGV handler doesn't handle this signal or the SIGSEGV handler will crash or 
whatever...  That will be too late to be useful.

But I don't know anything about how these .oat and .dex/.odex files are 
constructed, and maybe they can't crash for any other reason than emulating a 
Java NULL access, in which case this looks fine.




Comment at: source/Plugins/Platform/Android/PlatformAndroid.cpp:424
+  // We are lookking for .dex, .odex, and .oat files.
+  if (ext_ref.endswith("dex") || ext_ref.endswith("oat")) {
+// We have a SIGSEGV we need to mute

Given that this is a pretty big behavior change, I would exactly match on the 
three extensions rather than use endswith, so it only affects the file types 
you care about.


https://reviews.llvm.org/D48177



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


Re: [Lldb-commits] [lldb] r334743 - Add a script to setup codesigning on macOS.

2018-06-14 Thread Davide Italiano via lldb-commits
On Thu, Jun 14, 2018 at 11:04 AM, Frederic Riss via lldb-commits
 wrote:
> Author: friss
> Date: Thu Jun 14 11:04:13 2018
> New Revision: 334743
>
> URL: http://llvm.org/viewvc/llvm-project?rev=334743&view=rev
> Log:
> Add a script to setup codesigning on macOS.
>
> I've been using this script on a couple machines and it seems to work
> so I'm putting it out there, maybe other people will find it useful.
> It is strongly inspired from a similar script in the delve project.
>
> Added:
> lldb/trunk/scripts/macos-setup-codesign.sh   (with props)
>
> Added: lldb/trunk/scripts/macos-setup-codesign.sh
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/macos-setup-codesign.sh?rev=334743&view=auto
> ==
> --- lldb/trunk/scripts/macos-setup-codesign.sh (added)
> +++ lldb/trunk/scripts/macos-setup-codesign.sh Thu Jun 14 11:04:13 2018
> @@ -0,0 +1,57 @@
> +#!/bin/bash
> +
> +CERT="lldb_codesign"
> +
> +function error() {
> +echo error: "$@"
> +exit 1
> +}
> +
> +function cleanup {
> +# Remove generated files
> +rm -f "$TMPDIR/$CERT.tmpl" "$TMPDIR/$CERT.cer" "$TMPDIR/$CERT.key" > 
> /dev/null 2>&1
> +}
> +
> +trap cleanup EXIT
> +
> +# Check if the certificate is already present in the system keychain
> +security find-certificate -Z -p -c "$CERT" 
> /Library/Keychains/System.keychain > /dev/null 2>&1
> +if [ $? -eq 0 ]; then
> +echo Certificate has already been generated and installed
> +exit 0
> +fi
> +
> +# Create the certificate template
> +cat <$TMPDIR/$CERT.tmpl
> +[ req ]
> +default_bits   = 2048# RSA key size
> +encrypt_key= no  # Protect private key
> +default_md = sha512  # MD to use
> +prompt = no  # Prompt for DN
> +distinguished_name = codesign_dn # DN template
> +[ codesign_dn ]
> +commonName = "$CERT"
> +[ codesign_reqext ]
> +keyUsage   = critical,digitalSignature
> +extendedKeyUsage   = critical,codeSigning
> +EOF
> +
> +echo Generating and installing lldb_codesign certificate
> +
> +# Generate a new certificate
> +openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config 
> "$TMPDIR/$CERT.tmpl" -extensions codesign_reqext -batch -out 
> "$TMPDIR/$CERT.cer" -keyout "$TMPDIR/$CERT.key" > /dev/null 2>&1
> +[ $? -eq 0 ] || error Something went wrong when generating the certificate
> +
> +# Install the certificate in the system keychain
> +sudo security add-trusted-cert -d -r trustRoot -p codeSign -k 
> /Library/Keychains/System.keychain "$TMPDIR/$CERT.cer" > /dev/null 2>&1
> +[ $? -eq 0 ] || error Something went wrong when installing the certificate
> +
> +# Install the key for the certificate in the system keychain
> +sudo security import "$TMPDIR/$CERT.key" -A -k 
> /Library/Keychains/System.keychain > /dev/null 2>&1
> +[ $? -eq 0 ] || error Something went wrong when installing the key
> +
> +# Kill task_for_pid access control daemon
> +sudo pkill -f /usr/libexec/taskgated > /dev/null 2>&1
> +
> +# Exit indicating the certificate is now generated and installed
> +exit 0
>
> Propchange: lldb/trunk/scripts/macos-setup-codesign.sh
> --
> svn:executable = *
>

I just tested on my freshly installed OS and it works :)
Thank you very much, I really quite didn't like the manual dance.
Should we update code_signing.txt to point to this? (and fallback to
the old manual method)

Best,

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


[Lldb-commits] [lldb] r334772 - Add an entitlement to debugserver

2018-06-14 Thread Frederic Riss via lldb-commits
Author: friss
Date: Thu Jun 14 14:17:59 2018
New Revision: 334772

URL: http://llvm.org/viewvc/llvm-project?rev=334772&view=rev
Log:
Add an entitlement to debugserver

On macOS 10.14, debugserver needs to have an entitlement do be
allowed to debug processes. Adding this to both the Xcode and
cmake build system. This shouldn't have any impact on previous
OSs.

Added:
lldb/trunk/resources/debugserver-macosx-entitlements.plist
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
lldb/trunk/tools/debugserver/source/CMakeLists.txt

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=334772&r1=334771&r2=334772&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 14 14:17:59 2018
@@ -7335,7 +7335,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
-   shellScript = "if [ \"${CONFIGURATION}\" != 
BuildAndIntegration ]\nthen\nif [ \"${DEBUGSERVER_USE_FROM_SYSTEM}\" == 
\"\" ]\nthen\nif [ \"${DEBUGSERVER_DISABLE_CODESIGN}\" == \"\" ]\n  
  then\ncodesign -f -s lldb_codesign 
\"${TARGET_BUILD_DIR}/${TARGET_NAME}\"\nfi\nfi\nfi\n";
+   shellScript = "if [ \"${CONFIGURATION}\" != 
BuildAndIntegration ]\nthen\nif [ \"${DEBUGSERVER_USE_FROM_SYSTEM}\" == 
\"\" ]\nthen\nif [ \"${DEBUGSERVER_DISABLE_CODESIGN}\" == \"\" ]\n  
  then\ncodesign -f -s lldb_codesign --entitlements 
${SRCROOT}/resources/debugserver-macosx-entitlements.plist 
\"${TARGET_BUILD_DIR}/${TARGET_NAME}\"\nfi\nfi\nfi\n";
};
940B04E21A89871F0045D5F7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;

Added: lldb/trunk/resources/debugserver-macosx-entitlements.plist
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/debugserver-macosx-entitlements.plist?rev=334772&view=auto
==
--- lldb/trunk/resources/debugserver-macosx-entitlements.plist (added)
+++ lldb/trunk/resources/debugserver-macosx-entitlements.plist Thu Jun 14 
14:17:59 2018
@@ -0,0 +1,8 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+
+
+com.apple.security.cs.debugger
+
+
+

Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=334772&r1=334771&r2=334772&view=diff
==
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj 
(original)
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Jun 
14 14:17:59 2018
@@ -570,7 +570,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/bin/sh -x";
-   shellScript = "if [ \"${CONFIGURATION}\" != 
BuildAndIntegration ]\nthen\nif [ -n \"${DEBUGSERVER_USE_FROM_SYSTEM}\" ]\n 
   then\n\t\tditto 
\"${DEVELOPER_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver\" 
\"${TARGET_BUILD_DIR}/${TARGET_NAME}\"\nelif [ 
\"${DEBUGSERVER_DISABLE_CODESIGN}\" == \"\" ]\nthen\ncodesign -f -s 
lldb_codesign \"${TARGET_BUILD_DIR}/${TARGET_NAME}\"\nfi\nfi\n";
+   shellScript = "if [ \"${CONFIGURATION}\" != 
BuildAndIntegration ]\nthen\nif [ -n \"${DEBUGSERVER_USE_FROM_SYSTEM}\" ]\n 
   then\n\t\tditto 
\"${DEVELOPER_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver\" 
\"${TARGET_BUILD_DIR}/${TARGET_NAME}\"\nelif [ 
\"${DEBUGSERVER_DISABLE_CODESIGN}\" == \"\" ]\nthen\ncodesign -f -s 
lldb_codesign --entitlements 
${SRCROOT}/../../resources/debugserver-macosx-entitlements.plist 
\"${TARGET_BUILD_DIR}/${TARGET_NAME}\"\nfi\nfi\n";
};
 /* End PBXShellScriptBuildPhase section */
 

Modified: lldb/trunk/tools/debugserver/source/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/CMakeLists.txt?rev=334772&r1=334771&r2=334772&view=diff
==
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt Thu Jun 14 14:17:59 2018
@@ -209,12 +209,11 @@ endif()
 set(entitlements_xml 
${CMAKE_CURRENT_SOURCE_DIR}/debugserver-macosx-entitlements.plist)
 if(IOS)
   set(entitlements_xml 
${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist)
+else()
+  set(entitlements_xml 
${CMAKE_CURRENT_SOURC

[Lldb-commits] [lldb] r334783 - Change TestExec.py from creating an i386+x86_64 fat binary

2018-06-14 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Thu Jun 14 17:55:53 2018
New Revision: 334783

URL: http://llvm.org/viewvc/llvm-project?rev=334783&view=rev
Log:
Change TestExec.py from creating an i386+x86_64 fat binary
on darwin systems and re-execing itself, to creating two
separate test programs; lldb runs the first program and it
exec's the second.  

Support for compiling for i386 is going away.

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/main.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile?rev=334783&r1=334782&r2=334783&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile Thu 
Jun 14 17:55:53 2018
@@ -2,4 +2,12 @@ LEVEL = ../../make
 
 CXX_SOURCES := main.cpp
 
+all: a.out secondprog
+
 include $(LEVEL)/Makefile.rules
+
+secondprog:
+   $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/secondprog.mk
+
+clean::
+   $(MAKE) -f $(SRCDIR)/secondprog.mk clean

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py?rev=334783&r1=334782&r2=334783&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py 
Thu Jun 14 17:55:53 2018
@@ -41,29 +41,20 @@ class ExecTestCase(TestBase):
 self.do_test(True)
 
 def do_test(self, skip_exec):
+self.build()
 exe = self.getBuildArtifact("a.out")
-if self.getArchitecture() == 'x86_64':
-source = self.getSourcePath("main.cpp")
-o_file = self.getBuildArtifact("main.o")
-execute_command(
-"'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" %
-(os.environ["CC"], source, o_file))
-execute_command(
-"'%s' -g -O0 -arch i386 -arch x86_64 '%s' -o '%s'" %
-(os.environ["CC"], o_file, exe))
-if self.getDebugInfo() != "dsym":
-dsym_path = self.getBuildArtifact("a.out.dSYM")
-execute_command("rm -rf '%s'" % (dsym_path))
-else:
-self.build()
+secondprog = self.getBuildArtifact("secondprog")
 
 # Create the target
 target = self.dbg.CreateTarget(exe)
 
 # Create any breakpoints we need
-breakpoint = target.BreakpointCreateBySourceRegex(
+breakpoint1 = target.BreakpointCreateBySourceRegex(
 'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False))
-self.assertTrue(breakpoint, VALID_BREAKPOINT)
+self.assertTrue(breakpoint1, VALID_BREAKPOINT)
+breakpoint2 = target.BreakpointCreateBySourceRegex(
+'Set breakpoint 2 here', lldb.SBFileSpec("secondprog.cpp", False))
+self.assertTrue(breakpoint2, VALID_BREAKPOINT)
 
 # Launch the process
 process = target.LaunchSimple(
@@ -79,50 +70,48 @@ class ExecTestCase(TestBase):
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
 
-
-for i in range(6):
-# The stop reason of the thread should be breakpoint.
-self.assertTrue(process.GetState() == lldb.eStateStopped,
-STOPPED_DUE_TO_BREAKPOINT)
+# The stop reason of the thread should be breakpoint.
+self.assertTrue(process.GetState() == lldb.eStateStopped,
+STOPPED_DUE_TO_BREAKPOINT)
+
+threads = lldbutil.get_threads_stopped_at_breakpoint(
+process, breakpoint1)
+self.assertTrue(len(threads) == 1)
+
+# We had a deadlock tearing down the TypeSystemMap on exec, but only 
if some
+# expression had been evaluated.  So make sure we do that here so the 
teardown
+# is not trivial.
+
+thread = threads[0]
+value = thread.frames[0].EvaluateExpression("1 + 2")
+self.assertTrue(
+value.IsValid(),
+"Expression evaluated successfully")
+int_value = value.GetValueAsSigned()
+self.assertTrue(int_value == 3, "Expression got the right result.")
 
-threads = lldbutil.get_threads_stopped_at_br

[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-06-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This is going as I imagined it should, looks great!

We probably want to turn this on by default for "frame var" or no one will ever 
discover it.  The IDE folks can decide on their own what to do from the SB 
API's.  Since you are doing module filtering and this only triggers when you 
explicitly run "frame var" I think having it on by default will not be a big 
deal.

Does this work with "frame var paths" as well?  That is, if I do:

(lldb) frame var
(struct Foo *) recognized_variable = 0x12345

Will we find it again if I do:

(lldb) frame var *recognized_variable

or

(lldb) frame var recognized_variable.some_interesting_ivar

I think this should just work, but it's worth checking.


https://reviews.llvm.org/D44603



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


[Lldb-commits] [lldb] r334784 - Add support for PLATFORM_*SIMULATOR

2018-06-14 Thread Frederic Riss via lldb-commits
Author: friss
Date: Thu Jun 14 19:50:45 2018
New Revision: 334784

URL: http://llvm.org/viewvc/llvm-project?rev=334784&view=rev
Log:
Add support for PLATFORM_*SIMULATOR

The toolchain in Xcode 10 uses a new LC_BUILD_VERSION entry to identify
simulator binaries. Add support for reading those to debugserver.

The exisitng test testing that code is currently failling when run
with Xcode 10, no need for a new test.

Modified:
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=334784&r1=334783&r2=334784&view=diff
==
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Thu Jun 14 
19:50:45 2018
@@ -607,6 +607,11 @@ const char *MachProcess::GetDeploymentIn
 }
   }
 #if defined (LC_BUILD_VERSION)
+#ifndef PLATFORM_IOSSIMULATOR
+#define PLATFORM_IOSSIMULATOR 7
+#define PLATFORM_TVOSSIMULATOR 8
+#define PLATFORM_WATCHOSSIMULATOR 9
+#endif
   if (cmd == LC_BUILD_VERSION) {
 struct build_version_command build_vers;
 if (ReadMemory(load_command_address, sizeof(struct build_version_command),
@@ -621,10 +626,13 @@ const char *MachProcess::GetDeploymentIn
 case PLATFORM_MACOS:
   return "macosx";
 case PLATFORM_IOS:
+case PLATFORM_IOSSIMULATOR:
   return "ios";
 case PLATFORM_TVOS:
+case PLATFORM_TVOSSIMULATOR:
   return "tvos";
 case PLATFORM_WATCHOS:
+case PLATFORM_WATCHOSSIMULATOR:
   return "watchos";
 case PLATFORM_BRIDGEOS:
   return "bridgeos";


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