[Lldb-commits] [PATCH] D36496: Fix VASprintfTest.cpp for Darwin, add checks

2017-08-08 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu added a comment.

I'd prototyped this as simply prepending "DISABLED_" for non-Windows, but as 
this was designed as a temporary measure, I decided to ensure the same behavior 
was tested on Windows, and similar/equivalent behavior tested on other 
platforms.


https://reviews.llvm.org/D36496



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


[Lldb-commits] [PATCH] D36496: Fix VASprintfTest.cpp for Darwin, add checks

2017-08-08 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu created this revision.

The EncodingError test ensures that trying to encode a multibyte wchar
with a given codepage fails. If setlocale() fails, the encoding is
performed using the current locale, which may or may not fail.

This patch asserts that both setlocale() operations are successful, as
well as falling back to a widely available unibyte encoding for
non-Windows systems.

rdar://problem/33782806


https://reviews.llvm.org/D36496

Files:
  lldb.xcodeproj/project.pbxproj
  unittests/Utility/VASprintfTest.cpp


Index: unittests/Utility/VASprintfTest.cpp
===
--- unittests/Utility/VASprintfTest.cpp
+++ unittests/Utility/VASprintfTest.cpp
@@ -14,6 +14,12 @@
 
 #include 
 
+#if defined (_WIN32)
+#define TEST_ENCODING ".932"  // On Windows, test codepage 932
+#else
+#define TEST_ENCODING "C" // ...otherwise, any widely available uni-byte LC
+#endif
+
 using namespace lldb_private;
 using namespace llvm;
 
@@ -46,14 +52,16 @@
   // Save the current locale first.
   std::string Current(::setlocale(LC_ALL, nullptr));
 
-  setlocale(LC_ALL, ".932");
+  // Ensure tested locale is successfully set
+  ASSERT_TRUE(setlocale(LC_ALL, TEST_ENCODING));
 
   wchar_t Invalid[2];
   Invalid[0] = 0x100;
   Invalid[1] = 0;
   llvm::SmallString<32> Buffer;
   EXPECT_FALSE(Sprintf(Buffer, "%ls", Invalid));
   EXPECT_EQ("", Buffer);
 
-  setlocale(LC_ALL, Current.c_str());
+  // Ensure we've restored the original locale once tested
+  ASSERT_TRUE(setlocale(LC_ALL, Current.c_str()));
 }
Index: lldb.xcodeproj/project.pbxproj
===
--- lldb.xcodeproj/project.pbxproj
+++ lldb.xcodeproj/project.pbxproj
@@ -875,6 +875,7 @@
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = 
PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
9A1E595C1EB2B141002206A5 /* SBTrace.cpp in Sources */ = {isa = 
PBXBuildFile; fileRef = 9A1E59521EB2B0B9002206A5 /* SBTrace.cpp */; };
9A1E595D1EB2B141002206A5 /* SBTraceOptions.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A1E59531EB2B0B9002206A5 /* SBTraceOptions.cpp 
*/; };
+   9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A3D43C41F3150D200EB767C /* VASprintfTest.cpp 
*/; };
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* 
EmulateInstructionARM.cpp */; };
9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 9A22A15F135E30370024DDC3 /* 
EmulationStateARM.cpp */; };
9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa 
= PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
@@ -7092,6 +7093,7 @@
AFEC5FD81D94F9380076A480 /* 
Testx86AssemblyInspectionEngine.cpp in Sources */,
23CB15401D66DA9300EDDDE1 /* 
TestClangASTContext.cpp in Sources */,
23CB15411D66DA9300EDDDE1 /* 
StringExtractorTest.cpp in Sources */,
+   9A2057031F3A605200F6C293 /* VASprintfTest.cpp 
in Sources */,
23CB15421D66DA9300EDDDE1 /* TaskPoolTest.cpp in 
Sources */,
23CB15431D66DA9300EDDDE1 /* BroadcasterTest.cpp 
in Sources */,
9A3D43EE1F3237F900EB767C /* 
StreamCallbackTest.cpp in Sources */,


Index: unittests/Utility/VASprintfTest.cpp
===
--- unittests/Utility/VASprintfTest.cpp
+++ unittests/Utility/VASprintfTest.cpp
@@ -14,6 +14,12 @@
 
 #include 
 
+#if defined (_WIN32)
+#define TEST_ENCODING ".932"  // On Windows, test codepage 932
+#else
+#define TEST_ENCODING "C" // ...otherwise, any widely available uni-byte LC
+#endif
+
 using namespace lldb_private;
 using namespace llvm;
 
@@ -46,14 +52,16 @@
   // Save the current locale first.
   std::string Current(::setlocale(LC_ALL, nullptr));
 
-  setlocale(LC_ALL, ".932");
+  // Ensure tested locale is successfully set
+  ASSERT_TRUE(setlocale(LC_ALL, TEST_ENCODING));
 
   wchar_t Invalid[2];
   Invalid[0] = 0x100;
   Invalid[1] = 0;
   llvm::SmallString<32> Buffer;
   EXPECT_FALSE(Sprintf(Buffer, "%ls", Invalid));
   EXPECT_EQ("", Buffer);
 
-  setlocale(LC_ALL, Current.c_str());
+  // Ensure we've restored the original locale once tested
+  ASSERT_TRUE(setlocale(LC_ALL, Current.c_str()));
 }
Index: lldb.xcodeproj/project.pbxproj
===
--- lldb.xcodeproj/project.pbxproj
+++ lldb.xcodeproj/project.pbxproj
@@ -875,6 +875,7 @@
 		9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 

[Lldb-commits] [PATCH] D36485: Add existing unit tests to Xcode project

2017-08-08 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu added a comment.

Committing 'https://reviews.llvm.org/D36485: Add existing unit tests to Xcode 
project'...
Sendinglldb.xcodeproj/project.pbxproj
Transmitting file data .done
Committing transaction...
Committed revision 310417.
Closing revision https://reviews.llvm.org/D36485 'Add existing unit tests to 
Xcode project'...
Done.


https://reviews.llvm.org/D36485



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


[Lldb-commits] [lldb] r310417 - Add existing unit tests to Xcode project

2017-08-08 Thread Tim Hammerquist via lldb-commits
Author: penryu
Date: Tue Aug  8 13:59:20 2017
New Revision: 310417

URL: http://llvm.org/viewvc/llvm-project?rev=310417=rev
Log:
Add existing unit tests to Xcode project

Summary:
This adds gtest test files to the Xcode project which were
previously only in the cmake config. This is the first of several
planned merges.

Reviewers: beanz, spyffe, jingham

Reviewed By: jingham

Subscribers: lldb-commits

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

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

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=310417=310416=310417=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug  8 13:59:20 2017
@@ -885,6 +885,18 @@
9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = 
PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; };
9A36D24D1EB3BE7F00AAD9EA /* SBTrace.h in Headers */ = {isa = 
PBXBuildFile; fileRef = 9A1E59581EB2B10D002206A5 /* SBTrace.h */; settings = 
{ATTRIBUTES = (Public, ); }; };
9A36D24E1EB3BE7F00AAD9EA /* SBTraceOptions.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 9A1E59591EB2B10D002206A5 /* SBTraceOptions.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
+   9A3D43D61F3151C400EB767C /* ConstStringTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A3D43C81F3150D200EB767C /* ConstStringTest.cpp 
*/; };
+   9A3D43D71F3151C400EB767C /* LogTest.cpp in Sources */ = {isa = 
PBXBuildFile; fileRef = 9A3D43C71F3150D200EB767C /* LogTest.cpp */; };
+   9A3D43D81F3151C400EB767C /* NameMatchesTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A3D43CB1F3150D200EB767C /* NameMatchesTest.cpp 
*/; };
+   9A3D43D91F3151C400EB767C /* StatusTest.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 9A3D43C61F3150D200EB767C /* StatusTest.cpp */; };
+   9A3D43DA1F3151C400EB767C /* StructuredDataTest.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 9A3D43CA1F3150D200EB767C /* 
StructuredDataTest.cpp */; };
+   9A3D43DB1F3151C400EB767C /* TildeExpressionResolverTest.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C91F3150D200EB767C /* 
TildeExpressionResolverTest.cpp */; };
+   9A3D43DC1F3151C400EB767C /* TimeoutTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A3D43CC1F3150D200EB767C /* TimeoutTest.cpp */; 
};
+   9A3D43DD1F3151C400EB767C /* TimerTest.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 9A3D43C51F3150D200EB767C /* TimerTest.cpp */; };
+   9A3D43EC1F3237F900EB767C /* ListenerTest.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */; 
};
+   9A3D43ED1F3237F900EB767C /* StateTest.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 9A3D43E21F3237D500EB767C /* StateTest.cpp */; };
+   9A3D43EE1F3237F900EB767C /* StreamCallbackTest.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 9A3D43E11F3237D500EB767C /* 
StreamCallbackTest.cpp */; };
+   9A3D43F01F32380D00EB767C /* debugserver in CopyFiles */ = {isa 
= PBXBuildFile; fileRef = 9A3D43EF1F32380D00EB767C /* debugserver */; };
9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 9A4F350F1368A51A00823F52 /* 
StreamAsynchronousIO.cpp */; };
9A77AD541E64E2760025CE04 /* RegisterInfoPOSIX_arm.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 9A77AD501E64E24E0025CE04 /* 
RegisterInfoPOSIX_arm.cpp */; };
9AC7038E117674FB0086C050 /* SBInstruction.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 9AC7038D117674EB0086C050 /* SBInstruction.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
@@ -1200,6 +1212,7 @@
dstSubfolderSpec = 0;
files = (
AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles 
*/,
+   9A3D43F01F32380D00EB767C /* debugserver in 
CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
@@ -2843,6 +2856,20 @@
9A357672116E7B6400E8ED2F /* SBStringList.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = SBStringList.cpp; path = source/API/SBStringList.cpp; sourceTree = 
""; };
9A3576A7116E9AB700E8ED2F /* SBHostOS.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
SBHostOS.h; path = include/lldb/API/SBHostOS.h; sourceTree = ""; };
9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = 

[Lldb-commits] [PATCH] D36485: Add existing unit tests to Xcode project

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

Looks good.


https://reviews.llvm.org/D36485



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


[Lldb-commits] [PATCH] D36485: Add existing unit tests to Xcode project

2017-08-08 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu edited reviewers, added: spyffe, jingham; removed: zturner, labath.
penryu added a comment.

This is really an Xcode-only change.


https://reviews.llvm.org/D36485



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


[Lldb-commits] [PATCH] D36485: Add existing unit tests to Xcode project

2017-08-08 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu created this revision.

This adds gtest test files to the Xcode project which were
previously only in the cmake config. This is the first of several
planned merges.


https://reviews.llvm.org/D36485

Files:
  lldb.xcodeproj/project.pbxproj

Index: lldb.xcodeproj/project.pbxproj
===
--- lldb.xcodeproj/project.pbxproj
+++ lldb.xcodeproj/project.pbxproj
@@ -885,6 +885,18 @@
 		9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; };
 		9A36D24D1EB3BE7F00AAD9EA /* SBTrace.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A1E59581EB2B10D002206A5 /* SBTrace.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9A36D24E1EB3BE7F00AAD9EA /* SBTraceOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A1E59591EB2B10D002206A5 /* SBTraceOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		9A3D43D61F3151C400EB767C /* ConstStringTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C81F3150D200EB767C /* ConstStringTest.cpp */; };
+		9A3D43D71F3151C400EB767C /* LogTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C71F3150D200EB767C /* LogTest.cpp */; };
+		9A3D43D81F3151C400EB767C /* NameMatchesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43CB1F3150D200EB767C /* NameMatchesTest.cpp */; };
+		9A3D43D91F3151C400EB767C /* StatusTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C61F3150D200EB767C /* StatusTest.cpp */; };
+		9A3D43DA1F3151C400EB767C /* StructuredDataTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43CA1F3150D200EB767C /* StructuredDataTest.cpp */; };
+		9A3D43DB1F3151C400EB767C /* TildeExpressionResolverTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C91F3150D200EB767C /* TildeExpressionResolverTest.cpp */; };
+		9A3D43DC1F3151C400EB767C /* TimeoutTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43CC1F3150D200EB767C /* TimeoutTest.cpp */; };
+		9A3D43DD1F3151C400EB767C /* TimerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C51F3150D200EB767C /* TimerTest.cpp */; };
+		9A3D43EC1F3237F900EB767C /* ListenerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */; };
+		9A3D43ED1F3237F900EB767C /* StateTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43E21F3237D500EB767C /* StateTest.cpp */; };
+		9A3D43EE1F3237F900EB767C /* StreamCallbackTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43E11F3237D500EB767C /* StreamCallbackTest.cpp */; };
+		9A3D43F01F32380D00EB767C /* debugserver in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9A3D43EF1F32380D00EB767C /* debugserver */; };
 		9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */; };
 		9A77AD541E64E2760025CE04 /* RegisterInfoPOSIX_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A77AD501E64E24E0025CE04 /* RegisterInfoPOSIX_arm.cpp */; };
 		9AC7038E117674FB0086C050 /* SBInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038D117674EB0086C050 /* SBInstruction.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1200,6 +1212,7 @@
 			dstSubfolderSpec = 0;
 			files = (
 AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */,
+9A3D43F01F32380D00EB767C /* debugserver in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 1;
 		};
@@ -2843,6 +2856,20 @@
 		9A357672116E7B6400E8ED2F /* SBStringList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBStringList.cpp; path = source/API/SBStringList.cpp; sourceTree = ""; };
 		9A3576A7116E9AB700E8ED2F /* SBHostOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBHostOS.h; path = include/lldb/API/SBHostOS.h; sourceTree = ""; };
 		9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBHostOS.cpp; path = source/API/SBHostOS.cpp; sourceTree = ""; };
+		9A3D43C41F3150D200EB767C /* VASprintfTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VASprintfTest.cpp; sourceTree = ""; };
+		9A3D43C51F3150D200EB767C /* TimerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimerTest.cpp; sourceTree = ""; };
+		9A3D43C61F3150D200EB767C /* StatusTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatusTest.cpp; sourceTree = ""; };
+		9A3D43C71F3150D200EB767C /* LogTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LogTest.cpp; sourceTree = ""; };
+		9A3D43C81F3150D200EB767C /* ConstStringTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 

[Lldb-commits] [PATCH] D36485: Add existing unit tests to Xcode project

2017-08-08 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu added a comment.

Note that VASprintfTest.cpp is added to the xcodeproj but not added to the 
lldb-gtest-build target _YET_. It needs some work before I can enable it.


https://reviews.llvm.org/D36485



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


[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd

2017-08-08 Thread Ed Maste via Phabricator via lldb-commits
emaste added a comment.

> Actually, I think you probably need to extend the @skipIfLinux to apply to 
> freebsd as well.

Oh, I mistook the source of the check_stop_reason assertion failure -- I 
thought it was asserting before the step. In this case I agree the test should 
be skipped on FreeBSD.


Repository:
  rL LLVM

https://reviews.llvm.org/D35223



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


Re: [Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd

2017-08-08 Thread Jim Ingham via lldb-commits

> On Aug 8, 2017, at 12:02 AM, Pavel Labath via Phabricator via lldb-commits 
>  wrote:
> 
> labath added a comment.
> 
> In https://reviews.llvm.org/D35223#834050, @emaste wrote:
> 
>> With this patch I observed three new failures on FreeBSD and three new 
>> unexpected passes on FreeBSD. An example of a new failure:
>> 
>>  ==
>>  FAIL: test_inferior_crashing_expr_step_and_expr_dwarf 
>> (TestInferiorCrashing.CrashingInferiorTestCase)
>> Test that lldb expressions work before and after stepping after a crash.
>>  --
>>  Traceback (most recent call last):
>>File 
>> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py",
>>  line 1732, in dwarf_test_method
>>  return attrvalue(self)
>>File 
>> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/decorators.py",
>>  line 110, in wrapper
>>  func(*args, **kwargs)
>>File 
>> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py",
>>  line 82, in test_inferior_crashing_expr_step_and_expr
>>  self.inferior_crashing_expr_step_expr()
>>File 
>> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py",
>>  line 249, in inferior_crashing_expr_step_expr
>>  self.check_stop_reason()
>>File 
>> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py",
>>  line 93, in check_stop_reason
>>  STOPPED_DUE_TO_EXC_BAD_ACCESS)
>>  AssertionError: 0 != 1 : Process should be stopped due to bad access 
>> exception
>>  Config=x86_64-/usr/bin/cc
>>  --
>>  Ran 7 tests in 4.320s
>> 
>> 
>> From lldbsuite/test/lldbutil.py:
>> 
>>  def is_thread_crashed(test, thread):
>>  """In the test suite we dereference a null pointer to simulate a crash. 
>> The way this is
>>  reported depends on the platform."""
>>  if test.platformIsDarwin():
>>  return thread.GetStopReason(
>>  ) == lldb.eStopReasonException and "EXC_BAD_ACCESS" in 
>> thread.GetStopDescription(100)
>>  elif test.getPlatform() == "linux":
>>  return thread.GetStopReason() == lldb.eStopReasonSignal and 
>> thread.GetStopReasonDataAtIndex(
>>  0) == 
>> thread.GetProcess().GetUnixSignals().GetSignalNumberFromName("SIGSEGV")
>>  else:
>>  return "invalid address" in thread.GetStopDescription(100)
>> 
>> 
>> Presumably we want the second case to apply on FreeBSD as well when this 
>> patch is in, although I don't see why the existing else case shouldn't 
>> continue to work correctly.
> 
> 
> Actually, I think you probably need to extend the `@skipIfLinux` to apply to 
> freebsd as well. The reason is that the test is doing something which goes 
> fundamentally against this patch -- it expects that "step" after a "crash" is 
> a no-op, whereas the new behavior will be to let the process continue (and 
> probably exit, unless it has a SEGV handler). That behavior may make sense 
> for mach exceptions, but I don't think we should try to make posix signals 
> emulate that behavior.

Just to be clear, the behavior doesn't make sense for mach exceptions either.  
A darwin program running outside the debugger will get an EXC_BAD_ACCESS Mach 
Exception, but if that exception is unhandled at the thread & task levels the 
system handler will convert it to a BSD SIGSEGV and that will get dispatched to 
the appropriate signal handler.  So darwin and linux really should behave the 
same way in this respect.  The fact that it doesn't is a bug, so it's a little 
odd that we have a test that codifies a bug.  

For those interested, the problem is that the port you have to forward the 
exception to to trigger the Exception->Signal conversion is a privileged port, 
and lldb doesn't have permissions to send to it.  I have an idea about how to 
work around this, but I'm not 100% sure it will work and this doesn't affect 
very many folks so trying it out it hasn't bubbled to the top of my queue yet.

Anyway, stepping after a crash should either cause the program to exit, or to 
end up in the signal handler.  The macOS behavior is really wrong.  This test 
would be useful on linux too - ensuring that hitting a signal doesn't mess up 
lldb's notion of the program state.  The test isn't written right to test this 
situation on Linux, but you could add a signal handler to the main.c and in 
this test set a breakpoint there and assert that the step after the crash 
actually triggers a breakpoint in the signal handler, and you can then that run 
expressions.  If you wanted to baby lldb along, you would do the same check as 
the plain step case and excuse darwin it's inability to get 

[Lldb-commits] [lldb] r310341 - Checking in files accidentally missed in later diffs of revision r310261

2017-08-08 Thread Abhishek Aggarwal via lldb-commits
Author: abhishek
Date: Tue Aug  8 02:25:50 2017
New Revision: 310341

URL: http://llvm.org/viewvc/llvm-project?rev=310341=rev
Log:
Checking in files accidentally missed in later diffs of revision r310261

 -- 2 files were missing in this commit which should have been there.
These files were submitted initially for review and were reviewed.
However, while updating the revision with newer diffs, I accidentally
forgot to include them in newer diffs. So commiting now.


Added:
lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.h

Added: lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp?rev=310341=auto
==
--- lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp (added)
+++ lldb/trunk/tools/intel-features/intel-pt/cli-wrapper-pt.cpp Tue Aug  8 
02:25:50 2017
@@ -0,0 +1,583 @@
+//===-- cli-wrapper-pt.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+// CLI Wrapper of PTDecoder Tool to enable it to be used through LLDB's CLI. 
The
+// wrapper provides a new command called processor-trace with 4 child
+// subcommands as follows:
+// processor-trace start
+// processor-trace stop
+// processor-trace show-trace-options
+// processor-trace show-instr-log
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "PTDecoder.h"
+#include "cli-wrapper-pt.h"
+#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBThread.h"
+
+static bool GetProcess(lldb::SBDebugger ,
+   lldb::SBCommandReturnObject ,
+   lldb::SBProcess ) {
+  if (!debugger.IsValid()) {
+result.Printf("error: invalid debugger\n");
+result.SetStatus(lldb::eReturnStatusFailed);
+return false;
+  }
+
+  lldb::SBTarget target = debugger.GetSelectedTarget();
+  if (!target.IsValid()) {
+result.Printf("error: invalid target inside debugger\n");
+result.SetStatus(lldb::eReturnStatusFailed);
+return false;
+  }
+
+  process = target.GetProcess();
+  if (!process.IsValid() ||
+  (process.GetState() == lldb::StateType::eStateDetached) ||
+  (process.GetState() == lldb::StateType::eStateExited) ||
+  (process.GetState() == lldb::StateType::eStateInvalid)) {
+result.Printf("error: invalid process inside debugger's target\n");
+result.SetStatus(lldb::eReturnStatusFailed);
+return false;
+  }
+
+  return true;
+}
+
+static bool ParseCommandOption(char **command,
+   lldb::SBCommandReturnObject ,
+   uint32_t , const std::string ,
+   uint32_t _result) {
+  char *endptr;
+  if (!command[++index]) {
+result.Printf("error: option \"%s\" requires an argument\n", arg.c_str());
+result.SetStatus(lldb::eReturnStatusFailed);
+return false;
+  }
+
+  errno = 0;
+  unsigned long output = strtoul(command[index], , 0);
+  if ((errno != 0) || (*endptr != '\0')) {
+result.Printf("error: invalid value \"%s\" provided for option \"%s\"\n",
+  command[index], arg.c_str());
+result.SetStatus(lldb::eReturnStatusFailed);
+return false;
+  }
+  if (output > UINT32_MAX) {
+result.Printf("error: value \"%s\" for option \"%s\" exceeds UINT32_MAX\n",
+  command[index], arg.c_str());
+result.SetStatus(lldb::eReturnStatusFailed);
+return false;
+  }
+  parsed_result = (uint32_t)output;
+  return true;
+}
+
+static bool ParseCommandArgThread(char **command,
+  lldb::SBCommandReturnObject ,
+  lldb::SBProcess , uint32_t ,
+  lldb::tid_t _id) {
+  char *endptr;
+  if (!strcmp(command[index], "all"))
+thread_id = LLDB_INVALID_THREAD_ID;
+  else {
+uint32_t thread_index_id;
+errno = 0;
+unsigned long output = strtoul(command[index], , 0);
+if ((errno != 0) || (*endptr != '\0') || (output > UINT32_MAX)) {
+  result.Printf("error: invalid thread specification: \"%s\"\n",
+command[index]);
+  result.SetStatus(lldb::eReturnStatusFailed);
+  return false;
+}
+thread_index_id = (uint32_t)output;
+
+lldb::SBThread thread = process.GetThreadByIndexID(thread_index_id);
+if (!thread.IsValid()) {
+  result.Printf(
+  

[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd

2017-08-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D35223#834050, @emaste wrote:

> With this patch I observed three new failures on FreeBSD and three new 
> unexpected passes on FreeBSD. An example of a new failure:
>
>   ==
>   FAIL: test_inferior_crashing_expr_step_and_expr_dwarf 
> (TestInferiorCrashing.CrashingInferiorTestCase)
>  Test that lldb expressions work before and after stepping after a crash.
>   --
>   Traceback (most recent call last):
> File 
> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py",
>  line 1732, in dwarf_test_method
>   return attrvalue(self)
> File 
> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/decorators.py",
>  line 110, in wrapper
>   func(*args, **kwargs)
> File 
> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py",
>  line 82, in test_inferior_crashing_expr_step_and_expr
>   self.inferior_crashing_expr_step_expr()
> File 
> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py",
>  line 249, in inferior_crashing_expr_step_expr
>   self.check_stop_reason()
> File 
> "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py",
>  line 93, in check_stop_reason
>   STOPPED_DUE_TO_EXC_BAD_ACCESS)
>   AssertionError: 0 != 1 : Process should be stopped due to bad access 
> exception
>   Config=x86_64-/usr/bin/cc
>   --
>   Ran 7 tests in 4.320s
>
>
> From lldbsuite/test/lldbutil.py:
>
>   def is_thread_crashed(test, thread):
>   """In the test suite we dereference a null pointer to simulate a crash. 
> The way this is
>   reported depends on the platform."""
>   if test.platformIsDarwin():
>   return thread.GetStopReason(
>   ) == lldb.eStopReasonException and "EXC_BAD_ACCESS" in 
> thread.GetStopDescription(100)
>   elif test.getPlatform() == "linux":
>   return thread.GetStopReason() == lldb.eStopReasonSignal and 
> thread.GetStopReasonDataAtIndex(
>   0) == 
> thread.GetProcess().GetUnixSignals().GetSignalNumberFromName("SIGSEGV")
>   else:
>   return "invalid address" in thread.GetStopDescription(100)
>
>
> Presumably we want the second case to apply on FreeBSD as well when this 
> patch is in, although I don't see why the existing else case shouldn't 
> continue to work correctly.


Actually, I think you probably need to extend the `@skipIfLinux` to apply to 
freebsd as well. The reason is that the test is doing something which goes 
fundamentally against this patch -- it expects that "step" after a "crash" is a 
no-op, whereas the new behavior will be to let the process continue (and 
probably exit, unless it has a SEGV handler). That behavior may make sense for 
mach exceptions, but I don't think we should try to make posix signals emulate 
that behavior.


Repository:
  rL LLVM

https://reviews.llvm.org/D35223



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