feat(libSceNKWebKit): implement WTF::printInternal for StringImpl pointers and WTF::URL::dump #24896

Merged
XFlawless1 merged 1 commit from upstream-pr/24896 into main 2026-11-22 11:44:42 +00:00
XFlawless1 commented 2026-11-21 09:52:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XFlawless1 on 2026-11-21T09:52:02Z.


What

Implements two WTF::PrintStream string dumps that were throwing stubs:

Export Pinned source Output
WTF::printInternal(PrintStream&, const StringImpl*) PrintStream.cpp L76-L120 null: (null StringImpl*); otherwise the string's lenient UTF-8 (tryGetUTF8()), each through the stream's printf("%s", …)
WTF::URL::dump(PrintStream&) const URL.cpp L847-L850 out.print(m_string): begin(), printInternal(const String&) on the returned stream (lenient UTF-8, an empty string for a null URL string), end()

PrintStream is the guest object of WtfDumpStreamAbi.hpp; printf goes through its vprintf slot with a System V va_list, and print through its begin/end slots, as WtfTimeDump.cpp already does. The UTF-8 comes from this library's StringImpl::utf8(LenientConversion). Lenient conversion does not fail and allocation failure is not reported here, so the pinned (Out of memory while converting …) / (failed to convert …) texts are never printed; that is recorded in debt. Like upstream, %s stops at an embedded NUL. A null stream or URL throws.

The code is in new files (src/WtfStringDump.cpp, include/WtfStringDumpExports.hpp); #19839 and #19841, which implement other printInternal overloads, add WtfPrintStream.cpp and WtfPrintStreamAbi.hpp, and nothing here touches those names.

Tested

Windows 11, MinGW GCC 15.2, Release.

  • nkwebkit_wtfstringdump passes, using a fake guest stream whose vprintf (it also checks the format is %s), begin and end slots log what they receive:
    • printInternal: null → (null StringImpl*); empty; ASCII; Latin-1 é, U+00A0 and U+00FF → two-byte UTF-8; UTF-16 €, an astral emoji and é; ASCII in a 16-bit string; unpaired high and low surrogates → U+FFFD; an embedded NUL stops output; % characters pass through as data; output goes to the stream itself with no begin/end; the string's reference count is unchanged;
    • URL::dump: a parsed URL prints its canonical string, an invalid URL its input, a null URL an empty string and a 16-bit URL string its UTF-8, each between the outer stream's begin and end and written to the stream begin returns;
    • a null stream or null URL throws std::invalid_argument without writing anything.
  • Negative controls, each rebuilt and run, each makes the test fail: URL::dump writing to the outer stream instead of the one begin returns; strict instead of lenient conversion.
  • nkwebkit_wtftimedump still passes.
  • After a full build and after rebasing on current main, all 181 nkwebkit_* tests pass, as do the 15 registration|conventions_pr_template|pr_overlap_exports|conventions_unknown_nids tests.
  • python tools/check_conventions.py --base origin/main and python tools/debt_fold.py --check pass.

Not tested on a console.

Overlap (python tools/pr_overlap.py --names and --branch feat/nkwebkit-wtf-string-print-stream-dumps):

  • No open PR implements either export. #24322, the refactor that splits the large libraries, moves the stubs without implementing them.
  • #19839 and #19841 (other printInternal overloads) delete stubs next to these in Export.cpp and InventoryExports.hpp, so whichever merges second gets a textual conflict there; the resolution keeps all deletions.
  • #24614 adds an include next to PalCryptoDigestExports.hpp; this PR's include is elsewhere and the two merge without conflict (git merge-tree).
  • The tool could not compare 38 open PRs that already conflict with main and share Export.cpp, InventoryExports.hpp or libSceNKWebKit.hpp; the --names search covers every open PR's changes and finds these exports only in #24322.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5426598313 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24896). Originally posted by [XFlawless1](https://github.com/XFlawless1) on 2026-11-21T09:52:02Z. --- ### What Implements two `WTF::PrintStream` string dumps that were throwing stubs: | Export | Pinned source | Output | |---|---|---| | `WTF::printInternal(PrintStream&, const StringImpl*)` | [PrintStream.cpp L76-L120](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/PrintStream.cpp#L76-L120) | null: `(null StringImpl*)`; otherwise the string's lenient UTF-8 (`tryGetUTF8()`), each through the stream's `printf("%s", …)` | | `WTF::URL::dump(PrintStream&) const` | [URL.cpp L847-L850](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/URL.cpp#L847-L850) | `out.print(m_string)`: `begin()`, `printInternal(const String&)` on the returned stream (lenient UTF-8, an empty string for a null URL string), `end()` | `PrintStream` is the guest object of `WtfDumpStreamAbi.hpp`; `printf` goes through its `vprintf` slot with a System V `va_list`, and `print` through its `begin`/`end` slots, as `WtfTimeDump.cpp` already does. The UTF-8 comes from this library's `StringImpl::utf8(LenientConversion)`. Lenient conversion does not fail and allocation failure is not reported here, so the pinned `(Out of memory while converting …)` / `(failed to convert …)` texts are never printed; that is recorded in debt. Like upstream, `%s` stops at an embedded NUL. A null stream or URL throws. The code is in new files (`src/WtfStringDump.cpp`, `include/WtfStringDumpExports.hpp`); #19839 and #19841, which implement other `printInternal` overloads, add `WtfPrintStream.cpp` and `WtfPrintStreamAbi.hpp`, and nothing here touches those names. ### Tested Windows 11, MinGW GCC 15.2, Release. - `nkwebkit_wtfstringdump` passes, using a fake guest stream whose `vprintf` (it also checks the format is `%s`), `begin` and `end` slots log what they receive: - `printInternal`: null → `(null StringImpl*)`; empty; ASCII; Latin-1 `é`, U+00A0 and U+00FF → two-byte UTF-8; UTF-16 `€`, an astral emoji and `é`; ASCII in a 16-bit string; unpaired high and low surrogates → U+FFFD; an embedded NUL stops output; `%` characters pass through as data; output goes to the stream itself with no `begin`/`end`; the string's reference count is unchanged; - `URL::dump`: a parsed URL prints its canonical string, an invalid URL its input, a null URL an empty string and a 16-bit URL string its UTF-8, each between the outer stream's `begin` and `end` and written to the stream `begin` returns; - a null stream or null URL throws `std::invalid_argument` without writing anything. - Negative controls, each rebuilt and run, each makes the test fail: `URL::dump` writing to the outer stream instead of the one `begin` returns; strict instead of lenient conversion. - `nkwebkit_wtftimedump` still passes. - After a full build and after rebasing on current `main`, all 181 `nkwebkit_*` tests pass, as do the 15 `registration|conventions_pr_template|pr_overlap_exports|conventions_unknown_nids` tests. - `python tools/check_conventions.py --base origin/main` and `python tools/debt_fold.py --check` pass. Not tested on a console. **Overlap** (`python tools/pr_overlap.py --names` and `--branch feat/nkwebkit-wtf-string-print-stream-dumps`): - No open PR implements either export. #24322, the refactor that splits the large libraries, moves the stubs without implementing them. - #19839 and #19841 (other `printInternal` overloads) delete stubs next to these in `Export.cpp` and `InventoryExports.hpp`, so whichever merges second gets a textual conflict there; the resolution keeps all deletions. - #24614 adds an include next to `PalCryptoDigestExports.hpp`; this PR's include is elsewhere and the two merge without conflict (`git merge-tree`). - The tool could not compare 38 open PRs that already conflict with `main` and share `Export.cpp`, `InventoryExports.hpp` or `libSceNKWebKit.hpp`; the `--names` search covers every open PR's changes and finds these exports only in #24322. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PrivacyOnion commented 2026-11-21 09:54:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T09:54:15Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 5f31cd8eeb:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_wtfstringdump_tests built cleanly.
  • CTest (nkwebkit_wtfstringdump):
    1/1 Test #4894: nkwebkit_wtfstringdump ...........   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/WtfStringDump.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WTF::printInternal(PrintStream&, const StringImpl*) correctly handles null string pointer by printing '(null StringImpl*)' via PrintCString and null PrintStream by throwing std::invalid_argument.
    • Verified WTF::URL::dump(PrintStream&) correctly validates self and out pointers, invokes PrintStreamBegin and PrintStreamEnd vtable slots, and formats UTF-8 content via _ZNK3WTF10StringImpl4utf8ENS_14ConversionModeE.
    • Verified variadic arguments handling in StringDumpPrintf_nid_no_patch correctly uses sysv_va_list on Windows and std::va_list on Linux, dispatching to PrintStreamVprintf slot.
    • Verified memory management of CString buffer and StringImpl refcounts during dump and formatting operations.
    • Verified AGENTS.md compliance regarding lack of disallowed code comments, technical debt fragments in docs/dev/debt/changes/, and removal of exported stubs from Export.cpp and InventoryExports.hpp.
    • Verified comprehensive test coverage in core/libs/prx/libSceNKWebKit/tests/WtfStringDump.cpp exercising Latin1, UTF-16, surrogates, embedded NULs, valid/invalid URLs, and null arguments.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004485993 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24896#pullrequestreview-6004485993). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T09:54:15Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `5f31cd8eeb`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_wtfstringdump_tests` built cleanly. - **CTest** (`nkwebkit_wtfstringdump`): ``` 1/1 Test #4894: nkwebkit_wtfstringdump ........... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/WtfStringDump.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified WTF::printInternal(PrintStream&, const StringImpl*) correctly handles null string pointer by printing '(null StringImpl*)' via PrintCString and null PrintStream by throwing std::invalid_argument. - Verified WTF::URL::dump(PrintStream&) correctly validates self and out pointers, invokes PrintStreamBegin and PrintStreamEnd vtable slots, and formats UTF-8 content via _ZNK3WTF10StringImpl4utf8ENS_14ConversionModeE. - Verified variadic arguments handling in StringDumpPrintf_nid_no_patch correctly uses sysv_va_list on Windows and std::va_list on Linux, dispatching to PrintStreamVprintf slot. - Verified memory management of CString buffer and StringImpl refcounts during dump and formatting operations. - Verified AGENTS.md compliance regarding lack of disallowed code comments, technical debt fragments in docs/dev/debt/changes/, and removal of exported stubs from Export.cpp and InventoryExports.hpp. - Verified comprehensive test coverage in core/libs/prx/libSceNKWebKit/tests/WtfStringDump.cpp exercising Latin1, UTF-16, surrogates, embedded NULs, valid/invalid URLs, and null arguments. Looks Good To Me
MarcZX10 commented 2026-11-21 10:10:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T10:10:03Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 5f31cd8eebb75b0ea32d887468835d3b527212fa using the prepared diff and pinned repository reader. No tests or builds were run; the test results in the PR description are author-reported.

Results

Check Result Note
Changed implementation and test review passed New dump paths and ABI use inspected
Build and tests not run PR-reported results not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full texts of core/libs/prx/libSceNKWebKit/Export.cpp and core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp were excluded as too large; their changed hunks were visible in the prepared diff, but their surrounding code was not read. No build, tests, console behavior, or PR-reported checks were independently verified. Read: description.md, commits.md, manifest.json, diff.patch, src/WtfStringDump.cpp, include/WtfStringDumpExports.hpp, libSceNKWebKit.hpp, tests/WtfStringDump.cpp, src/WtfStringAbi.hpp, src/WtfDumpStreamAbi.hpp, src/WtfTimeDump.cpp, and CMakeLists.txt. Excluded: Export.cpp and InventoryExports.hpp full text; files.json was unavailable through the reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004543872 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24896#pullrequestreview-6004543872). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T10:10:03Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this; the points below are optional. ## What I ran Reviewed head `5f31cd8eebb75b0ea32d887468835d3b527212fa` using the prepared diff and pinned repository reader. No tests or builds were run; the test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed implementation and test review | passed | New dump paths and ABI use inspected | | Build and tests | not run | PR-reported results not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full texts of `core/libs/prx/libSceNKWebKit/Export.cpp` and `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp` were excluded as too large; their changed hunks were visible in the prepared diff, but their surrounding code was not read. No build, tests, console behavior, or PR-reported checks were independently verified. Read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `src/WtfStringDump.cpp`, `include/WtfStringDumpExports.hpp`, `libSceNKWebKit.hpp`, `tests/WtfStringDump.cpp`, `src/WtfStringAbi.hpp`, `src/WtfDumpStreamAbi.hpp`, `src/WtfTimeDump.cpp`, and `CMakeLists.txt`. Excluded: `Export.cpp` and `InventoryExports.hpp` full text; `files.json` was unavailable through the reader. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!24896
No description provided.