mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
Meta: Implement support for the new String in the gdb formatter
The pretty-print gdb helpers were not updated since the DeprecatedString change. This commit introduces a new printer for String and renames the old one to DeprecatedString.
This commit is contained in:
parent
259228d8d2
commit
e13b89dd20
Notes:
sideshowbarker
2024-07-17 05:03:11 +09:00
Author: https://github.com/SebastianZaha Commit: https://github.com/SerenityOS/serenity/commit/e13b89dd20 Pull-request: https://github.com/SerenityOS/serenity/pull/20370 Reviewed-by: https://github.com/LucasChollet ✅
@ -38,6 +38,8 @@ def handler_class_for_type(type, re=re.compile('^([^<]+)(<.*>)?$')):
|
||||
return AKSinglyLinkedList
|
||||
elif klass == 'AK::String':
|
||||
return AKString
|
||||
elif klass == 'AK::DeprecatedString':
|
||||
return AKDeprecatedString
|
||||
elif klass == 'AK::StringView':
|
||||
return AKStringView
|
||||
elif klass == 'AK::StringImpl':
|
||||
@ -149,6 +151,24 @@ class AKString:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
def to_string(self):
|
||||
# Using the internal structure directly is quite convoluted here because of the packing optimizations
|
||||
# of AK::String (could be a short string, a substring, or a normal string).
|
||||
# This workaround was described in the gdb bugzilla on a discussion of supporting direct method calls
|
||||
# on values: https://sourceware.org/bugzilla/show_bug.cgi?id=13326
|
||||
gdb.set_convenience_variable('_tmp', self.val.reference_value())
|
||||
string_view = gdb.parse_and_eval('$_tmp.bytes_as_string_view()')
|
||||
return AKStringView(string_view).to_string()
|
||||
|
||||
@classmethod
|
||||
def prettyprint_type(cls, type):
|
||||
return 'AK::String'
|
||||
|
||||
|
||||
class AKDeprecatedString:
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
def to_string(self):
|
||||
if int(self.val["m_impl"]["m_ptr"]) == 0:
|
||||
return '""'
|
||||
@ -158,7 +178,7 @@ class AKString:
|
||||
|
||||
@classmethod
|
||||
def prettyprint_type(cls, type):
|
||||
return 'AK::String'
|
||||
return 'AK::DeprecatedString'
|
||||
|
||||
|
||||
class AKStringView:
|
||||
|
Loading…
Reference in New Issue
Block a user