Bug 187185 - [lldb-webkit] Non-empty strings may be pretty-printed as empty
Summary: [lldb-webkit] Non-empty strings may be pretty-printed as empty
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Local Build
Hardware: Mac Unspecified
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-06-29 10:53 PDT by Daniel Bates
Modified: 2018-06-29 16:19 PDT (History)
7 users (show)

See Also:


Attachments
Patch (2.66 KB, patch)
2018-06-29 11:05 PDT, Daniel Bates
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2018-06-29 10:53:23 PDT
Today, I set a breakpoint at <https://trac.webkit.org/browser/trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm?rev=233316#L91>. Using a debug built of WebKit, I started MiniBrowser and opened a new WK2 window. When the breakpoint was hit I ran `p m_url.string()`. LLDB emitted the following:

(lldb) p m_url.string()
(const WTF::String) $9 = { length = 0, contents = '' } {
  m_impl = {
    m_ptr = 0x000000011ce6fb18 { length = 0, is8bit = 0, contents = '' }
  }
}

But m_url.string() is not an empty string:

(lldb) p m_url.string().isEmpty()
(bool) $10 = false

I am using Xcode 10.0 (10L177m) on macOS Mojave (18A323).
Comment 1 Daniel Bates 2018-06-29 10:53:59 PDT
$ Tools/Scripts/dump-class-layout -c Debug JavaScriptCore StringImpl
Found 1 types matching "StringImpl" in "/Volumes/.../WebKitBuild/Debug/JavaScriptCore.framework/JavaScriptCore" for x86_64
  +0 { 24} StringImpl
  +0 { 24}     WTF::StringImplShape
  +0 <  4>         unsigned int m_refCount;
  +4 <  4>         unsigned int m_length;
  +8 <  8>         WTF::StringImplShape::(anonymous union) None;
 +16 <  4>         unsigned int m_hashAndFlags;
 +20 <  4>         <PADDING>
 +20 <  4>     <PADDING>
Total byte size: 24
Total pad bytes: 8
Padding percentage: 33.33 %
Comment 2 Daniel Bates 2018-06-29 10:56:24 PDT
dump-class-layout does not have an issue resolving that WTF::StringImpl is effectively a WTF::StringImplShape. The LLDB repl seems to have an issue with this.
Comment 3 Daniel Bates 2018-06-29 11:05:50 PDT
Created attachment 343923 [details]
Patch
Comment 4 Daniel Bates 2018-06-29 16:18:03 PDT
Committed r233375: <https://trac.webkit.org/changeset/233375>
Comment 5 Radar WebKit Bug Importer 2018-06-29 16:19:49 PDT
<rdar://problem/41657759>