chrome-devtools-frontend 1.0.1012587 → 1.0.1013367

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -115,19 +115,22 @@ export class LinearMemoryViewer extends HTMLElement {
115
115
 
116
116
  // We initially just plot one row with one byte group (here: byte group size of 4).
117
117
  // Depending on that initially plotted row we can determine how many rows and
118
- // bytes per row we can fit:
119
- // > 0000000 | b0 b1 b2 b4 | a0 a1 a2 a3 <
120
- // ^-^ ^-^
121
- // byteCellWidth textCellWidth
122
- // ^-------------------------------^
123
- // widthToFill
118
+ // bytes per row we can fit.
119
+ // > 0000000 | b0 b1 b2 b4 | a0 a1 a2 a3 <
120
+ // ^-------^ ^-^ ^-^
121
+ // | byteCellWidth textCellWidth
122
+ // |
123
+ // addressTextAndDividerWidth
124
+ // ^--^ + ^----------------------------^
125
+ // widthToFill
124
126
 
125
127
  const firstByteCell = this.shadowRoot.querySelector('.byte-cell');
126
128
  const textCell = this.shadowRoot.querySelector('.text-cell');
127
129
  const divider = this.shadowRoot.querySelector('.divider');
128
130
  const rowElement = this.shadowRoot.querySelector('.row');
131
+ const addressText = this.shadowRoot.querySelector('.address');
129
132
 
130
- if (!firstByteCell || !textCell || !divider || !rowElement) {
133
+ if (!firstByteCell || !textCell || !divider || !rowElement || !addressText) {
131
134
  this.#numBytesInRow = BYTE_GROUP_SIZE;
132
135
  this.#numRows = 1;
133
136
  return;
@@ -140,16 +143,18 @@ export class LinearMemoryViewer extends HTMLElement {
140
143
 
141
144
  // Calculate the width to fill.
142
145
  const dividerWidth = divider.getBoundingClientRect().width;
143
- // this.clientWidth is rounded, while the other values are not. Subtract one to make
146
+ const addressTextAndDividerWidth =
147
+ firstByteCell.getBoundingClientRect().left - addressText.getBoundingClientRect().left;
148
+
149
+ // this.clientWidth is rounded, while the other values are not. Subtract 1 to make
144
150
  // sure that we correctly calculate the widths.
145
- const widthToFill = this.clientWidth - 1 -
146
- (firstByteCell.getBoundingClientRect().left - this.getBoundingClientRect().left) - dividerWidth;
151
+ const widthToFill = this.clientWidth - 1 - addressTextAndDividerWidth - dividerWidth;
152
+
147
153
  if (widthToFill < groupWidth) {
148
154
  this.#numBytesInRow = BYTE_GROUP_SIZE;
149
155
  this.#numRows = 1;
150
156
  return;
151
157
  }
152
-
153
158
  this.#numBytesInRow = Math.floor(widthToFill / groupWidth) * BYTE_GROUP_SIZE;
154
159
  this.#numRows = Math.floor(this.clientHeight / rowElement.clientHeight);
155
160
  }
@@ -19,6 +19,10 @@
19
19
  padding: 9px 12px 9px 7px;
20
20
  }
21
21
 
22
+ devtools-linear-memory-inspector-viewer {
23
+ justify-content: center;
24
+ }
25
+
22
26
  devtools-linear-memory-inspector-navigator + devtools-linear-memory-inspector-viewer {
23
27
  margin-top: 12px;
24
28
  }
package/package.json CHANGED
@@ -55,5 +55,5 @@
55
55
  "unittest": "scripts/test/run_unittests.py --no-text-coverage",
56
56
  "watch": "vpython third_party/node/node.py --output scripts/watch_build.js"
57
57
  },
58
- "version": "1.0.1012587"
58
+ "version": "1.0.1013367"
59
59
  }
@@ -121,9 +121,9 @@ template("devtools_entrypoint") {
121
121
 
122
122
  is_web_worker = _is_web_worker
123
123
 
124
- if (defined(use_rbe) && use_rbe && defined(devtools_use_rbe) &&
125
- devtools_use_rbe) {
126
- use_rbe = false
124
+ if (defined(use_remoteexec) && use_remoteexec &&
125
+ defined(devtools_use_remoteexec) && devtools_use_remoteexec) {
126
+ use_remoteexec = false
127
127
  }
128
128
  }
129
129
 
@@ -0,0 +1,25 @@
1
+ # Copyright 2022 The Chromium 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
+ import("./copy.gni")
5
+
6
+ template("wasm_module") {
7
+ assert(defined(invoker.sources), "Need sources in $target_name")
8
+ action_foreach(target_name) {
9
+ script = devtools_location_prepend + "scripts/build/wasm-as.py"
10
+ outputs = [
11
+ "$target_gen_dir/{{source_name_part}}.wasm",
12
+ "$target_gen_dir/{{source_name_part}}.wasm.map",
13
+ "$target_gen_dir/{{source_name_part}}.wasm.map.json",
14
+ ]
15
+ args = [
16
+ "{{source}}",
17
+ rebase_path("$target_gen_dir/{{source_name_part}}.wasm", root_build_dir),
18
+ ]
19
+ sources = invoker.sources
20
+ }
21
+
22
+ copy_to_gen(target_name + "_sources") {
23
+ sources = invoker.sources
24
+ }
25
+ }
@@ -0,0 +1,87 @@
1
+ # Copyright 2022 The Chromium 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
+ import argparse
6
+ import json
7
+ from os import path
8
+ import platform
9
+ import re
10
+ import subprocess
11
+ import sys
12
+
13
+ REPO_DIR = path.join(path.dirname(__file__), '..', '..')
14
+
15
+
16
+ def llvm_readobj():
17
+ binary_name = {
18
+ 'Darwin': 'llvm-readobj',
19
+ 'Linux': 'llvm-readobj',
20
+ 'Windows': 'llvm-readobj.exe',
21
+ }[platform.system()]
22
+ return path.realpath(
23
+ path.join(REPO_DIR, 'third_party', 'emscripten-releases', 'install',
24
+ 'bin', binary_name))
25
+
26
+
27
+ def wasm_as():
28
+ binary_name = {
29
+ 'Darwin': 'wasm-as',
30
+ 'Linux': 'wasm-as',
31
+ 'Windows': 'wasm-as.exe',
32
+ }[platform.system()]
33
+ return path.realpath(
34
+ path.join(REPO_DIR, 'third_party', 'emscripten-releases', 'install',
35
+ 'bin', binary_name))
36
+
37
+
38
+ def script_main(args):
39
+ parser = argparse.ArgumentParser()
40
+ parser.add_argument('input')
41
+ parser.add_argument('output')
42
+ options = parser.parse_args(args)
43
+
44
+ sourcemap = f'{options.output}.map'
45
+ subprocess.check_call([
46
+ wasm_as(), options.input, '-g', '-sm', sourcemap, '-o', options.output
47
+ ])
48
+
49
+ wasm_obj_headers = subprocess.check_output([
50
+ llvm_readobj(),
51
+ '-e',
52
+ # TODO(crbug.com/1328729): use JSON output as soon as that's supported for wasm
53
+ # '--elf-output-style=JSON',
54
+ options.output
55
+ ])
56
+ (size, offset) = re.search(
57
+ b'Section {[^}]*Type: CODE[^}]*Size: (\d*)[^}]*Offset: (\d*)[^}]*}',
58
+ wasm_obj_headers).groups()
59
+
60
+ # readobj reports as offset the location of the first byte of the header.
61
+ # Our offsets are relative to the first byte of the section though, so
62
+ # calculate the offset manually. The header is composed of one byte for the
63
+ # section id, and an leb128 value for the length.
64
+ size = int(size)
65
+ leb_len = 0
66
+ while size > 0:
67
+ size >>= 7
68
+ leb_len += 1
69
+ offset = int(offset) + 1 + leb_len
70
+
71
+ node = path.realpath(path.join(REPO_DIR, 'third_party', 'node', 'node.py'))
72
+ sourcemap2json = path.realpath(
73
+ path.join(REPO_DIR, 'scripts', 'build', 'wasm_sourcemap.mjs'))
74
+ sourcemap_contents = subprocess.check_output([
75
+ sys.executable, node, '--output', sourcemap2json, sourcemap,
76
+ '%s' % (offset)
77
+ ])
78
+
79
+ json_file = f'{options.output}.map.json'
80
+ with open(json_file, 'wb') as output:
81
+ output.write(sourcemap_contents)
82
+
83
+ return 0
84
+
85
+
86
+ if __name__ == '__main__':
87
+ sys.exit(script_main(sys.argv[1:]))
@@ -0,0 +1,22 @@
1
+ // Copyright 2022 The Chromium 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
+ import * as fs from 'fs';
6
+ import * as sourceMap from 'source-map';
7
+
8
+ if (process.argv.length !== 4) {
9
+ throw new Error(`usage: ${process.argv[1]} <input.map> <offset>`);
10
+ }
11
+
12
+ const offset = Number(process.argv[3] || 0);
13
+ const sourceMapContents = JSON.parse(fs.readFileSync(process.argv[2], 'utf-8'));
14
+ const sourceMapConsumer = new sourceMap.SourceMapConsumer(sourceMapContents);
15
+
16
+ const sourceMappings = [];
17
+ sourceMapConsumer.eachMapping(({source, generatedLine, generatedColumn, originalLine, originalColumn}) => {
18
+ const bytecodeOffset = generatedColumn - offset;
19
+ sourceMappings.push({source, generatedLine, generatedColumn, originalLine, originalColumn, bytecodeOffset});
20
+ });
21
+
22
+ console.log(JSON.stringify(sourceMappings));