@@ -36,6 +36,7 @@ static VALUE tracing = Qfalse;
3636static VALUE locker = Qnil ;
3737static VALUE post_mortem = Qfalse ;
3838static VALUE keep_frame_binding = Qfalse ;
39+ static VALUE resolve_symlinks = Qtrue ;
3940static VALUE debug = Qfalse ;
4041static VALUE track_frame_args = Qfalse ;
4142
@@ -509,6 +510,17 @@ save_call_frame(rb_event_flag_t _event, debug_context_t *debug_context, VALUE se
509510 copy_scalar_args (debug_frame );
510511}
511512
513+ char *
514+ resolve_symlink (char * file ) {
515+ char * result ;
516+ #ifdef PATH_MAX
517+ result = (char * )malloc (PATH_MAX );
518+ #else
519+ result = NULL ;
520+ #endif
521+ return realpath (file , result );
522+ }
523+
512524
513525#if defined DOSISH
514526#define isdirsep (x ) ((x) == '/' || (x) == '\\')
@@ -517,7 +529,14 @@ save_call_frame(rb_event_flag_t _event, debug_context_t *debug_context, VALUE se
517529#endif
518530
519531int
520- filename_cmp (VALUE source , char * file )
532+ filename_cmp (VALUE source , char * file ) {
533+ char * path ;
534+ path = RTEST (resolve_symlinks ) ? resolve_symlink (file ) : file ;
535+ return filename_cmp_impl (source , path );
536+ }
537+
538+ int
539+ filename_cmp_impl (VALUE source , char * file )
521540{
522541 char * source_ptr , * file_ptr ;
523542 long s_len , f_len , min_len ;
@@ -1460,6 +1479,31 @@ debug_set_keep_frame_binding(VALUE self, VALUE value)
14601479 return value ;
14611480}
14621481
1482+ /*
1483+ * call-seq:
1484+ * Debugger.resolve_symlinks? -> bool
1485+ *
1486+ * Returns +true+ if the debugger will resolve symlinks when checking breakpoint.
1487+ */
1488+ static VALUE
1489+ debug_resolve_symlinks (VALUE self )
1490+ {
1491+ return resolve_symlinks ;
1492+ }
1493+
1494+ /*
1495+ * call-seq:
1496+ * Debugger.resolve_symlinks = bool
1497+ *
1498+ * Setting to +true+ will make the debugger resolve symlinks when checking breakpoint.
1499+ */
1500+ static VALUE
1501+ debug_set_resolve_symlinks (VALUE self , VALUE value )
1502+ {
1503+ resolve_symlinks = RTEST (value ) ? Qtrue : Qfalse ;
1504+ return value ;
1505+ }
1506+
14631507/* :nodoc: */
14641508static VALUE
14651509debug_debug (VALUE self )
@@ -2604,6 +2648,10 @@ Init_ruby_debug()
26042648 debug_keep_frame_binding , 0 );
26052649 rb_define_module_function (mDebugger , "keep_frame_binding=" ,
26062650 debug_set_keep_frame_binding , 1 );
2651+ rb_define_module_function (mDebugger , "resolve_symlinks?" ,
2652+ debug_resolve_symlinks , 0 );
2653+ rb_define_module_function (mDebugger , "resolve_symlinks=" ,
2654+ debug_set_resolve_symlinks , 1 );
26072655 rb_define_module_function (mDebugger , "track_frame_args?" ,
26082656 debug_track_frame_args , 0 );
26092657 rb_define_module_function (mDebugger , "track_frame_args=" ,
0 commit comments