[Lldb-commits] [lldb] r178035 - Remove FunctionProfiler and ProfileObjectiveC action classes as they are not used.
Greg Clayton
gclayton at apple.com
Tue Mar 26 09:47:22 PDT 2013
Author: gclayton
Date: Tue Mar 26 11:47:22 2013
New Revision: 178035
URL: http://llvm.org/viewvc/llvm-project?rev=178035&view=rev
Log:
Remove FunctionProfiler and ProfileObjectiveC action classes as they are not used.
Removed:
lldb/trunk/tools/debugserver/source/FunctionProfiler.cpp
lldb/trunk/tools/debugserver/source/FunctionProfiler.h
lldb/trunk/tools/debugserver/source/ProfileObjectiveC.cpp
lldb/trunk/tools/debugserver/source/ProfileObjectiveC.h
Modified:
lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=178035&r1=178034&r2=178035&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Mar 26 11:47:22 2013
@@ -65,8 +65,6 @@
2695DD9B0D3EC160007E4CA2 /* CFString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CFString.cpp; sourceTree = "<group>"; };
2695DE2D0D3EE55B007E4CA2 /* CFData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFData.h; sourceTree = "<group>"; };
2695DE2E0D3EE55B007E4CA2 /* CFData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CFData.cpp; sourceTree = "<group>"; };
- 269DE5C50CB5B723008989F0 /* ProfileObjectiveC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileObjectiveC.h; sourceTree = "<group>"; };
- 269DE5C60CB5B723008989F0 /* ProfileObjectiveC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProfileObjectiveC.cpp; sourceTree = "<group>"; };
269E8DF8164B2ED200AD65F6 /* com.apple.debugserver.posix.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.debugserver.posix.plist; sourceTree = "<group>"; };
26A02918114AB9240029C479 /* debugserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = debugserver.cpp; sourceTree = "<group>"; };
26A4BAED0D498B7D00A9BEAB /* com.apple.debugserver.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.debugserver.plist; sourceTree = "<group>"; };
@@ -77,8 +75,6 @@
26A68FD50D10574500665A9E /* RNBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNBRemote.h; sourceTree = "<group>"; };
26A68FD60D10574500665A9E /* RNBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RNBRemote.cpp; sourceTree = "<group>"; };
26A8FE1E0D11A77B00203048 /* DNBTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNBTimer.h; sourceTree = "<group>"; };
- 26A901EA0EA3F46B00F7C71E /* FunctionProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionProfiler.cpp; sourceTree = "<group>"; };
- 26A901EB0EA3F46B00F7C71E /* FunctionProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionProfiler.h; sourceTree = "<group>"; };
26ACA3340D3E956300A2120B /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
26B67DE00EE9BC30006C8BC0 /* MachTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachTask.h; sourceTree = "<group>"; };
26B67DE10EE9BC30006C8BC0 /* MachTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MachTask.cpp; sourceTree = "<group>"; };
@@ -235,17 +231,6 @@
name = libdebugnub;
sourceTree = "<group>";
};
- 26A02900114AB6DB0029C479 /* Utility */ = {
- isa = PBXGroup;
- children = (
- 26A901EB0EA3F46B00F7C71E /* FunctionProfiler.h */,
- 26A901EA0EA3F46B00F7C71E /* FunctionProfiler.cpp */,
- 269DE5C50CB5B723008989F0 /* ProfileObjectiveC.h */,
- 269DE5C60CB5B723008989F0 /* ProfileObjectiveC.cpp */,
- );
- name = Utility;
- sourceTree = "<group>";
- };
26ACA3330D3E94F200A2120B /* Framework */ = {
isa = PBXGroup;
children = (
@@ -268,7 +253,6 @@
26593A060D4931CC001C9FE3 /* ChangeLog */,
26DEFD6C0D104C23008A5A07 /* debugserver */,
26A028FF114AB6BB0029C479 /* libdebugnub */,
- 26A02900114AB6DB0029C479 /* Utility */,
);
indentWidth = 4;
path = source;
Removed: lldb/trunk/tools/debugserver/source/FunctionProfiler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/FunctionProfiler.cpp?rev=178034&view=auto
==============================================================================
--- lldb/trunk/tools/debugserver/source/FunctionProfiler.cpp (original)
+++ lldb/trunk/tools/debugserver/source/FunctionProfiler.cpp (removed)
@@ -1,288 +0,0 @@
-//===-- FunctionProfiler.cpp ------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 10/8/08.
-//
-//===----------------------------------------------------------------------===//
-
-#include "FunctionProfiler.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "DNB.h"
-
-// Project includes
-
-//----------------------------------------------------------------------
-// FunctionProfiler constructor
-//----------------------------------------------------------------------
-FunctionProfiler::FunctionProfiler(nub_addr_t start_addr, nub_addr_t stop_addr) :
- m_pid(INVALID_NUB_PROCESS),
- m_start_addr(start_addr),
- m_stop_addr(stop_addr),
- m_start_break_id(INVALID_NUB_BREAK_ID),
- m_stop_break_id(INVALID_NUB_BREAK_ID),
- m_func_entered_count(0),
- m_last_pc(0),
- m_last_flags(0),
- m_consecutive_opcode_count(0),
- m_total_opcode_count(0)
-{
-}
-
-
-FunctionProfiler::~FunctionProfiler()
-{
- Clear();
-}
-
-
-void
-FunctionProfiler::Clear()
-{
- if (m_pid != INVALID_NUB_PROCESS)
- {
- if (m_start_break_id != INVALID_NUB_BREAK_ID)
- DNBBreakpointClear(m_pid, m_start_break_id);
- if (m_stop_break_id != INVALID_NUB_BREAK_ID)
- DNBBreakpointClear(m_pid, m_stop_break_id);
- }
- m_start_break_id = INVALID_NUB_BREAK_ID;
- m_stop_break_id = INVALID_NUB_BREAK_ID;
- m_func_entered_count = 0;
- m_last_pc = 0;
- m_last_flags = 0;
- m_consecutive_opcode_count = 0;
-}
-
-void
-FunctionProfiler::Initialize(nub_process_t pid)
-{
- //printf("FunctionProfiler::%s(0x%4.4x)\n", __FUNCTION__, pid);
- Clear();
- m_pid = pid;
-}
-
-#include "DNBDataRef.h"
-
-void
-FunctionProfiler::SetBreakpoints()
-{
-#if defined (__i386__)
- nub_size_t bp_opcode_size = 1;
-#elif defined (__powerpc__) || defined (__ppc__)
- nub_size_t bp_opcode_size = 4;
-#endif
- if (m_start_addr != INVALID_NUB_ADDRESS && !NUB_BREAK_ID_IS_VALID(m_start_break_id))
- {
-#if defined (__arm__)
- m_start_break_id = DNBBreakpointSet(m_pid, m_start_addr & 0xFFFFFFFEu, m_start_addr & 1 ? 2 : 4, false);
-#else
- m_start_break_id = DNBBreakpointSet(m_pid, m_start_addr, bp_opcode_size, false);
-#endif
- if (NUB_BREAK_ID_IS_VALID(m_start_break_id))
- DNBBreakpointSetCallback(m_pid, m_start_break_id, FunctionProfiler::BreakpointHitCallback, this);
- }
- if (m_stop_addr != INVALID_NUB_ADDRESS && !NUB_BREAK_ID_IS_VALID(m_stop_break_id))
- {
-#if defined (__arm__)
- m_stop_break_id = DNBBreakpointSet(m_pid, m_stop_addr & 0xFFFFFFFEu, m_stop_addr & 1 ? 2 : 4, false);
-#else
- m_stop_break_id = DNBBreakpointSet(m_pid, m_stop_addr, bp_opcode_size, false);
-#endif
- if (NUB_BREAK_ID_IS_VALID(m_stop_break_id))
- DNBBreakpointSetCallback(m_pid, m_stop_break_id, FunctionProfiler::BreakpointHitCallback, this);
- }
-}
-
-nub_bool_t
-FunctionProfiler::BreakpointHitCallback(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton)
-{
- printf("FunctionProfiler::%s(pid = %4.4x, tid = %4.4x, breakID = %u, baton = %p)\n", __FUNCTION__, pid, tid, breakID, baton);
- return ((FunctionProfiler*) baton)->BreakpointHit(pid, tid, breakID);
-}
-
-nub_bool_t
-FunctionProfiler::BreakpointHit(nub_process_t pid, nub_thread_t tid, nub_break_t breakID)
-{
- printf("FunctionProfiler::%s(pid = %4.4x, tid = %4.4x, breakID = %u)\n", __FUNCTION__, pid, tid, breakID);
- if (breakID == m_start_break_id)
- {
- m_func_entered_count++;
- printf("FunctionProfiler::%s(pid = %4.4x, tid = %4.4x, breakID = %u) START breakpoint hit (%u)\n", __FUNCTION__, pid, tid, breakID, m_func_entered_count);
- }
- else if (breakID == m_stop_break_id)
- {
- if (m_func_entered_count > 0)
- m_func_entered_count--;
- printf("FunctionProfiler::%s(pid = %4.4x, tid = %4.4x, breakID = %u) STOP breakpoint hit (%u)\n", __FUNCTION__, pid, tid, breakID, m_func_entered_count);
- }
- return true;
-}
-
-void
-FunctionProfiler::ProcessStateChanged(nub_state_t state)
-{
-// printf("FunctionProfiler::%s(%s)\n", __FUNCTION__, DNBStateAsString(state));
-
- switch (state)
- {
- case eStateInvalid:
- case eStateUnloaded:
- case eStateAttaching:
- case eStateLaunching:
- break;
-
- case eStateDetached:
- case eStateExited:
- // No sense is clearing out breakpoints if our process has exited...
- m_start_break_id = INVALID_NUB_BREAK_ID;
- m_stop_break_id = INVALID_NUB_BREAK_ID;
- printf("[0x%8.8x - 0x%8.8x) executed %u total opcodes.\n", m_total_opcode_count);
- break;
-
- case eStateStopped:
- // Keep trying find dyld each time we stop until we do
- if (!NUB_BREAK_ID_IS_VALID(m_start_break_id))
- SetBreakpoints();
-
- if (ShouldStepProcess())
- {
-
- // TODO: do logging/tracing here
- nub_thread_t tid = DNBProcessGetCurrentThread(m_pid);
- DNBRegisterValue reg;
- m_total_opcode_count++;
-
- if (DNBThreadGetRegisterValueByID(m_pid, tid, REGISTER_SET_GENERIC, GENERIC_REGNUM_PC, ®))
- {
- const nub_addr_t pc = reg.value.uint32;
-
-#if defined (__i386__)
- uint8_t buf[16];
- uint32_t bytes_read = DNBProcessMemoryRead(m_pid, pc, 1, buf);
- if (bytes_read == 1)
- printf("0x%8.8x: %2.2x\n", pc, buf[0]);
- else
- printf("0x%8.8x: error: can't read opcode byte.\n", pc);
-
-// if (bytes_read > 0)
-// {
-// for (uint32_t i=0; i<bytes_read; ++i)
-// {
-// printf(" %2.2x", buf[i]);
-// }
-// }
-// printf("\n");
-
-#elif defined (__powerpc__) || defined (__ppc__)
-
- uint32_t opcode = 0;
- if (DNBProcessMemoryRead(m_pid, pc, 4, &opcode) == 4)
- {
- printf("0x%8.8x: 0x%8.8x\n", pc, opcode);
- }
-
-#elif defined (__arm__)
- #define CPSR_T (1u << 5)
- // Read the CPSR into flags
- if (DNBThreadGetRegisterValueByID(m_pid, tid, REGISTER_SET_GENERIC, GENERIC_REGNUM_FLAGS, ®))
- {
- const uint32_t flags = reg.value.uint32;
-
- const bool curr_pc_is_thumb = (flags & CPSR_T) != 0; // check the CPSR T bit
- const bool last_pc_was_thumb = (m_last_flags & CPSR_T) != 0; // check the CPSR T bit
- bool opcode_is_sequential = false;
-
- uint32_t opcode;
- // Always read four bytes for the opcode
- if (DNBProcessMemoryRead(m_pid, pc, 4, &opcode) == 4)
- {
- if (curr_pc_is_thumb)
- {
- // Trim off the high 16 bits if this is a 16 bit thumb instruction
- if ((opcode & 0xe000) != 0xe000 || (opcode & 0x1800) == 0)
- {
- opcode &= 0xFFFFu;
- printf("0x%8.8x: %4.4x Thumb\n", pc, opcode);
- }
- else
- printf("0x%8.8x: %8.8x Thumb\n", pc, opcode);
- }
- else
- printf("0x%8.8x: %8.8x ARM\n", pc, opcode);
- }
-
- if (m_last_flags != 0 && curr_pc_is_thumb == last_pc_was_thumb)
- {
- if (curr_pc_is_thumb)
- {
- if (pc == m_last_pc + 2)
- {
- opcode_is_sequential = true;
- }
- else if (pc == m_last_pc + 4)
- {
- // Check for 32 bit thumb instruction...
- uint16_t opcode16;
- if (DNBProcessMemoryRead(m_pid, m_last_pc, 2, &opcode16) == 2)
- {
- if ((opcode16 & 0xe000) == 0xe000 && (opcode16 & 0x1800) != 0)
- {
- // Last opcode was a 32 bit thumb instruction...
- opcode_is_sequential = true;
- }
- }
- }
- }
- else
- {
- if (pc == m_last_pc + 4)
- {
- opcode_is_sequential = true;
- }
- }
- }
-
-
- if (opcode_is_sequential)
- {
- m_consecutive_opcode_count++;
- }
- else
- {
- if (m_consecutive_opcode_count > 0)
- {
- // printf(" x %u\n", m_consecutive_opcode_count);
- }
- m_consecutive_opcode_count = 1;
- //printf("0x%8.8x: %-5s", pc, curr_pc_is_thumb ? "Thumb" : "ARM");
- //fflush(stdout);
- }
- m_last_flags = flags;
- }
-#else
-#error undefined architecture
-#endif
- m_last_pc = pc;
- }
- }
- break;
-
- case eStateRunning:
- case eStateStepping:
- case eStateCrashed:
- case eStateSuspended:
- break;
-
- default:
- break;
- }
-}
Removed: lldb/trunk/tools/debugserver/source/FunctionProfiler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/FunctionProfiler.h?rev=178034&view=auto
==============================================================================
--- lldb/trunk/tools/debugserver/source/FunctionProfiler.h (original)
+++ lldb/trunk/tools/debugserver/source/FunctionProfiler.h (removed)
@@ -1,70 +0,0 @@
-//===-- FunctionProfiler.h --------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 10/8/08.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __FunctionProfiler_h__
-#define __FunctionProfiler_h__
-
-// C Includes
-
-// C++ Includes
-#include <map>
-#include <vector>
-#include <string>
-
-// Other libraries and framework includes
-
-// Project includes
-#include "DNBDefs.h"
-#include "DNBRuntimeAction.h"
-#include "PThreadMutex.h"
-
-class DNBBreakpoint;
-class MachProcess;
-
-class FunctionProfiler : public DNBRuntimeAction
-{
-public:
- FunctionProfiler (nub_addr_t start_addr, nub_addr_t stop_addr);
- virtual ~FunctionProfiler ();
-
- //------------------------------------------------------------------
- // DNBRuntimeAction required functions
- //------------------------------------------------------------------
- virtual void Initialize(nub_process_t pid);
- virtual void ProcessStateChanged(nub_state_t state);
- virtual void SharedLibraryStateChanged(DNBExecutableImageInfo *image_infos, nub_size_t num_image_infos) {}
-
- nub_bool_t BreakpointHit(nub_process_t pid, nub_thread_t tid, nub_break_t breakID);
- bool ShouldStepProcess() const
- {
- return m_func_entered_count > 0;
- }
-protected:
- static nub_bool_t BreakpointHitCallback (nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton);
- void Clear();
- void SetBreakpoints();
-
- nub_process_t m_pid;
- nub_addr_t m_start_addr;
- nub_addr_t m_stop_addr;
- nub_break_t m_start_break_id;
- nub_break_t m_stop_break_id;
- uint32_t m_func_entered_count;
- nub_addr_t m_last_pc;
- uint32_t m_last_flags;
- uint32_t m_consecutive_opcode_count;
- uint32_t m_total_opcode_count;
-};
-
-
-#endif // __FunctionProfiler_h__
Removed: lldb/trunk/tools/debugserver/source/ProfileObjectiveC.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/ProfileObjectiveC.cpp?rev=178034&view=auto
==============================================================================
--- lldb/trunk/tools/debugserver/source/ProfileObjectiveC.cpp (original)
+++ lldb/trunk/tools/debugserver/source/ProfileObjectiveC.cpp (removed)
@@ -1,393 +0,0 @@
-//===-- ProfileObjectiveC.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 10/4/07.
-//
-//===----------------------------------------------------------------------===//
-
-#include "ProfileObjectiveC.h"
-#include "DNB.h"
-#include <objc/objc-runtime.h>
-#include <map>
-
-#if defined (__powerpc__) || defined (__ppc__)
-#define OBJC_MSG_SEND_PPC32_COMM_PAGE_ADDR ((nub_addr_t)0xfffeff00)
-#endif
-
-//----------------------------------------------------------------------
-// Constructor
-//----------------------------------------------------------------------
-ProfileObjectiveC::ProfileObjectiveC() :
- m_pid(INVALID_NUB_PROCESS),
- m_objcStats(),
- m_hit_count(0),
- m_dump_count(0xffff)
-{
- memset(&m_begin_time, 0, sizeof(m_begin_time));
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-ProfileObjectiveC::~ProfileObjectiveC()
-{
-}
-
-//----------------------------------------------------------------------
-// Clear any counts that we may have had
-//----------------------------------------------------------------------
-void
-ProfileObjectiveC::Clear()
-{
- if (m_pid != INVALID_NUB_PROCESS)
- {
- DNBBreakpointClear(m_pid, m_objc_msgSend.breakID);
- DNBBreakpointClear(m_pid, m_objc_msgSendSuper.breakID);
-#if defined (__powerpc__) || defined (__ppc__)
- DNBBreakpointClear(m_pid, m_objc_msgSend_rtp.breakID);
-#endif
- }
- m_objc_msgSend.Clear();
- m_objc_msgSendSuper.Clear();
-#if defined (__powerpc__) || defined (__ppc__)
- memset(m_objc_msgSend_opcode, 0, k_opcode_size);
- m_objc_msgSend_rtp.Clear();
-#endif
- memset(&m_begin_time, 0, sizeof(m_begin_time));
- m_objcStats.clear();
-}
-
-void
-ProfileObjectiveC::Initialize(nub_process_t pid)
-{
- Clear();
- m_pid = pid;
-}
-
-
-void
-ProfileObjectiveC::ProcessStateChanged(nub_state_t state)
-{
- //printf("ProfileObjectiveC::%s(%s)\n", __FUNCTION__, DNBStateAsString(state));
- switch (state)
- {
- case eStateInvalid:
- case eStateUnloaded:
- case eStateExited:
- case eStateDetached:
- Clear();
- break;
-
- case eStateStopped:
-#if defined (__powerpc__) || defined (__ppc__)
- if (NUB_BREAK_ID_IS_VALID(m_objc_msgSend.breakID) && !NUB_BREAK_ID_IS_VALID(m_objc_msgSend_rtp.breakID))
- {
- nub_thread_t tid = DNBProcessGetCurrentThread(m_pid);
- DNBRegisterValue pc_value;
- if (DNBThreadGetRegisterValueByName(m_pid, tid, REGISTER_SET_ALL, "srr0" , &pc_value))
- {
- nub_addr_t pc = pc_value.value.uint32;
- if (pc == OBJC_MSG_SEND_PPC32_COMM_PAGE_ADDR)
- {
- // Restore previous first instruction to 0xfffeff00 in comm page
- DNBProcessMemoryWrite(m_pid, OBJC_MSG_SEND_PPC32_COMM_PAGE_ADDR, k_opcode_size, m_objc_msgSend_opcode);
- //printf("Setting breakpoint on _objc_msgSend_rtp...\n");
- m_objc_msgSend_rtp.breakID = DNBBreakpointSet(m_pid, OBJC_MSG_SEND_PPC32_COMM_PAGE_ADDR);
- if (NUB_BREAK_ID_IS_VALID(m_objc_msgSend_rtp.breakID))
- {
- DNBBreakpointSetCallback(m_pid, m_objc_msgSend_rtp.breakID, ProfileObjectiveC::MessageSendBreakpointCallback, this);
- }
- }
- }
- }
-#endif
- DumpStats(m_pid, stdout);
- break;
-
- case eStateAttaching:
- case eStateLaunching:
- case eStateRunning:
- case eStateStepping:
- case eStateCrashed:
- case eStateSuspended:
- break;
-
- default:
- break;
- }
-}
-
-void
-ProfileObjectiveC::SharedLibraryStateChanged(DNBExecutableImageInfo *image_infos, nub_size_t num_image_infos)
-{
- //printf("ProfileObjectiveC::%s(%p, %u)\n", __FUNCTION__, image_infos, num_image_infos);
- if (m_objc_msgSend.IsValid() && m_objc_msgSendSuper.IsValid())
- return;
-
- if (image_infos)
- {
- nub_process_t pid = m_pid;
- nub_size_t i;
- for (i = 0; i < num_image_infos; i++)
- {
- if (strcmp(image_infos[i].name, "/usr/lib/libobjc.A.dylib") == 0)
- {
- if (!NUB_BREAK_ID_IS_VALID(m_objc_msgSend.breakID))
- {
- m_objc_msgSend.addr = DNBProcessLookupAddress(pid, "_objc_msgSend", image_infos[i].name);
-
- if (m_objc_msgSend.addr != INVALID_NUB_ADDRESS)
- {
-#if defined (__powerpc__) || defined (__ppc__)
- if (DNBProcessMemoryRead(pid, m_objc_msgSend.addr, k_opcode_size, m_objc_msgSend_opcode) != k_opcode_size)
- memset(m_objc_msgSend_opcode, 0, sizeof(m_objc_msgSend_opcode));
-#endif
- m_objc_msgSend.breakID = DNBBreakpointSet(pid, m_objc_msgSend.addr, 4, false);
- if (NUB_BREAK_ID_IS_VALID(m_objc_msgSend.breakID))
- DNBBreakpointSetCallback(pid, m_objc_msgSend.breakID, ProfileObjectiveC::MessageSendBreakpointCallback, this);
- }
- }
-
- if (!NUB_BREAK_ID_IS_VALID(m_objc_msgSendSuper.breakID))
- {
- m_objc_msgSendSuper.addr = DNBProcessLookupAddress(pid, "_objc_msgSendSuper", image_infos[i].name);
-
- if (m_objc_msgSendSuper.addr != INVALID_NUB_ADDRESS)
- {
- m_objc_msgSendSuper.breakID = DNBBreakpointSet(pid, m_objc_msgSendSuper.addr, 4, false);
- if (NUB_BREAK_ID_IS_VALID(m_objc_msgSendSuper.breakID))
- DNBBreakpointSetCallback(pid, m_objc_msgSendSuper.breakID, ProfileObjectiveC::MessageSendSuperBreakpointCallback, this);
- }
- }
- break;
- }
- }
- }
-}
-
-
-void
-ProfileObjectiveC::SetStartTime()
-{
- gettimeofday(&m_begin_time, NULL);
-}
-
-void
-ProfileObjectiveC::SelectorHit(objc_class_ptr_t isa, objc_selector_t sel)
-{
- m_objcStats[isa][sel]++;
-}
-
-nub_bool_t
-ProfileObjectiveC::MessageSendBreakpointCallback(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *userData)
-{
- ProfileObjectiveC *profile_objc = (ProfileObjectiveC*)userData;
- uint32_t hit_count = profile_objc->IncrementHitCount();
- if (hit_count == 1)
- profile_objc->SetStartTime();
-
- objc_class_ptr_t objc_self = 0;
- objc_selector_t objc_selector = 0;
-#if defined (__i386__)
- DNBRegisterValue esp;
- if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "esp", &esp))
- {
- uint32_t uval32[2];
- if (DNBProcessMemoryRead(pid, esp.value.uint32 + 4, 8, &uval32) == 8)
- {
- objc_self = uval32[0];
- objc_selector = uval32[1];
- }
- }
-#elif defined (__powerpc__) || defined (__ppc__)
- DNBRegisterValue r3;
- DNBRegisterValue r4;
- if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r3", &r3) &&
- DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r4", &r4))
- {
- objc_self = r3.value.uint32;
- objc_selector = r4.value.uint32;
- }
-#elif defined (__arm__)
- DNBRegisterValue r0;
- DNBRegisterValue r1;
- if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r0", &r0) &&
- DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r1", &r1))
- {
- objc_self = r0.value.uint32;
- objc_selector = r1.value.uint32;
- }
-#else
-#error undefined architecture
-#endif
- if (objc_selector != 0)
- {
- uint32_t isa = 0;
- if (objc_self == 0)
- {
- profile_objc->SelectorHit(0, objc_selector);
- }
- else
- if (DNBProcessMemoryRead(pid, (nub_addr_t)objc_self, sizeof(isa), &isa) == sizeof(isa))
- {
- if (isa)
- {
- profile_objc->SelectorHit(isa, objc_selector);
- }
- else
- {
- profile_objc->SelectorHit(0, objc_selector);
- }
- }
- }
-
-
- // Dump stats if we are supposed to
- if (profile_objc->ShouldDumpStats())
- {
- profile_objc->DumpStats(pid, stdout);
- return true;
- }
-
- // Just let the target run again by returning false;
- return false;
-}
-
-nub_bool_t
-ProfileObjectiveC::MessageSendSuperBreakpointCallback(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *userData)
-{
- ProfileObjectiveC *profile_objc = (ProfileObjectiveC*)userData;
-
- uint32_t hit_count = profile_objc->IncrementHitCount();
- if (hit_count == 1)
- profile_objc->SetStartTime();
-
-// printf("BreakID %u hit count is = %u\n", breakID, hc);
- objc_class_ptr_t objc_super = 0;
- objc_selector_t objc_selector = 0;
-#if defined (__i386__)
- DNBRegisterValue esp;
- if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "esp", &esp))
- {
- uint32_t uval32[2];
- if (DNBProcessMemoryRead(pid, esp.value.uint32 + 4, 8, &uval32) == 8)
- {
- objc_super = uval32[0];
- objc_selector = uval32[1];
- }
- }
-#elif defined (__powerpc__) || defined (__ppc__)
- DNBRegisterValue r3;
- DNBRegisterValue r4;
- if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r3", &r3) &&
- DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r4", &r4))
- {
- objc_super = r3.value.uint32;
- objc_selector = r4.value.uint32;
- }
-#elif defined (__arm__)
- DNBRegisterValue r0;
- DNBRegisterValue r1;
- if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r0", &r0) &&
- DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, "r1", &r1))
- {
- objc_super = r0.value.uint32;
- objc_selector = r1.value.uint32;
- }
-#else
-#error undefined architecture
-#endif
- if (objc_selector != 0)
- {
- uint32_t isa = 0;
- if (objc_super == 0)
- {
- profile_objc->SelectorHit(0, objc_selector);
- }
- else
- if (DNBProcessMemoryRead(pid, (nub_addr_t)objc_super + 4, sizeof(isa), &isa) == sizeof(isa))
- {
- if (isa)
- {
- profile_objc->SelectorHit(isa, objc_selector);
- }
- else
- {
- profile_objc->SelectorHit(0, objc_selector);
- }
- }
- }
-
- // Dump stats if we are supposed to
- if (profile_objc->ShouldDumpStats())
- {
- profile_objc->DumpStats(pid, stdout);
- return true;
- }
-
- // Just let the target run again by returning false;
- return false;
-}
-
-void
-ProfileObjectiveC::DumpStats(nub_process_t pid, FILE *f)
-{
- if (f == NULL)
- return;
-
- if (m_hit_count == 0)
- return;
-
- ClassStatsMap::iterator class_pos;
- ClassStatsMap::iterator class_end = m_objcStats.end();
-
- struct timeval end_time;
- gettimeofday(&end_time, NULL);
- int64_t elapsed_usec = ((int64_t)(1000*1000))*((int64_t)end_time.tv_sec - (int64_t)m_begin_time.tv_sec) + ((int64_t)end_time.tv_usec - (int64_t)m_begin_time.tv_usec);
- fprintf(f, "%u probe hits for %.2f hits/sec)\n", m_hit_count, (double)m_hit_count / (((double)elapsed_usec)/(1000000.0)));
-
- for (class_pos = m_objcStats.begin(); class_pos != class_end; ++class_pos)
- {
- SelectorHitCount::iterator sel_pos;
- SelectorHitCount::iterator sel_end = class_pos->second.end();
- for (sel_pos = class_pos->second.begin(); sel_pos != sel_end; ++sel_pos)
- {
- struct objc_class objc_class;
- uint32_t isa = class_pos->first;
- uint32_t sel = sel_pos->first;
- uint32_t sel_hit_count = sel_pos->second;
-
- if (isa != 0 && DNBProcessMemoryRead(pid, isa, sizeof(objc_class), &objc_class) == sizeof(objc_class))
- {
- /* fprintf(f, "%#.8x\n isa = %p\n super_class = %p\n name = %p\n version = %lx\n info = %lx\ninstance_size = %lx\n ivars = %p\n methodLists = %p\n cache = %p\n protocols = %p\n",
- arg1.value.pointer,
- objc_class.isa,
- objc_class.super_class,
- objc_class.name,
- objc_class.version,
- objc_class.info,
- objc_class.instance_size,
- objc_class.ivars,
- objc_class.methodLists,
- objc_class.cache,
- objc_class.protocols); */
-
- // Print the class name
- fprintf(f, "%6u hits for %c[", sel_hit_count, (objc_class.super_class == objc_class.isa ? '+' : '-'));
- DNBPrintf(pid, INVALID_NUB_THREAD, (nub_addr_t)objc_class.name, f, "%s ");
- }
- else
- {
- fprintf(f, "%6u hits for [<nil> ", sel_hit_count);
- }
- DNBPrintf(pid, INVALID_NUB_THREAD, sel, f, "%s]\n");
- }
- }
-}
-
Removed: lldb/trunk/tools/debugserver/source/ProfileObjectiveC.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/ProfileObjectiveC.h?rev=178034&view=auto
==============================================================================
--- lldb/trunk/tools/debugserver/source/ProfileObjectiveC.h (original)
+++ lldb/trunk/tools/debugserver/source/ProfileObjectiveC.h (removed)
@@ -1,82 +0,0 @@
-//===-- ProfileObjectiveC.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 10/4/07.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __ProfileObjectiveC_h__
-#define __ProfileObjectiveC_h__
-
-#include "DNB.h"
-#include "DNBRuntimeAction.h"
-#include <map>
-#include <sys/time.h>
-
-class ProfileObjectiveC : public DNBRuntimeAction
-{
-public:
- ProfileObjectiveC();
- virtual ~ProfileObjectiveC();
- //------------------------------------------------------------------
- // DNBRuntimeAction required functions
- //------------------------------------------------------------------
- virtual void Initialize(nub_process_t pid);
- virtual void ProcessStateChanged(nub_state_t state);
- virtual void SharedLibraryStateChanged(DNBExecutableImageInfo *image_infos, nub_size_t num_image_infos);
-
-protected:
- typedef uint32_t objc_selector_t;
- typedef uint32_t objc_class_ptr_t;
- void Clear();
- static nub_bool_t MessageSendBreakpointCallback(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *userData);
- static nub_bool_t MessageSendSuperBreakpointCallback(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *userData);
- void DumpStats(nub_process_t pid, FILE *f);
- void SetStartTime();
- void SelectorHit(objc_class_ptr_t isa, objc_selector_t sel);
- typedef std::map<objc_selector_t, uint32_t> SelectorHitCount;
- typedef std::map<objc_class_ptr_t, SelectorHitCount> ClassStatsMap;
- typedef struct Probe
- {
- nub_addr_t addr;
- nub_break_t breakID;
- Probe() : addr(INVALID_NUB_ADDRESS), breakID(INVALID_NUB_BREAK_ID) {}
- void Clear()
- {
- addr = INVALID_NUB_ADDRESS;
- breakID = INVALID_NUB_BREAK_ID;
- }
- bool IsValid() const
- {
- return (addr != INVALID_NUB_ADDRESS) && (NUB_BREAK_ID_IS_VALID(breakID));
- }
- };
-
- uint32_t IncrementHitCount() { return ++m_hit_count; }
- bool ShouldDumpStats() const { return m_dump_count && (m_hit_count % m_dump_count) == 0; }
-
- nub_process_t m_pid;
- Probe m_objc_msgSend;
- Probe m_objc_msgSendSuper;
- uint32_t m_hit_count; // Number of times we have gotten one of our breakpoints hit
- uint32_t m_dump_count; // Dump stats every time the hit count reaches a multiple of this value
-#if defined (__powerpc__) || defined (__ppc__)
- enum
- {
- k_opcode_size = 4
- };
- uint8_t m_objc_msgSend_opcode[k_opcode_size]; // Saved copy of first opcode in objc_msgSend
- Probe m_objc_msgSend_rtp; // COMM page probe info for objc_msgSend
-#endif
- struct timeval m_begin_time;
- ClassStatsMap m_objcStats;
-};
-
-
-#endif // #ifndef __ProfileObjectiveC_h__
More information about the lldb-commits
mailing list