Skip to content

Commit

Permalink
Update debug printers for Arc.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Sep 26, 2023
1 parent 94992cc commit b580dd3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/etc/gdb_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@ def __init__(self, valobj, is_atomic=False):
self.ptr = unwrap_unique_or_non_null(valobj["ptr"])
self.value = self.ptr["data" if is_atomic else "value"]
self.strong = self.ptr["strong"]["v" if is_atomic else "value"]["value"]
self.weak = self.ptr["weak"]["v" if is_atomic else "value"]["value"] - 1
self.weak = self.ptr["weak"]["v" if is_atomic else "value"]["value"]
if is_atomic:
if self.weak % 2 == 1:
self.weak = 0
elif self.weak > 0:
self.weak >>= 1
self.weak -= 1
self.strong >>= 2
else:
self.weak -= 1

def to_string(self):
if self.is_atomic:
Expand Down
13 changes: 12 additions & 1 deletion src/etc/lldb_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ def __init__(self, valobj, dict, is_atomic=False):

self.value_builder = ValueBuilder(valobj)

self.is_atomic = is_atomic

self.update()

def num_children(self):
Expand Down Expand Up @@ -641,7 +643,16 @@ def get_child_at_index(self, index):
def update(self):
# type: () -> None
self.strong_count = self.strong.GetValueAsUnsigned()
self.weak_count = self.weak.GetValueAsUnsigned() - 1
self.weak_count = self.weak.GetValueAsUnsigned()
if self.is_atomic:
if self.weak_count % 2 == 1:
self.weak_count = 0
elif self.weak_count > 0:
self.weak_count >>= 1
self.weak_count -= 1
self.strong_count >>= 2
else:
self.weak_count -= 1

def has_children(self):
# type: () -> bool
Expand Down

0 comments on commit b580dd3

Please sign in to comment.