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
5import("../../gni/v8.gni")
6
7config("v8windbg_config") {
8  # Required for successful compilation of SDK header file DbgModel.h.
9  cflags_cc = [ "/Zc:twoPhase-" ]
10
11  include_dirs = [ "../.." ]
12}
13
14# Basic support for WinDbg extensions, with nothing specific to V8.
15source_set("v8windbg_base") {
16  testonly = true
17
18  sources = [
19    "base/dbgext.cc",
20    "base/dbgext.h",
21    "base/utilities.cc",
22    "base/utilities.h",
23  ]
24
25  libs = [
26    "DbgEng.lib",
27    "DbgModel.lib",
28    "RuntimeObject.lib",
29    "comsuppwd.lib",
30  ]
31
32  public_configs = [ ":v8windbg_config" ]
33}
34
35# An extension DLL that can be loaded into WinDbg with `.load v8windbg`.
36v8_shared_library("v8windbg") {
37  testonly = true
38
39  sources = [
40    "base/dbgext.def",
41    "src/cur-isolate.cc",
42    "src/cur-isolate.h",
43    "src/js-stack.cc",
44    "src/js-stack.h",
45    "src/local-variables.cc",
46    "src/local-variables.h",
47    "src/object-inspection.cc",
48    "src/object-inspection.h",
49    "src/v8-debug-helper-interop.cc",
50    "src/v8-debug-helper-interop.h",
51    "src/v8windbg-extension.cc",
52    "src/v8windbg-extension.h",
53  ]
54
55  deps = [
56    ":v8windbg_base",
57    "../../:v8_flags",
58    "../../:v8_libbase",
59    "../../:v8_shared_internal_headers",
60    "../debug_helper:v8_debug_helper",
61  ]
62}
63
64# Copies Windows SDK files that v8windbg_test needs.
65action("copy_prereqs") {
66  testonly = true
67
68  script = "copy-prereqs.py"
69
70  inputs = [
71    script,
72    "//build/vs_toolchain.py",
73  ]
74
75  outputs = [ "$root_out_dir/dbgeng.dll" ]
76
77  args = [
78    rebase_path("//build", root_build_dir),
79    rebase_path(root_out_dir, root_build_dir),
80    target_cpu,
81  ]
82}
83
84# A test that launches a separate d8 process and debugs it using v8windbg.
85v8_source_set("v8windbg_test") {
86  testonly = true
87
88  sources = [
89    "test/debug-callbacks.cc",
90    "test/debug-callbacks.h",
91    "test/v8windbg-test.cc",
92    "test/v8windbg-test.h",
93  ]
94
95  deps = [ "../..:v8_libbase" ]  # For CHECK macro.
96
97  data_deps = [
98    ":copy_prereqs",
99    ":v8windbg",
100    ":v8windbg_test_script",
101    "../..:d8",
102  ]
103
104  libs = [
105    "DbgEng.lib",
106    "DbgModel.lib",
107    "Pathcch.lib",
108    "RuntimeObject.lib",
109  ]
110
111  configs = [ ":v8windbg_config" ]
112}
113
114# Copies the JavaScript file used by v8windbg_test.
115copy("v8windbg_test_script") {
116  testonly = true
117  sources = [ "test/script.js" ]
118  outputs = [ "$target_out_dir/v8windbg-test-script.js" ]
119}
120