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 #include "jsapi.h"
9
10 #include "vm/Stack.h"
11
12 namespace js {
13
GDBTestInitInterpreterRegs(InterpreterRegs & regs,js::InterpreterFrame * fp_,JS::Value * sp,uint8_t * pc)14 void GDBTestInitInterpreterRegs(InterpreterRegs& regs,
15 js::InterpreterFrame* fp_, JS::Value* sp,
16 uint8_t* pc) {
17 regs.fp_ = fp_;
18 regs.sp = sp;
19 regs.pc = pc;
20 }
21
GDBTestInitAbstractFramePtr(AbstractFramePtr & frame,InterpreterFrame * ptr)22 void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame,
23 InterpreterFrame* ptr) {
24 MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0);
25 frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_InterpreterFrame;
26 }
27
GDBTestInitAbstractFramePtr(AbstractFramePtr & frame,jit::BaselineFrame * ptr)28 void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame,
29 jit::BaselineFrame* ptr) {
30 MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0);
31 frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_BaselineFrame;
32 }
33
GDBTestInitAbstractFramePtr(AbstractFramePtr & frame,jit::RematerializedFrame * ptr)34 void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame,
35 jit::RematerializedFrame* ptr) {
36 MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0);
37 frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_RematerializedFrame;
38 }
39
GDBTestInitAbstractFramePtr(AbstractFramePtr & frame,wasm::DebugFrame * ptr)40 void GDBTestInitAbstractFramePtr(AbstractFramePtr& frame,
41 wasm::DebugFrame* ptr) {
42 MOZ_ASSERT((uintptr_t(ptr) & AbstractFramePtr::TagMask) == 0);
43 frame.ptr_ = uintptr_t(ptr) | AbstractFramePtr::Tag_WasmDebugFrame;
44 }
45
46 } // namespace js
47
FRAGMENT(Interpreter,Regs)48 FRAGMENT(Interpreter, Regs) {
49 struct FakeFrame {
50 js::InterpreterFrame frame;
51 JS::Value slot0;
52 JS::Value slot1;
53 JS::Value slot2;
54 } fakeFrame;
55 uint8_t fakeOpcode = uint8_t(JSOp::True);
56
57 js::InterpreterRegs regs;
58 js::GDBTestInitInterpreterRegs(regs, &fakeFrame.frame, &fakeFrame.slot2,
59 &fakeOpcode);
60
61 breakpoint();
62
63 use(regs);
64 }
65
FRAGMENT(Interpreter,AbstractFramePtr)66 FRAGMENT(Interpreter, AbstractFramePtr) {
67 js::AbstractFramePtr ifptr;
68 GDBTestInitAbstractFramePtr(ifptr,
69 (js::InterpreterFrame*)uintptr_t(0x8badf00));
70
71 js::AbstractFramePtr bfptr;
72 GDBTestInitAbstractFramePtr(bfptr,
73 (js::jit::BaselineFrame*)uintptr_t(0xbadcafe0));
74
75 js::AbstractFramePtr rfptr;
76 GDBTestInitAbstractFramePtr(
77 rfptr, (js::jit::RematerializedFrame*)uintptr_t(0xdabbad00));
78
79 js::AbstractFramePtr sfptr;
80 GDBTestInitAbstractFramePtr(sfptr,
81 (js::wasm::DebugFrame*)uintptr_t(0xcb98ad00));
82
83 breakpoint();
84
85 use(ifptr);
86 use(bfptr);
87 use(rfptr);
88 use(sfptr);
89 }
90