summaryrefslogtreecommitdiff
path: root/iseq.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 /iseq.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 'iseq.c')
-rw-r--r--iseq.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/iseq.c b/iseq.c
index 297299e00a..7e1ac877c1 100644
--- a/iseq.c
+++ b/iseq.c
@@ -13,6 +13,10 @@
#include "ruby/util.h"
#include "eval_intern.h"
+#ifdef HAVE_DLADDR
+# include <dlfcn.h>
+#endif
+
/* #define RUBY_MARK_FREE_DEBUG 1 */
#include "gc.h"
#include "vm_core.h"
@@ -1375,7 +1379,16 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
break;
case TS_FUNCPTR:
- ret = rb_str_new2("<funcptr>");
+ {
+#ifdef HAVE_DLADDR
+ Dl_info info;
+ if (dladdr((void *)op, &info) && info.dli_sname) {
+ ret = rb_str_new_cstr(info.dli_sname);
+ break;
+ }
+#endif
+ ret = rb_str_new2("<funcptr>");
+ }
break;
default: