Skip to content

Commit d98ea02

Browse files
committed
Futher Refactoring of Introduction.md
1 parent 724f046 commit d98ea02

27 files changed

+392
-381
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Debugging With Xcode
2+
3+
Debugging with the Xcode IDE
4+
5+
## Debugging Layout Tests
6+
7+
The easiest way to debug a layout test is with WebKitTestRunner or DumpRenderTree.
8+
In Product > Scheme, select “All Source”.
9+
10+
In Product > Scheme > Edit Scheme, open “Run” tab.
11+
Pick WebKitTestRunner or DumpRenderTree, whichever is desired in “Executable”.
12+
13+
![Screenshot of specifying DumpRenderTree as the target of "Run" scheme](xcode-scheme-dumprendertree.png)
14+
Go to Arguments and specify the path to the layout tests being debugged relative to where the build directory is located.
15+
e.g. `../../LayoutTests/fast/dom/Element/element-traversal.html` if `WebKitBuild/Debug` is the build directory.
16+
![Screenshot of Xcode specifying a layout test in an argument to DumpRenderTree](xcode-scheme-layout-test.png)
17+
You may want to specify OS_ACTIVITY_MODE environmental variable to “disable”
18+
in order to suppress all the system logging that happens during the debugging session.
19+
20+
You may also want to specify `--no-timeout` option to prevent WebKitTestRunner or DumpRenderTree
21+
to stop the test after 30 seconds if you’re stepping through code.
22+
23+
Once this is done, you can run WebKitTestRunner or DumpRenderTree by going to Product > Perform Action > Run without Building.
24+
25+
Clicking on “Run” button may be significantly slower due to Xcode re-building every project and framework each time.
26+
You can disable this behavior by going to “Build” tab and unchecking boxes for all the frameworks involved for “Run”:
27+
![Screenshot of Xcode unchecking build options for all but DumpRenderTree for "Run" scheme](xcode-build-settings-for-run.png)
28+
29+
### Attaching to WebContent Process
30+
31+
You may find Xcode fails to attach to WebContent or Networking process in the case of WebKitTestRunner.
32+
In those cases, attach a breakpoint in UIProcess code
33+
such as [`TestController::runTest` in WebKitTestRunner right before `TestInvocation::invoke` is called](https://github.com/WebKit/WebKit/blob/5f4c01f41527547ce2f82b812ad478e12b51239d/Tools/WebKitTestRunner/TestController.cpp#L1522).
34+
Once breakpoint is hit in the UIProcess, attach to `WebContent.Development` or `Networking.Development` process manually in Xcode via Debug > Attach to Process.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Logging
2+
3+
Logging in WebKit.
4+
5+
## Setup
6+
7+
Each framework (WebCore, WebKit, WebKitLegacy, WTF) enable their own logging infrastructure independently (though the infrastructure itself is shared). If you want to log a message, `#include` the relevant framework's `Logging.h` header. Then, you can use the macros below.
8+
9+
Beware that you can't `#include` multiple framework's `Logging.h` headers at the same time - they each define a macro `LOG_CHANNEL_PREFIX` which will conflict with each other. Only `#include` the `Logging.h` header from your specific framework.
10+
11+
If you want to do more advanced operations, like searching through the list of log channels, `#include` your framework's `LogInitialization.h` header. These do not conflict across frameworks, so you can do something like
12+
13+
```
14+
#include "LogInitialization.h"
15+
#include <WebCore/LogInitialization.h>
16+
#include <WTF/LogInitialization.h>
17+
```
18+
19+
Indeed, WebKit does this to initialize all frameworks' log channels during Web Process startup.
20+
21+
## Logging messages
22+
23+
There are a few relevant macros for logging messages:
24+
25+
- `LOG()`: Log a printf-style message in debug builds. Requires you to name a logging channel to output to.
26+
- `LOG_WITH_STREAM()` Log an iostream-style message in debug builds. Requires you to name a logging channel to output to.
27+
- `RELEASE_LOG()`: Just like `LOG()` but logs in both debug and release builds. Requires you to name a logging channel to output to.
28+
- `WTFLogAlways()`: Mainly for local debugging, unconditionally output a message. Does not require a logging channel to output to.
29+
30+
Here's an example invocation of `LOG()`:
31+
32+
```
33+
LOG(MediaQueries, "HTMLMediaElement %p selectNextSourceChild evaluating media queries", this);
34+
```
35+
36+
That first argument is a log channel. These have 2 purposes:
37+
38+
- Individual channels can be enabled/disabled independently (So you can get all the WebGL logging without getting any Loading logging)
39+
- When multiple channels are enabled, and you're viewing the logs, you can search/filter by the channel
40+
41+
Here's an example invocation of `LOG_WITH_STREAM()`:
42+
43+
```
44+
LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::commitTreeState - removing unvisited node " << nodeID);
45+
```
46+
47+
The macro sets up a local variable named `stream` which the second argument can direct messages to. The second argument is a collection of statements - not expressions like `LOG()` and `RELEASE_LOG()`. So, you can do things like this:
48+
49+
```
50+
LOG_WITH_STREAM(TheLogChannel,
51+
for (const auto& something : stuffToLog)
52+
stream << " " << something;
53+
);
54+
```
55+
56+
The reason why (most of) these use macros is so the entire thing can be compiled out when logging is disabled. Consider this:
57+
58+
```
59+
LOG(TheLogChannel, "The result is %d", someSuperComplicatedCalculation());
60+
```
61+
62+
If these were not macros, you'd have to pay for `someSuperComplicatedCalculation()` whether logging is enabled or not.
63+
64+
## Enabling and disabling log channels
65+
66+
Channels are enabled/disabled at startup by passing a carefully crafted string to `initializeLogChannelsIfNecessary()`. On the macOS and iOS ports, this string comes from the _defaults_ database. On other UNIX systems and Windows, it comes from environment variables.
67+
68+
You can read the grammar of this string in `initializeLogChannelsIfNecessary()`. Here is an example:
69+
70+
```
71+
WebGL -Loading
72+
```
73+
74+
You can also specify the string `all` to enable all logging.
75+
76+
On macOS/iOS and Windows, each framework has its own individually supplied string that it uses to enable its own logging channels. On Linux, all frameworks share the same string.
77+
78+
### Linux
79+
80+
Set the `WEBKIT_DEBUG` environment variable.
81+
82+
```
83+
WEBKIT_DEBUG=Scrolling Tools/Scripts/run-minibrowser --gtk --debug
84+
```
85+
86+
### macOS
87+
88+
On macOS, you can, for example, enable the `Language` log channel with these terminal commands:
89+
90+
```
91+
for identifier in com.apple.WebKit.WebContent.Development com.apple.WebKit.WebContent org.webkit.MiniBrowser com.apple.WebKit.WebKitTestRunner org.webkit.DumpRenderTree -g /Users/$USER/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist; do
92+
for key in WTFLogging WebCoreLogging WebKitLogging WebKit2Logging; do
93+
defaults write ${identifier} "${key}" "Language"
94+
done
95+
done
96+
```
97+
98+
You may also need to specify these strings to `com.apple.WebKit.WebContent.Development`, the global domain, or the Safari container, depending on what you're running.
99+
100+
You may also pass this key and value as an argument:
101+
102+
```
103+
Tools/Scripts/run-minibrowser --debug -WebCoreLogging Scrolling
104+
```
105+
106+
### Windows
107+
108+
Set the `WebCoreLogging` environment variable.
109+
110+
## Adding a new log channel
111+
112+
Simply add a line to your framework's `Logging.h` header. Depending on how the accompanying `Logging.cpp` file is set up, you may need to add a parallel line there. That should be all you need. It is acceptable to have log channels in different frameworks with the same name - this is what `LOG_CHANNEL_PREFIX` is for.

Sources/WebKit/WebKit.docc/BugTracking.md renamed to Sources/WebKit/WebKit.docc/GettingStarted/BugTracking.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
[bugs.webkit.org](https://bugs.webkit.org/) hosted is the primary bug tracking tool we use.
66
We use bugzilla to file bugs, and then perform code review using GitHub.
77

8-
### Filing a bug and editing bugs
8+
### Filing and Editing Bugs
99

1010
To [file a new WebKit bug](https://bugs.webkit.org/enter_bug.cgi), see [reporting bugs](https://webkit.org/reporting-bugs/).
11-
1211
To edit an existing bug, you may need [editbug-bits](https://webkit.org/bugzilla-bits/).
1312

14-
### Code review
15-
Code reviews are done on GitHub when a pull request is made. See [Submitting a pull request](#submitting-a-pull-request).
16-
17-
### Security Bugs
13+
### Reporting Security Bugs
1814

1915
Security bugs have their own components in [bugs.webkit.org](https://bugs.webkit.org/).
2016
We’re also working on a new policy to delay publishing tests for security fixes until after the fixes have been widely deployed.

Sources/WebKit/WebKit.docc/ContributingCode.md renamed to Sources/WebKit/WebKit.docc/GettingStarted/ContributingCode.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,49 @@
22

33
WebKit has a rigorous code contribution process and policy in place to maintain the quality of code.
44

5-
### Coding style
5+
## Getting setup to contribute
6+
7+
After downloading the code please run the below command.
8+
9+
```Bash
10+
git webkit setup
11+
```
12+
13+
The `setup` checks that your environment is optimally configured to contribute, and may prompt you for some additional information.
14+
15+
### Submitting a pull request
16+
17+
Firstly, please make sure you [file a bug](https://bugs.webkit.org) for the thing you are adding or fixing! Or, find a bug that you think is relevant to the fix you are making.
18+
19+
Assuming you are working off "main" branch, once your patch is working and [tests are passing](#correctness-testing-in-webkit), simply run:
20+
21+
```Bash
22+
git webkit pr --issue <your bug number here>
23+
```
24+
25+
That will pull down the details from [bugs.webkit.org](https://bugs.webkit.org), create a new git branch, and generate a commit message for you.
26+
If necessary, please add additional details describing what you've added, modified, or fixed.
27+
28+
Once your pull request is on GitHub, the Early Warning System (a.k.a. EWS) will automatically build and run tests against your code change.
29+
This allows contributors to find build or test failures before committing code changes to the WebKit’s repository.
30+
31+
Note, if you'd like to submit a draft pull request, you can do so by running:
32+
33+
```Bash
34+
git webkit pr --draft
35+
```
36+
37+
## Addressing review feedback
38+
39+
After you receive review feedback on GitHub, you should collaborate with the reviewer to address the feedback.
40+
41+
Once done, you can update your pull request to include the changes by again simply running:
42+
43+
```Bash
44+
git webkit pr
45+
```
46+
47+
## Coding style
648

749
Code you write must follow WebKit’s [coding style guideline](https://webkit.org/contributing-code/#code-style-guidelines).
850
You can run `Tools/Scripts/check-webkit-style` to check whether your code follows the coding guidelines or not
@@ -13,17 +55,17 @@ it automatically runs the style checker against the code you changed so there is
1355
Some older parts of the codebase do not follow these guidelines.
1456
If you are modifying such code, it is generally best to clean it up to comply with the current guidelines.
1557

16-
### Convenience Tools
58+
## Convenience Tools
1759

1860
`Tools/Scripts/webkit-patch` provides a lot of utility functions like applying the latest patch on [bugs.webkit.org](https://bugs.webkit.org/) (`apply-from-bug`)
1961
and uploading a patch (`upload --git-commit=<commit hash>`) to a [bugs.webkit.org](https://bugs.webkit.org/) bug.
2062
Use `--all-commands` to the list of all commands this tool supports.
2163

22-
### Regression Tests
64+
## Regression Tests
2365

2466
Once you have made a code change, you need to run the aforementioned tests (layout tests, API tests, etc...)
2567
to make sure your code change doesn’t break existing functionality.
26-
These days, uploading a patch on [bugs.webkit.org](https://bugs.webkit.org/) triggers the Early Warning System (a.k.a. EWS)
68+
These days, uploading a patch on [bugs.webkit.org](https://bugs.webkit.org/) triggers the Early Warning System (a.k.a. EWS).
2769

2870
For any bug fix or a feature addition, there should be a new test demonstrating the behavior change caused by the code change.
2971
If no such test can be written in a reasonable manner (e.g. the fix for a hard-to-reproduce race condition),
@@ -32,7 +74,7 @@ then the reason writing a tests is impractical should be explained in the accomp
3274
Any patch which introduces new test failures or performance regressions may be reverted.
3375
It’s in your interest to wait for the Early Warning System to fully build and test your patch on all relevant platforms.
3476

35-
### Commit messages
77+
## Commit messages
3678

3779
Commit messages serve as change logs, providing historical documentation for all changes to the WebKit project.
3880
Running `git-webkit setup` configures your git hooks to properly generate commit messages.

0 commit comments

Comments
 (0)