[Lldb-commits] [PATCH] D33998: Add pretty-printer for wait(2) statuses and modernize the code handling them

2017-06-13 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 2 inline comments as done.
labath added inline comments.



Comment at: source/Host/common/Host.cpp:1010
+static constexpr char type[] = "WXS";
+OS << formatv("{0}{1:x-2}", type[WS.type], WS.status);
+return;

eugene wrote:
>  type[WS.type] seems to be a somewhat unnecessary hack. I would use a simple 
> switch here.
I wouldn't call it a hack. :) More like data-oriented programming... :P
I wrote it like this because fully
clang-formatted
switches
tend
to
be
loong
.

But I don't care about it too much.


https://reviews.llvm.org/D33998



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


[Lldb-commits] [PATCH] D33998: Add pretty-printer for wait(2) statuses and modernize the code handling them

2017-06-13 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 102309.
labath marked an inline comment as done.
labath added a comment.

Use a switch instead of indexing the array with an enum value


https://reviews.llvm.org/D33998

Files:
  include/lldb/Host/Host.h
  include/lldb/Host/common/NativeProcessProtocol.h
  include/lldb/lldb-private-enumerations.h
  source/Host/common/Host.cpp
  source/Host/common/NativeProcessProtocol.cpp
  source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.h
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  unittests/Host/CMakeLists.txt
  unittests/Host/HostTest.cpp

Index: unittests/Host/HostTest.cpp
===
--- /dev/null
+++ unittests/Host/HostTest.cpp
@@ -0,0 +1,22 @@
+//===-- HostTest.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Host/Host.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace llvm;
+
+TEST(Host, WaitStatusFormat) {
+  EXPECT_EQ("W01", formatv("{0:g}", WaitStatus{WaitStatus::Exit, 1}).str());
+  EXPECT_EQ("X02", formatv("{0:g}", WaitStatus{WaitStatus::Signal, 2}).str());
+  EXPECT_EQ("S03", formatv("{0:g}", WaitStatus{WaitStatus::Stop, 3}).str());
+  EXPECT_EQ("Exited with status 4",
+formatv("{0}", WaitStatus{WaitStatus::Exit, 4}).str());
+}
Index: unittests/Host/CMakeLists.txt
===
--- unittests/Host/CMakeLists.txt
+++ unittests/Host/CMakeLists.txt
@@ -1,6 +1,7 @@
 set (FILES
   FileSpecTest.cpp
   FileSystemTest.cpp
+  HostTest.cpp
   MainLoopTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -370,53 +370,23 @@
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
 
   // send W notification
-  ExitType exit_type = ExitType::eExitTypeInvalid;
-  int return_code = 0;
-  std::string exit_description;
-
-  const bool got_exit_info =
-  process->GetExitStatus(&exit_type, &return_code, exit_description);
-  if (!got_exit_info) {
-if (log)
-  log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
-  ", failed to retrieve process exit status",
-  __FUNCTION__, process->GetID());
+  auto wait_status = process->GetExitStatus();
+  if (!wait_status) {
+LLDB_LOG(log, "pid = {0}, failed to retrieve process exit status",
+ process->GetID());
 
 StreamGDBRemote response;
 response.PutChar('E');
 response.PutHex8(GDBRemoteServerError::eErrorExitStatus);
 return SendPacketNoLock(response.GetString());
-  } else {
-if (log)
-  log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
-  ", returning exit type %d, return code %d [%s]",
-  __FUNCTION__, process->GetID(), exit_type, return_code,
-  exit_description.c_str());
-
-StreamGDBRemote response;
-
-char return_type_code;
-switch (exit_type) {
-case ExitType::eExitTypeExit:
-  return_type_code = 'W';
-  break;
-case ExitType::eExitTypeSignal:
-  return_type_code = 'X';
-  break;
-case ExitType::eExitTypeStop:
-  return_type_code = 'S';
-  break;
-case ExitType::eExitTypeInvalid:
-  return_type_code = 'E';
-  break;
-}
-response.PutChar(return_type_code);
+  }
 
-// POSIX exit status limited to unsigned 8 bits.
-response.PutHex8(return_code);
+  LLDB_LOG(log, "pid = {0}, returning exit type {1}", process->GetID(),
+   *wait_status);
 
-return SendPacketNoLock(response.GetString());
-  }
+  StreamGDBRemote response;
+  response.Format("{0:g}", *wait_status);
+  return SendPacketNoLock(response.GetString());
 }
 
 static void AppendHexValue(StreamString &response, const uint8_t *buf,
Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
===
--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -123,7 +123,7 @@
   void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error);
 
   void MonitorCallback(lldb::pid_t pid, int signal);
-  void MonitorExited(lldb::pid_t pid, int signal, int

[Lldb-commits] [lldb] r305286 - Mark TestCallThatRestarts as flaky on android

2017-06-13 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Jun 13 06:13:11 2017
New Revision: 305286

URL: http://llvm.org/viewvc/llvm-project?rev=305286&view=rev
Log:
Mark TestCallThatRestarts as flaky on android

This test started being flaky since r303848 (RunThreadPlan: Fix halting
logic in IgnoreBreakpoints = false). I am not reverting that, as I am
confident that actually fixed a problem. A more likely explanation is
that there is still one corner case that is not handled correctly there.

Marking the test as flaky until I get a chance to investigate. I also
mark the test as no-debug-info-dependend -- it stresses expression
evaluation, as far as debug info goes, the test if extremely simple.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py?rev=305286&r1=305285&r2=305286&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py
 Tue Jun 13 06:13:11 2017
@@ -14,6 +14,7 @@ from lldbsuite.test import lldbutil
 class ExprCommandThatRestartsTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
 
 def setUp(self):
 # Call super's setUp().
@@ -25,6 +26,7 @@ class ExprCommandThatRestartsTestCase(Te
 @skipIfFreeBSD  # llvm.org/pr19246: intermittent failure
 @skipIfDarwin  # llvm.org/pr19246: intermittent failure
 @skipIfWindows  # Test relies on signals, unsupported on Windows
+@expectedFlakeyAndroid(bugnumber="llvm.org/pr19246")
 def test(self):
 """Test calling function that hits a signal and restarts."""
 self.build()


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