2013-12-07 06:57:16 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* Xenia : Xbox 360 Emulator Research Project *
|
|
|
|
******************************************************************************
|
|
|
|
* Copyright 2013 Ben Vanik. All rights reserved. *
|
|
|
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2015-03-24 15:25:58 +00:00
|
|
|
#ifndef XENIA_CPU_FUNCTION_H_
|
|
|
|
#define XENIA_CPU_FUNCTION_H_
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2014-07-14 05:28:00 +00:00
|
|
|
#include <memory>
|
2014-07-10 05:28:51 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <vector>
|
|
|
|
|
2015-03-24 15:25:58 +00:00
|
|
|
#include "xenia/cpu/debug_info.h"
|
|
|
|
#include "xenia/cpu/thread_state.h"
|
2015-05-05 03:57:46 +00:00
|
|
|
#include "xenia/debug/breakpoint.h"
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2015-03-24 14:46:18 +00:00
|
|
|
namespace xe {
|
|
|
|
namespace cpu {
|
2013-12-07 06:57:16 +00:00
|
|
|
|
|
|
|
class FunctionInfo;
|
|
|
|
|
|
|
|
class Function {
|
2014-07-11 03:20:00 +00:00
|
|
|
public:
|
2014-01-30 08:22:55 +00:00
|
|
|
Function(FunctionInfo* symbol_info);
|
2013-12-07 06:57:16 +00:00
|
|
|
virtual ~Function();
|
|
|
|
|
2015-03-25 02:41:29 +00:00
|
|
|
uint32_t address() const { return address_; }
|
2014-01-30 08:22:55 +00:00
|
|
|
FunctionInfo* symbol_info() const { return symbol_info_; }
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2014-07-14 05:28:00 +00:00
|
|
|
DebugInfo* debug_info() const { return debug_info_.get(); }
|
|
|
|
void set_debug_info(std::unique_ptr<DebugInfo> debug_info) {
|
|
|
|
debug_info_ = std::move(debug_info);
|
|
|
|
}
|
2013-12-22 17:25:44 +00:00
|
|
|
|
2015-05-05 03:57:46 +00:00
|
|
|
int AddBreakpoint(debug::Breakpoint* breakpoint);
|
|
|
|
int RemoveBreakpoint(debug::Breakpoint* breakpoint);
|
2013-12-23 06:03:06 +00:00
|
|
|
|
2015-03-25 02:41:29 +00:00
|
|
|
int Call(ThreadState* thread_state, uint32_t return_address);
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2014-07-11 03:20:00 +00:00
|
|
|
protected:
|
2015-05-05 03:57:46 +00:00
|
|
|
debug::Breakpoint* FindBreakpoint(uint32_t address);
|
|
|
|
virtual int AddBreakpointImpl(debug::Breakpoint* breakpoint) { return 0; }
|
|
|
|
virtual int RemoveBreakpointImpl(debug::Breakpoint* breakpoint) { return 0; }
|
2015-03-25 02:41:29 +00:00
|
|
|
virtual int CallImpl(ThreadState* thread_state, uint32_t return_address) = 0;
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2014-07-11 03:20:00 +00:00
|
|
|
protected:
|
2015-03-25 02:41:29 +00:00
|
|
|
uint32_t address_;
|
2014-01-30 08:22:55 +00:00
|
|
|
FunctionInfo* symbol_info_;
|
2014-07-14 05:28:00 +00:00
|
|
|
std::unique_ptr<DebugInfo> debug_info_;
|
2013-12-23 06:03:06 +00:00
|
|
|
|
|
|
|
// TODO(benvanik): move elsewhere? DebugData?
|
2014-07-10 05:28:51 +00:00
|
|
|
std::mutex lock_;
|
2015-05-05 03:57:46 +00:00
|
|
|
std::vector<debug::Breakpoint*> breakpoints_;
|
2013-12-07 06:57:16 +00:00
|
|
|
};
|
|
|
|
|
2015-03-24 14:46:18 +00:00
|
|
|
} // namespace cpu
|
|
|
|
} // namespace xe
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2015-03-24 15:25:58 +00:00
|
|
|
#endif // XENIA_CPU_FUNCTION_H_
|