summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-24 23:37:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-24 23:38:27 +0900
commit8439caab0ac91aa33176060bb81cb4197ab21069 (patch)
tree5fd0ddd3f6ec03160a498778248eedd77c19242b /misc
parentdc44ab2913719a7d9b78012f277b9fe02868c172 (diff)
downloadruby-8439caab0ac91aa33176060bb81cb4197ab21069.tar.gz
Refined `rp` output [ci skip]
So that the result structure can be accessed as `$number` variables, not a mere `VALUE`.
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/lldb_cruby.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py
index 619f97d646..93663b28dd 100755
--- a/misc/lldb_cruby.py
+++ b/misc/lldb_cruby.py
@@ -111,30 +111,30 @@ def lldb_inspect(debugger, target, result, val):
tRBasic = target.FindFirstType("struct RBasic").GetPointerType()
val = val.Cast(tRBasic)
flags = val.GetValueForExpressionPath("->flags").GetValueAsUnsigned()
+ flaginfo = ""
if (flags & RUBY_FL_PROMOTED) == RUBY_FL_PROMOTED:
- print("[PROMOTED] ", file=result)
+ flaginfo += "[PROMOTED] "
if (flags & RUBY_FL_FREEZE) == RUBY_FL_FREEZE:
- print("[FROZEN] ", file=result)
+ flaginfo += "[FROZEN] "
flType = flags & RUBY_T_MASK
if flType == RUBY_T_NONE:
- print('T_NONE: %s' % val.Dereference(), file=result)
+ print('T_NONE: %s%s' % (flaginfo, val.Dereference()), file=result)
elif flType == RUBY_T_NIL:
- print('T_NIL: %s' % val.Dereference(), file=result)
+ print('T_NIL: %s%s' % (flaginfo, val.Dereference()), file=result)
elif flType == RUBY_T_OBJECT:
- tRObject = target.FindFirstType("struct RObject").GetPointerType()
- val = val.Cast(tRObject)
- print('T_OBJECT: %s' % val.Dereference(), file=result)
+ result.write('T_OBJECT: %s' % flaginfo)
+ append_command_output(debugger, "print *(struct RObject*)%0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_CLASS or flType == RUBY_T_MODULE or flType == RUBY_T_ICLASS:
- tRClass = target.FindFirstType("struct RClass").GetPointerType()
- val = val.Cast(tRClass)
- print('T_%s: %s' % ('CLASS' if flType == RUBY_T_CLASS else 'MODULE' if flType == RUBY_T_MODULE else 'ICLASS', val.Dereference()), file=result)
+ result.write('T_%s: %s' % ('CLASS' if flType == RUBY_T_CLASS else 'MODULE' if flType == RUBY_T_MODULE else 'ICLASS', flaginfo))
+ append_command_output(debugger, "print *(struct RClass*)%0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_STRING:
+ result.write('T_STRING: %s' % flaginfo)
tRString = target.FindFirstType("struct RString").GetPointerType()
ptr, len = string2cstr(val.Cast(tRString))
append_command_output(debugger, "print *(const char (*)[%d])%0#x" % (len, ptr), result)
elif flType == RUBY_T_SYMBOL:
- tRSymbol = target.FindFirstType("struct RSymbol").GetPointerType()
- print(val.Cast(tRSymbol).Dereference(), file=result)
+ result.write('T_SYMBOL: %s' % flaginfo)
+ append_command_output(debugger, "print *(struct RSymbol*)%0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_ARRAY:
tRArray = target.FindFirstType("struct RArray").GetPointerType()
val = val.Cast(tRArray)
@@ -145,7 +145,7 @@ def lldb_inspect(debugger, target, result, val):
len = val.GetValueForExpressionPath("->as.heap.len").GetValueAsSigned()
ptr = val.GetValueForExpressionPath("->as.heap.ptr")
#print(val.GetValueForExpressionPath("->as.heap"), file=result)
- result.write("T_ARRAY: len=%d" % len)
+ result.write("T_ARRAY: %slen=%d" % (flaginfo, len))
if flags & RUBY_FL_USER1:
result.write(" (embed)")
elif flags & RUBY_FL_USER2:
@@ -155,11 +155,12 @@ def lldb_inspect(debugger, target, result, val):
capa = val.GetValueForExpressionPath("->as.heap.aux.capa").GetValueAsSigned()
result.write(" (ownership) capa=%d" % capa)
if len == 0:
- result.write(" {(empty)}")
+ result.write(" {(empty)}\n")
else:
result.write("\n")
append_command_output(debugger, "expression -Z %d -fx -- (const VALUE*)%0#x" % (len, ptr.GetValueAsUnsigned()), result)
elif flType == RUBY_T_HASH:
+ result.write("T_HASH: %s" % flaginfo)
append_command_output(debugger, "p *(struct RHash *) %0#x" % val.GetValueAsUnsigned(), result)
elif flType == RUBY_T_BIGNUM:
tRBignum = target.FindFirstType("struct RBignum").GetPointerType()