[Lldb-commits] [lldb] r234469 - [LLDB][MIPS] Add LinuxSignals for mips64 and change trap opcode for mips64el.

Mohit K. Bhakkad mohit.bhakkad at gmail.com
Thu Apr 9 00:12:16 PDT 2015


Author: mohit.bhakkad
Date: Thu Apr  9 02:12:15 2015
New Revision: 234469

URL: http://llvm.org/viewvc/llvm-project?rev=234469&view=rev
Log:
[LLDB][MIPS] Add LinuxSignals for mips64 and change trap opcode for mips64el.
Patch by Sagar Thakur

- Added LinuxSignals for MIPS64.
- Changed software trap opcode for mips64el.

Reviewers: clayborg, tberghammer.

Subscribers: emaste, jaydeep, bhushan, mohit.bhakkad, llvm-commits.

Differential Revision: http://reviews.llvm.org/D8856

Added:
    lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
    lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h
Modified:
    lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
    lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=234469&r1=234468&r2=234469&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Thu Apr  9 02:12:15 2015
@@ -597,12 +597,18 @@ PlatformLinux::GetSoftwareBreakpointTrap
         }
         break;
     case llvm::Triple::mips64:
-    case llvm::Triple::mips64el:
         {
             static const uint8_t g_hex_opcode[] = { 0x00, 0x00, 0x00, 0x0d };
             trap_opcode = g_hex_opcode;
             trap_opcode_size = sizeof(g_hex_opcode);
         }
+        break;
+    case llvm::Triple::mips64el:
+        {
+            static const uint8_t g_hex_opcode[] = { 0x0d, 0x00, 0x00, 0x00 };
+            trap_opcode = g_hex_opcode;
+            trap_opcode_size = sizeof(g_hex_opcode);
+        }
         break;
     }
 

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=234469&r1=234468&r2=234469&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu Apr  9 02:12:15 2015
@@ -3230,6 +3230,7 @@ NativeProcessLinux::GetSoftwareBreakpoin
     static const uint8_t g_aarch64_opcode[] = { 0x00, 0x00, 0x20, 0xd4 };
     static const uint8_t g_i386_opcode [] = { 0xCC };
     static const uint8_t g_mips64_opcode[] = { 0x00, 0x00, 0x00, 0x0d };
+    static const uint8_t g_mips64el_opcode[] = { 0x0d, 0x00, 0x00, 0x00 };
 
     switch (m_arch.GetMachine ())
     {
@@ -3245,11 +3246,15 @@ NativeProcessLinux::GetSoftwareBreakpoin
         return Error ();
 
     case llvm::Triple::mips64:
-    case llvm::Triple::mips64el:
         trap_opcode_bytes = g_mips64_opcode;
         actual_opcode_size = sizeof(g_mips64_opcode);
         return Error ();
 
+    case llvm::Triple::mips64el:
+        trap_opcode_bytes = g_mips64el_opcode;
+        actual_opcode_size = sizeof(g_mips64el_opcode);
+        return Error ();
+
     default:
         assert(false && "CPU type not supported!");
         return Error ("CPU type not supported");

Modified: lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt?rev=234469&r1=234468&r2=234469&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt Thu Apr  9 02:12:15 2015
@@ -9,6 +9,7 @@ add_lldb_library(lldbPluginProcessUtilit
   HistoryUnwind.cpp
   InferiorCallPOSIX.cpp
   LinuxSignals.cpp
+  MipsLinuxSignals.cpp
   RegisterContextDarwin_arm.cpp
   RegisterContextDarwin_arm64.cpp
   RegisterContextDarwin_i386.cpp

Added: lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp?rev=234469&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp (added)
+++ lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp Thu Apr  9 02:12:15 2015
@@ -0,0 +1,62 @@
+//===-- MipsLinuxSignals.cpp ----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "MipsLinuxSignals.h"
+
+using namespace lldb_private::process_linux;
+
+MipsLinuxSignals::MipsLinuxSignals()
+    : UnixSignals()
+{
+    Reset();
+}
+
+void
+MipsLinuxSignals::Reset()
+{
+    m_signals.clear();
+
+    AddSignal (1,    "SIGHUP",    "HUP",     false,   true , true , "hangup");
+    AddSignal (2,    "SIGINT",    "INT",     true ,   true , true , "interrupt");
+    AddSignal (3,    "SIGQUIT",   "QUIT",    false,   true , true , "quit");
+    AddSignal (4,    "SIGILL",    "ILL",     false,   true , true , "illegal instruction");
+    AddSignal (5,    "SIGTRAP",   "TRAP",    true ,   true , true , "trace trap (not reset when caught)");
+    AddSignal (6,    "SIGABRT",   "ABRT",    false,   true , true , "abort()");
+    AddSignal (6,    "SIGIOT",    "IOT",     false,   true , true , "IOT trap");
+    AddSignal (7,    "SIGEMT",    "EMT",     false,   true , true , "terminate process with core dump");
+    AddSignal (8,    "SIGFPE",    "FPE",     false,   true , true , "floating point exception");
+    AddSignal (9,    "SIGKILL",   "KILL",    false,   true , true , "kill");
+    AddSignal (10,   "SIGBUS",    "BUS",     false,   true , true , "bus error");
+    AddSignal (11,   "SIGSEGV",   "SEGV",    false,   true , true , "segmentation violation");
+    AddSignal (12,   "SIGSYS",    "SYS",     false,   true , true , "invalid system call");
+    AddSignal (13,   "SIGPIPE",   "PIPE",    false,   true , true , "write to pipe with reading end closed");
+    AddSignal (14,   "SIGALRM",   "ALRM",    false,   false, false, "alarm");
+    AddSignal (15,   "SIGTERM",   "TERM",    false,   true , true , "termination requested");
+    AddSignal (16,   "SIGUSR1",   "USR1",    false,   true , true , "user defined signal 1");
+    AddSignal (17,   "SIGUSR2",   "USR2",    false,   true , true , "user defined signal 2");
+    AddSignal (18,   "SIGCLD",    "CLD",     false,   false, true , "same as SIGCHLD");
+    AddSignal (18,   "SIGCHLD",   "CHLD",    false,   false, true , "child status has changed");
+    AddSignal (19,   "SIGPWR",    "PWR",     false,   true , true , "power failure");
+    AddSignal (20,   "SIGWINCH",  "WINCH",   false,   true , true , "window size changes");
+    AddSignal (21,   "SIGURG",    "URG",     false,   true , true , "urgent data on socket");
+    AddSignal (22,   "SIGIO",     "IO",      false,   true , true , "input/output ready");
+    AddSignal (22,   "SIGPOLL",   "POLL",    false,   true , true , "pollable event");
+    AddSignal (23,   "SIGSTOP",   "STOP",    true ,   true , true , "process stop");
+    AddSignal (24,   "SIGTSTP",   "TSTP",    false,   true , true , "tty stop");
+    AddSignal (25,   "SIGCONT",   "CONT",    false,   true , true , "process continue");
+    AddSignal (26,   "SIGTTIN",   "TTIN",    false,   true , true , "background tty read");
+    AddSignal (27,   "SIGTTOU",   "TTOU",    false,   true , true , "background tty write");
+    AddSignal (28,   "SIGVTALRM", "VTALRM",  false,   true , true , "virtual time alarm");
+    AddSignal (29,   "SIGPROF",   "PROF",    false,   false, false, "profiling time alarm");
+    AddSignal (30,   "SIGXCPU",   "XCPU",    false,   true , true , "CPU resource exceeded");
+    AddSignal (31,   "SIGXFSZ",   "XFSZ",    false,   true , true , "file size limit exceeded");
+}

Added: lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h?rev=234469&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h (added)
+++ lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h Thu Apr  9 02:12:15 2015
@@ -0,0 +1,37 @@
+//===-- MipsLinuxSignals.h ------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_MipsLinuxSignals_H_
+#define liblldb_MipsLinuxSignals_H_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/UnixSignals.h"
+
+namespace lldb_private {
+namespace process_linux {
+
+    /// Linux specific set of Unix signals.
+    class MipsLinuxSignals
+        : public lldb_private::UnixSignals
+    {
+    public:
+        MipsLinuxSignals();
+
+    private:
+        void
+        Reset();
+    };
+
+} // namespace lldb_private
+} // namespace process_linux
+
+#endif

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=234469&r1=234468&r2=234469&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Apr  9 02:12:15 2015
@@ -66,6 +66,7 @@
 #include "Plugins/Process/Utility/FreeBSDSignals.h"
 #include "Plugins/Process/Utility/InferiorCallPOSIX.h"
 #include "Plugins/Process/Utility/LinuxSignals.h"
+#include "Plugins/Process/Utility/MipsLinuxSignals.h"
 #include "Plugins/Process/Utility/StopInfoMachException.h"
 #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
 #include "Utility/StringExtractorGDBRemote.h"
@@ -717,7 +718,10 @@ ProcessGDBRemote::DoConnectRemote (Strea
             switch (arch_spec.GetTriple ().getOS ())
             {
             case llvm::Triple::Linux:
-                SetUnixSignals (UnixSignalsSP (new process_linux::LinuxSignals ()));
+                if (arch_spec.GetTriple ().getArch () == llvm::Triple::mips64 || arch_spec.GetTriple ().getArch () == llvm::Triple::mips64el)
+                    SetUnixSignals (UnixSignalsSP (new process_linux::MipsLinuxSignals ()));
+                else
+                    SetUnixSignals (UnixSignalsSP (new process_linux::LinuxSignals ()));
                 if (log)
                     log->Printf ("ProcessGDBRemote::%s using Linux unix signals type for pid %" PRIu64, __FUNCTION__, GetID ());
                 break;





More information about the lldb-commits mailing list