summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-04-29 17:24:48 +0000
committerChaoren Lin <chaorenl@google.com>2015-04-29 17:24:48 +0000
commit3eb4b4589e0094a39fa2e1a8b1e9f585b6cdaa69 (patch)
tree3962354cbc0c3233a9bd4d31f75c321f240a33ec /lldb/source/Plugins/Process
parent387ce30685ae178c87588fe9b5e18d7f1ff76864 (diff)
downloadbcm5719-llvm-3eb4b4589e0094a39fa2e1a8b1e9f585b6cdaa69.tar.gz
bcm5719-llvm-3eb4b4589e0094a39fa2e1a8b1e9f585b6cdaa69.zip
Remove trap code from disassembly.
Summary: NativeProcessProtocol uses ReadMemory internally for setting/checking breakpoints but also for generic memory reads (Handle_m), this change adds a ReadMemoryWithoutTrap for that purpose. Also fixes a bunch of misuses of addr_t as size/length. Test Plan: `disassemble` no longer shows the trap code. Reviewers: jingham, vharron, clayborg Reviewed By: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9330 llvm-svn: 236132
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp63
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.h9
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp10
3 files changed, 45 insertions, 37 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index c8cadecb833..e529867e083 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -345,19 +345,19 @@ namespace
// NativeProcessLinux::WriteMemory. This enables mutual recursion between these
// functions without needed to go thru the thread funnel.
- lldb::addr_t
- DoReadMemory (
+ size_t
+ DoReadMemory(
lldb::pid_t pid,
lldb::addr_t vm_addr,
void *buf,
- lldb::addr_t size,
+ size_t size,
Error &error)
{
// ptrace word size is determined by the host, not the child
static const unsigned word_size = sizeof(void*);
unsigned char *dst = static_cast<unsigned char*>(buf);
- lldb::addr_t bytes_read;
- lldb::addr_t remainder;
+ size_t bytes_read;
+ size_t remainder;
long data;
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_ALL));
@@ -407,19 +407,19 @@ namespace
return bytes_read;
}
- lldb::addr_t
+ size_t
DoWriteMemory(
lldb::pid_t pid,
lldb::addr_t vm_addr,
const void *buf,
- lldb::addr_t size,
+ size_t size,
Error &error)
{
// ptrace word size is determined by the host, not the child
static const unsigned word_size = sizeof(void*);
const unsigned char *src = static_cast<const unsigned char*>(buf);
- lldb::addr_t bytes_written = 0;
- lldb::addr_t remainder;
+ size_t bytes_written = 0;
+ size_t remainder;
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_ALL));
if (log)
@@ -526,11 +526,11 @@ namespace
class ReadOperation : public Operation
{
public:
- ReadOperation (
+ ReadOperation(
lldb::addr_t addr,
void *buff,
- lldb::addr_t size,
- lldb::addr_t &result) :
+ size_t size,
+ size_t &result) :
Operation (),
m_addr (addr),
m_buff (buff),
@@ -544,8 +544,8 @@ namespace
private:
lldb::addr_t m_addr;
void *m_buff;
- lldb::addr_t m_size;
- lldb::addr_t &m_result;
+ size_t m_size;
+ size_t &m_result;
};
void
@@ -560,11 +560,11 @@ namespace
class WriteOperation : public Operation
{
public:
- WriteOperation (
+ WriteOperation(
lldb::addr_t addr,
const void *buff,
- lldb::addr_t size,
- lldb::addr_t &result) :
+ size_t size,
+ size_t &result) :
Operation (),
m_addr (addr),
m_buff (buff),
@@ -578,8 +578,8 @@ namespace
private:
lldb::addr_t m_addr;
const void *m_buff;
- lldb::addr_t m_size;
- lldb::addr_t &m_result;
+ size_t m_size;
+ size_t &m_result;
};
void
@@ -2825,7 +2825,7 @@ ReadMemoryCallback (EmulateInstruction *instruction,
{
EmulatorBaton* emulator_baton = static_cast<EmulatorBaton*>(baton);
- lldb::addr_t bytes_read;
+ size_t bytes_read;
emulator_baton->m_process->ReadMemory(addr, dst, length, bytes_read);
return bytes_read;
}
@@ -3472,10 +3472,7 @@ NativeProcessLinux::DoStopIDBumped (uint32_t newBumpId)
}
Error
-NativeProcessLinux::AllocateMemory (
- lldb::addr_t size,
- uint32_t permissions,
- lldb::addr_t &addr)
+NativeProcessLinux::AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr)
{
// FIXME implementing this requires the equivalent of
// InferiorCallPOSIX::InferiorCallMmap, which depends on
@@ -3837,7 +3834,7 @@ NativeProcessLinux::GetCrashReasonForSIGBUS(const siginfo_t *info)
#endif
Error
-NativeProcessLinux::ReadMemory (lldb::addr_t addr, void *buf, lldb::addr_t size, lldb::addr_t &bytes_read)
+NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read)
{
ReadOperation op(addr, buf, size, bytes_read);
m_monitor_up->DoOperation(&op);
@@ -3845,7 +3842,15 @@ NativeProcessLinux::ReadMemory (lldb::addr_t addr, void *buf, lldb::addr_t size,
}
Error
-NativeProcessLinux::WriteMemory (lldb::addr_t addr, const void *buf, lldb::addr_t size, lldb::addr_t &bytes_written)
+NativeProcessLinux::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read)
+{
+ Error error = ReadMemory(addr, buf, size, bytes_read);
+ if (error.Fail()) return error;
+ return m_breakpoint_list.RemoveTrapsFromBuffer(addr, buf, size);
+}
+
+Error
+NativeProcessLinux::WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written)
{
WriteOperation op(addr, buf, size, bytes_written);
m_monitor_up->DoOperation(&op);
@@ -4182,11 +4187,11 @@ NativeProcessLinux::FixupBreakpointPCAsNeeded (NativeThreadProtocolSP &thread_sp
// First try probing for a breakpoint at a software breakpoint location: PC - breakpoint size.
const lldb::addr_t initial_pc_addr = context_sp->GetPC ();
lldb::addr_t breakpoint_addr = initial_pc_addr;
- if (breakpoint_size > static_cast<lldb::addr_t> (0))
+ if (breakpoint_size > 0)
{
// Do not allow breakpoint probe to wrap around.
- if (breakpoint_addr >= static_cast<lldb::addr_t> (breakpoint_size))
- breakpoint_addr -= static_cast<lldb::addr_t> (breakpoint_size);
+ if (breakpoint_addr >= breakpoint_size)
+ breakpoint_addr -= breakpoint_size;
}
// Check if we stopped because of a breakpoint.
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
index 3f17fa1cd6e..5c1f712d9b4 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -84,13 +84,16 @@ namespace process_linux {
GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info) override;
Error
- ReadMemory (lldb::addr_t addr, void *buf, lldb::addr_t size, lldb::addr_t &bytes_read) override;
+ ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override;
Error
- WriteMemory (lldb::addr_t addr, const void *buf, lldb::addr_t size, lldb::addr_t &bytes_written) override;
+ ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override;
Error
- AllocateMemory (lldb::addr_t size, uint32_t permissions, lldb::addr_t &addr) override;
+ WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override;
+
+ Error
+ AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr) override;
Error
DeallocateMemory (lldb::addr_t addr) override;
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index d4bbb6f4972..47dc849e25b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1846,8 +1846,8 @@ GDBRemoteCommunicationServerLLGS::Handle_m (StringExtractorGDBRemote &packet)
// Retrieve the process memory.
- lldb::addr_t bytes_read = 0;
- Error error = m_debugged_process_sp->ReadMemory (read_addr, &buf[0], byte_count, bytes_read);
+ size_t bytes_read = 0;
+ Error error = m_debugged_process_sp->ReadMemoryWithoutTrap(read_addr, &buf[0], byte_count, bytes_read);
if (error.Fail ())
{
if (log)
@@ -1863,7 +1863,7 @@ GDBRemoteCommunicationServerLLGS::Handle_m (StringExtractorGDBRemote &packet)
}
StreamGDBRemote response;
- for (lldb::addr_t i = 0; i < bytes_read; ++i)
+ for (size_t i = 0; i < bytes_read; ++i)
response.PutHex8(buf[i]);
return SendPacketNoLock(response.GetData(), response.GetSize());
@@ -1917,7 +1917,7 @@ GDBRemoteCommunicationServerLLGS::Handle_M (StringExtractorGDBRemote &packet)
// Convert the hex memory write contents to bytes.
StreamGDBRemote response;
- const uint64_t convert_count = static_cast<uint64_t> (packet.GetHexBytes (&buf[0], byte_count, 0));
+ const uint64_t convert_count = packet.GetHexBytes(&buf[0], byte_count, 0);
if (convert_count != byte_count)
{
if (log)
@@ -1926,7 +1926,7 @@ GDBRemoteCommunicationServerLLGS::Handle_M (StringExtractorGDBRemote &packet)
}
// Write the process memory.
- lldb::addr_t bytes_written = 0;
+ size_t bytes_written = 0;
Error error = m_debugged_process_sp->WriteMemory (write_addr, &buf[0], byte_count, bytes_written);
if (error.Fail ())
{
OpenPOWER on IntegriCloud