1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Refined rp output [ci skip]

So that the result structure can be accessed as `$number`
variables, not a mere `VALUE`.
This commit is contained in:
Nobuyoshi Nakada 2019-10-24 23:37:19 +09:00
parent dc44ab2913
commit 8439caab0a
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -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()