Bug 61149 - [debug feature] WTFString should have show() method
Summary: [debug feature] WTFString should have show() method
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-19 15:13 PDT by Ryosuke Niwa
Modified: 2011-05-26 15:09 PDT (History)
7 users (show)

See Also:


Attachments
adds String::show (1.68 KB, patch)
2011-05-19 15:39 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
adds String::show and AtomicString::show (2.71 KB, patch)
2011-05-19 16:11 PDT, Ryosuke Niwa
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2011-05-19 15:13:10 PDT
gdb that comes with XCode 3 doesn't support printing WTFString.  We should add a show() method to WTFString to ease the pain.
Comment 1 Anders Carlsson 2011-05-19 15:23:52 PDT
Yes please. I'm getting tired of gdb crashing when trying to print WTF Strings using p string.utf8().data();
Comment 2 Ryosuke Niwa 2011-05-19 15:26:53 PDT
(In reply to comment #1)
> Yes please. I'm getting tired of gdb crashing when trying to print WTF Strings using p string.utf8().data();

Yeah, that gdb bug is driving me nuts.  I don't remember how many times I had to spend minutes getting into the right breakpoint and the first "p ~~" crashed :(
Comment 3 Ryosuke Niwa 2011-05-19 15:39:20 PDT
Created attachment 94134 [details]
adds String::show
Comment 4 Ryosuke Niwa 2011-05-19 15:39:59 PDT
I wonder if we should also add it to AtomicString and QualifiedName.
Comment 5 Ryosuke Niwa 2011-05-19 16:11:55 PDT
Created attachment 94138 [details]
adds String::show and AtomicString::show
Comment 6 Ryosuke Niwa 2011-05-19 16:13:35 PDT
Adding it to QualifiedName is a bit tricky because we'd have to export String::show from JSC to WebCore so I'll put that aside for now.
Comment 7 Levi Weintraub 2011-05-19 16:22:29 PDT
(In reply to comment #6)
> Adding it to QualifiedName is a bit tricky because we'd have to export String::show from JSC to WebCore so I'll put that aside for now.

The following in your .gdbinit will allow you to type string_print followed by a WTF::String to print it out:

define wchar_print
        echo "

        set $i = 0
        while (1 == 1)
                set $c = (char)(($arg0)[$i++])
                if ($c == '\0')
                        loop_break
                end
                printf "%c", $c
        end

        echo "\n
end

define string_print
	wchar_print ($arg0)
end

Just sayin' ;)
Comment 8 Ryosuke Niwa 2011-05-26 14:56:57 PDT
Any reviewer?
Comment 9 Eric Seidel (no email) 2011-05-26 14:57:44 PDT
Comment on attachment 94138 [details]
adds String::show and AtomicString::show

OK.
Comment 10 Eric Seidel (no email) 2011-05-26 14:58:18 PDT
Since Darin authored many of our string classes, I figure he might like to see this go by, but it looks like you already CC'd him.  Thanks.
Comment 11 Ryosuke Niwa 2011-05-26 14:58:57 PDT
Thanks for the review!
Comment 12 Ryosuke Niwa 2011-05-26 15:09:55 PDT
We can always remove this if it turns out be redundant or useless.
Comment 13 Ryosuke Niwa 2011-05-26 15:09:59 PDT
Committed r87438: <http://trac.webkit.org/changeset/87438>