From 545e01645f7350c255f79b90f184a1317d3d55fb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 28 Sep 2021 19:55:07 +0900 Subject: [PATCH] lldb: Show encoding of String [ci skip] --- common.mk | 1 + debug.c | 2 ++ misc/lldb_cruby.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/common.mk b/common.mk index ddc34dd94f..3940280ca8 100644 --- a/common.mk +++ b/common.mk @@ -3457,6 +3457,7 @@ debug.$(OBJEXT): {$(VPATH)}config.h debug.$(OBJEXT): {$(VPATH)}debug.c debug.$(OBJEXT): {$(VPATH)}debug_counter.h debug.$(OBJEXT): {$(VPATH)}defines.h +debug.$(OBJEXT): {$(VPATH)}encindex.h debug.$(OBJEXT): {$(VPATH)}encoding.h debug.$(OBJEXT): {$(VPATH)}eval_intern.h debug.$(OBJEXT): {$(VPATH)}gc.h diff --git a/debug.c b/debug.c index 3b4f1cbb12..52bd0f7fb7 100644 --- a/debug.c +++ b/debug.c @@ -14,6 +14,7 @@ #include #include "eval_intern.h" +#include "encindex.h" #include "id.h" #include "internal/signal.h" #include "ruby/encoding.h" @@ -50,6 +51,7 @@ const union { enum ruby_coderange_type enc_coderange_types; enum ruby_econv_flag_type econv_flag_types; rb_econv_result_t econv_result; + enum ruby_preserved_encindex encoding_index; enum ruby_robject_flags robject_flags; enum ruby_robject_consts robject_consts; enum ruby_rmodule_flags rmodule_flags; diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index 8461eea8b3..c7a25984ae 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -287,6 +287,8 @@ def lldb_inspect(debugger, target, result, val): append_command_output(debugger, "print *(struct RClass*)%0#x" % val.GetValueAsUnsigned(), result) elif flType == RUBY_T_STRING: result.write('T_STRING: %s' % flaginfo) + encidx = ((flags & RUBY_ENCODING_MASK)>>RUBY_ENCODING_SHIFT) + result.write('[%s] ' % target.FindFirstType("enum ruby_preserved_encindex").GetEnumMembers().GetTypeEnumMemberAtIndex(encidx).GetName()[14:]) tRString = target.FindFirstType("struct RString").GetPointerType() ptr, len = string2cstr(val.Cast(tRString)) if len == 0: