[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

llvm-svn: 234469
This commit is contained in:
Mohit K. Bhakkad 2015-04-09 07:12:15 +00:00
parent 0eccfdc655
commit 2c2acf9602
6 changed files with 118 additions and 3 deletions

View File

@ -597,13 +597,19 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target,
}
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;
}
if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))

View File

@ -3230,6 +3230,7 @@ NativeProcessLinux::GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hin
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::GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hin
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");

View File

@ -9,6 +9,7 @@ add_lldb_library(lldbPluginProcessUtility
HistoryUnwind.cpp
InferiorCallPOSIX.cpp
LinuxSignals.cpp
MipsLinuxSignals.cpp
RegisterContextDarwin_arm.cpp
RegisterContextDarwin_arm64.cpp
RegisterContextDarwin_i386.cpp

View File

@ -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");
}

View File

@ -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

View File

@ -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,6 +718,9 @@ ProcessGDBRemote::DoConnectRemote (Stream *strm, const char *remote_url)
switch (arch_spec.GetTriple ().getOS ())
{
case llvm::Triple::Linux:
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 ());