You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/WebKit/WebKit.docc/Build&Debug/DebuggingWithXcode.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,35 @@
2
2
3
3
Debugging with the Xcode IDE
4
4
5
+
## Overview
6
+
7
+
You can also use Xcode to build & debug WebKit. Open `WebKit.xcworkspace` at the top level directory.
8
+
9
+
In order to make Xcode use build files built by `make` command above,
10
+
go to File > Workspace Settings... > Advanced... > Custom > Relative to Workspace
11
+
and adjust the relative paths of Products and Intermediates to point to `WebKitBuild` directory.
12
+

13
+

14
+
Note that debugging WebCore code typically requires attaching to the relevant WebContent process,
15
+
not the application process, which is mostly running code in [Source/WebKit/UIProcess](https://github.com/WebKit/WebKit/tree/main/Source/WebKit/UIProcess).
16
+
Depending on what you’re debugging, you’d have to attach & debug different processes in the coalition.
17
+
18
+
You may find it useful to use the debug helpers under `Tools/lldb/lldb_webkit.py`.
19
+
This can be added to `~/.lldbinit` for automatic loading into LLDB on launch by adding the line `command script import {Path to WebKit}/Tools/lldb/lldb_webkit.py`.
20
+
For more details, see the Wiki article on [lldb formatters](https://trac.webkit.org/wiki/lldb%20formatters).
21
+
22
+
When debugging a debug build in LLDB, there are also a few functions that can be called on objects that will dump debugging info.
23
+
24
+
* RenderObject
25
+
* showNodeTree()
26
+
* showLineTree()
27
+
* showRenderTree()
28
+
* Node
29
+
* showTree()
30
+
* showNodePath()
31
+
* showTreeForThis()
32
+
* showNodePathForThis()
33
+
5
34
## Debugging Layout Tests
6
35
7
36
The easiest way to debug a layout test is with WebKitTestRunner or DumpRenderTree.
a JS wrapper for each `Node` which is being removed from its parent if there isn't already one.
296
+
A `Node` which is a root node (of the newly removed [subtree](https://dom.spec.whatwg.org/#concept-tree)) is an opaque root of its JS wrapper,
297
+
and the garbage collector will visit this opaque root if there is any JS wrapper in the removed subtree that needs to be kept alive.
298
+
In effect, this keeps the new root node and all its [descendant](https://dom.spec.whatwg.org/#concept-tree-descendant) nodes alive
299
+
if the newly removed subtree contains any node with a live JS wrapper, preserving the API contract.
300
+
301
+
It's important to recognize that storing a `Ref` or a `RefPtr` to another `Node` in a `Node` subclass
302
+
or an object directly owned by the Node can create a [reference cycle](https://en.wikipedia.org/wiki/Reference_counting#Dealing_with_reference_cycles),
303
+
or a reference that never gets cleared.
304
+
It's not guaranteed that every node is [disconnected](https://dom.spec.whatwg.org/#connected)
305
+
from a [`Document`](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/Document.h) at some point in the future,
306
+
and some `Node` may always have a parent node or a child node so long as it exists.
307
+
Only permissible circumstances in which a `Ref` or a `RefPtr` to another `Node` can be stored
308
+
in a `Node` subclass or other data structures owned by it is if it's temporally limited.
309
+
For example, it's okay to store a `Ref` or a `RefPtr` in
310
+
an enqueued [event loop task](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/EventLoop.h#L69).
311
+
In all other circumstances, `WeakPtr` should be used to reference another `Node`,
312
+
and JS wrapper relationships such as opaque roots should be used to preserve the lifecycle ties between `Node` objects.
313
+
314
+
It's equally crucial to observe that keeping C++ Node object alive by storing `Ref` or `RefPtr`
315
+
in an enqueued [event loop task](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/EventLoop.h#L69)
316
+
does not keep its JS wrapper alive, and can result in the JS wrapper of a conceptually live object to be erroneously garbage collected.
317
+
To avoid this problem, use [`GCReachableRef`](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/GCReachableRef.h) instead
318
+
to temporarily hold a strong reference to a node over a period of time.
319
+
For example, [`HTMLTextFormControlElement::scheduleSelectEvent()`](https://github.com/WebKit/WebKit/blob/297c01a143f649b34544f0cb7a555decf6ecbbfd/Source/WebCore/html/HTMLTextFormControlElement.cpp#L547)
320
+
uses `GCReachableRef` to fire an event in an event loop task:
WebKit’s CI ([continuous integration](https://en.wikipedia.org/wiki/Continuous_integration)) infrastructure is located at [build.webkit.org](https://build.webkit.org/)).
6
+
7
+
[build.webkit.org](https://build.webkit.org/) will build and test commits from WebKit in the chronological order
8
+
and report test results to [results.webkit.org](https://results.webkit.org/).
9
+
Due to the chronological ordering, results could be a few hours behind during the work week.
10
+
11
+
12
+
We also have a dashboard to monitor the health of [build.webkit.org](https://build.webkit.org/)
13
+
at [build.webkit.org/dashboard](https://build.webkit.org/dashboard/).
14
+
If you observe that some bots are offline, or otherwise not processing your patch,
| Inserting or Removing DOM Nodes | FIXME: Talk about how a node insertion or removal works. |
10
+
| Understanding Style and Render Tree | FIXME: Describe rendering/layers/compositing |
11
+
| Security Model of Web | For starters, refer to https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy. FIXME: Write this section. |
0 commit comments