| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#include "gdb-tests.h" |
| 8 |
|
| 9 |
#include "vm/Stack.h" |
| 10 |
|
| 11 |
namespace js { |
| 12 |
|
| 13 |
void GDBTestInitInterpreterRegs(InterpreterRegs& regs, |
| 14 |
js::InterpreterFrame* fp_, JS::Value* sp, |
| 15 |
uint8_t* pc) { |
| 16 |
regs.fp_ = fp_; |
| 17 |
regs.sp = sp; |
| 18 |
regs.pc = pc; |
| 19 |
} |
| 20 |
|
| 21 |
void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame, |
| 22 |
InterpreterFrame* ptr) { |
| 23 |
MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0); |
| 24 |
frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_InterpreterFrame; |
| 25 |
} |
| 26 |
|
| 27 |
void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame, |
| 28 |
jit::BaselineFrame* ptr) { |
| 29 |
MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0); |
| 30 |
frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_BaselineFrame; |
| 31 |
} |
| 32 |
|
| 33 |
void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame, |
| 34 |
jit::RematerializedFrame* ptr) { |
| 35 |
MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0); |
| 36 |
frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_RematerializedFrame; |
| 37 |
} |
| 38 |
|
| 39 |
void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame, |
| 40 |
wasm::DebugFrame* ptr) { |
| 41 |
MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0); |
| 42 |
frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_WasmDebugFrame; |
| 43 |
} |
| 44 |
|
| 45 |
} // namespace js |
| 46 |
|
| 47 |
FRAGMENT(Interpreter, Regs) { |
| 48 |
struct FakeFrame { |
| 49 |
js::InterpreterFrame frame; |
| 50 |
JS::Value slot0; |
| 51 |
JS::Value slot1; |
| 52 |
JS::Value slot2; |
| 53 |
} fakeFrame; |
| 54 |
uint8_t fakeOpcode = uint8_t(JSOp::True); |
| 55 |
|
| 56 |
js::InterpreterRegs regs; |
| 57 |
js::GDBTestInitInterpreterRegs(regs, &fakeFrame.frame, &fakeFrame.slot2, |
| 58 |
&fakeOpcode); |
| 59 |
|
| 60 |
breakpoint(); |
| 61 |
|
| 62 |
use(regs); |
| 63 |
} |
| 64 |
|
| 65 |
FRAGMENT(Interpreter, AbstractFramePtr) { |
| 66 |
js::AbstractFramePtr ifptr; |
| 67 |
GDBTestInitAbstractFramePtr(ifptr, |
| 68 |
(js::InterpreterFrame*)uintptr_t(0x8badf00)); |
| 69 |
|
| 70 |
js::AbstractFramePtr bfptr; |
| 71 |
GDBTestInitAbstractFramePtr(bfptr, |
| 72 |
(js::jit::BaselineFrame*)uintptr_t(0xbadcafe0)); |
| 73 |
|
| 74 |
js::AbstractFramePtr rfptr; |
| 75 |
GDBTestInitAbstractFramePtr( |
| 76 |
rfptr, (js::jit::RematerializedFrame*)uintptr_t(0xdabbad00)); |
| 77 |
|
| 78 |
js::AbstractFramePtr sfptr; |
| 79 |
GDBTestInitAbstractFramePtr(sfptr, |
| 80 |
(js::wasm::DebugFrame*)uintptr_t(0xcb98ad00)); |
| 81 |
|
| 82 |
breakpoint(); |
| 83 |
|
| 84 |
use(ifptr); |
| 85 |
use(bfptr); |
| 86 |
use(rfptr); |
| 87 |
use(sfptr); |
| 88 |
} |