summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-16 01:14:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-16 01:14:27 +0000
commit1d5c5ea1534ed0078c4058969b7aa066279f9d30 (patch)
treeb1923aff4ad2ff95bf60ca7eabdd700176df8b03 /compile.c
parent389ea73014d8e7ed67ca289679d4aa50a375a5ef (diff)
iseq.c: show function name if possible
* iseq.c (rb_insn_operand_intern): show the name of the nearest run-time symbol if possible. * compile.c (insn_data_to_s_detail): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index a6ce631..b25edcb 100644
--- a/compile.c
+++ b/compile.c
@@ -18,6 +18,10 @@
#include "insns.inc"
#include "insns_info.inc"
+#ifdef HAVE_DLADDR
+# include <dlfcn.h>
+#endif
+
#define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
#define FIXNUM_OR(n, i) ((n)|INT2FIX(i))
@@ -5604,7 +5608,17 @@ insn_data_to_s_detail(INSN *iobj)
rb_str_cat2(str, "<ch>");
break;
case TS_FUNCPTR:
- rb_str_catf(str, "<%p>", (rb_insn_func_t)OPERAND_AT(iobj, j));
+ {
+ rb_insn_func_t func = (rb_insn_func_t)OPERAND_AT(iobj, j);
+#ifdef HAVE_DLADDR
+ Dl_info info;
+ if (dladdr(func, &info) && info.dli_sname) {
+ rb_str_cat2(str, info.dli_sname);
+ break;
+ }
+#endif
+ rb_str_catf(str, "<%p>", func);
+ }
break;
default:{
rb_raise(rb_eSyntaxError, "unknown operand type: %c", type);