1 // Copyright 2020 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "tools/v8windbg/test/debug-callbacks.h"
6
7 namespace v8 {
8 namespace internal {
9 namespace v8windbg_test {
10
MyOutput(WRL::ComPtr<IDebugClient5> p_client)11 MyOutput::MyOutput(WRL::ComPtr<IDebugClient5> p_client) : p_client_(p_client) {
12 p_client_->SetOutputCallbacks(this);
13 }
14
~MyOutput()15 MyOutput::~MyOutput() { p_client_->SetOutputCallbacks(nullptr); }
16
QueryInterface(REFIID InterfaceId,PVOID * Interface)17 HRESULT __stdcall MyOutput::QueryInterface(REFIID InterfaceId,
18 PVOID* Interface) {
19 return E_NOTIMPL;
20 }
AddRef(void)21 ULONG __stdcall MyOutput::AddRef(void) { return 0; }
Release(void)22 ULONG __stdcall MyOutput::Release(void) { return 0; }
Output(ULONG Mask,PCSTR Text)23 HRESULT __stdcall MyOutput::Output(ULONG Mask, PCSTR Text) {
24 if (Mask & DEBUG_OUTPUT_NORMAL) {
25 log_ += Text;
26 }
27 return S_OK;
28 }
29
QueryInterface(REFIID InterfaceId,PVOID * Interface)30 HRESULT __stdcall MyCallback::QueryInterface(REFIID InterfaceId,
31 PVOID* Interface) {
32 return E_NOTIMPL;
33 }
AddRef(void)34 ULONG __stdcall MyCallback::AddRef(void) { return S_OK; }
Release(void)35 ULONG __stdcall MyCallback::Release(void) { return S_OK; }
GetInterestMask(PULONG Mask)36 HRESULT __stdcall MyCallback::GetInterestMask(PULONG Mask) {
37 *Mask = DEBUG_EVENT_BREAKPOINT | DEBUG_EVENT_CREATE_PROCESS;
38 return S_OK;
39 }
Breakpoint(PDEBUG_BREAKPOINT Bp)40 HRESULT __stdcall MyCallback::Breakpoint(PDEBUG_BREAKPOINT Bp) {
41 ULONG64 bp_offset;
42 HRESULT hr = Bp->GetOffset(&bp_offset);
43 if (FAILED(hr)) return hr;
44
45 // Break on breakpoints? Seems reasonable.
46 return DEBUG_STATUS_BREAK;
47 }
Exception(PEXCEPTION_RECORD64 Exception,ULONG FirstChance)48 HRESULT __stdcall MyCallback::Exception(PEXCEPTION_RECORD64 Exception,
49 ULONG FirstChance) {
50 return E_NOTIMPL;
51 }
CreateThread(ULONG64 Handle,ULONG64 DataOffset,ULONG64 StartOffset)52 HRESULT __stdcall MyCallback::CreateThread(ULONG64 Handle, ULONG64 DataOffset,
53 ULONG64 StartOffset) {
54 return E_NOTIMPL;
55 }
ExitThread(ULONG ExitCode)56 HRESULT __stdcall MyCallback::ExitThread(ULONG ExitCode) { return E_NOTIMPL; }
ExitProcess(ULONG ExitCode)57 HRESULT __stdcall MyCallback::ExitProcess(ULONG ExitCode) { return E_NOTIMPL; }
LoadModule(ULONG64 ImageFileHandle,ULONG64 BaseOffset,ULONG ModuleSize,PCSTR ModuleName,PCSTR ImageName,ULONG CheckSum,ULONG TimeDateStamp)58 HRESULT __stdcall MyCallback::LoadModule(ULONG64 ImageFileHandle,
59 ULONG64 BaseOffset, ULONG ModuleSize,
60 PCSTR ModuleName, PCSTR ImageName,
61 ULONG CheckSum, ULONG TimeDateStamp) {
62 return E_NOTIMPL;
63 }
UnloadModule(PCSTR ImageBaseName,ULONG64 BaseOffset)64 HRESULT __stdcall MyCallback::UnloadModule(PCSTR ImageBaseName,
65 ULONG64 BaseOffset) {
66 return E_NOTIMPL;
67 }
SystemError(ULONG Error,ULONG Level)68 HRESULT __stdcall MyCallback::SystemError(ULONG Error, ULONG Level) {
69 return E_NOTIMPL;
70 }
SessionStatus(ULONG Status)71 HRESULT __stdcall MyCallback::SessionStatus(ULONG Status) { return E_NOTIMPL; }
ChangeDebuggeeState(ULONG Flags,ULONG64 Argument)72 HRESULT __stdcall MyCallback::ChangeDebuggeeState(ULONG Flags,
73 ULONG64 Argument) {
74 return E_NOTIMPL;
75 }
ChangeEngineState(ULONG Flags,ULONG64 Argument)76 HRESULT __stdcall MyCallback::ChangeEngineState(ULONG Flags, ULONG64 Argument) {
77 return E_NOTIMPL;
78 }
ChangeSymbolState(ULONG Flags,ULONG64 Argument)79 HRESULT __stdcall MyCallback::ChangeSymbolState(ULONG Flags, ULONG64 Argument) {
80 return E_NOTIMPL;
81 }
CreateProcessW(ULONG64 ImageFileHandle,ULONG64 Handle,ULONG64 BaseOffset,ULONG ModuleSize,PCSTR ModuleName,PCSTR ImageName,ULONG CheckSum,ULONG TimeDateStamp,ULONG64 InitialThreadHandle,ULONG64 ThreadDataOffset,ULONG64 StartOffset)82 HRESULT __stdcall MyCallback::CreateProcessW(
83 ULONG64 ImageFileHandle, ULONG64 Handle, ULONG64 BaseOffset,
84 ULONG ModuleSize, PCSTR ModuleName, PCSTR ImageName, ULONG CheckSum,
85 ULONG TimeDateStamp, ULONG64 InitialThreadHandle, ULONG64 ThreadDataOffset,
86 ULONG64 StartOffset) {
87 // Should fire once the target process is launched. Break to create
88 // breakpoints, etc.
89 return DEBUG_STATUS_BREAK;
90 }
91
92 } // namespace v8windbg_test
93 } // namespace internal
94 } // namespace v8
95