@@ -36,6 +36,7 @@ static VALUE tracing = Qfalse;
36
36
static VALUE locker = Qnil ;
37
37
static VALUE post_mortem = Qfalse ;
38
38
static VALUE keep_frame_binding = Qfalse ;
39
+ static VALUE resolve_symlinks = Qtrue ;
39
40
static VALUE debug = Qfalse ;
40
41
static VALUE track_frame_args = Qfalse ;
41
42
@@ -509,6 +510,17 @@ save_call_frame(rb_event_flag_t _event, debug_context_t *debug_context, VALUE se
509
510
copy_scalar_args (debug_frame );
510
511
}
511
512
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
+
512
524
513
525
#if defined DOSISH
514
526
#define isdirsep (x ) ((x) == '/' || (x) == '\\')
@@ -517,7 +529,14 @@ save_call_frame(rb_event_flag_t _event, debug_context_t *debug_context, VALUE se
517
529
#endif
518
530
519
531
int
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 )
521
540
{
522
541
char * source_ptr , * file_ptr ;
523
542
long s_len , f_len , min_len ;
@@ -1460,6 +1479,31 @@ debug_set_keep_frame_binding(VALUE self, VALUE value)
1460
1479
return value ;
1461
1480
}
1462
1481
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
+
1463
1507
/* :nodoc: */
1464
1508
static VALUE
1465
1509
debug_debug (VALUE self )
@@ -2604,6 +2648,10 @@ Init_ruby_debug()
2604
2648
debug_keep_frame_binding , 0 );
2605
2649
rb_define_module_function (mDebugger , "keep_frame_binding=" ,
2606
2650
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 );
2607
2655
rb_define_module_function (mDebugger , "track_frame_args?" ,
2608
2656
debug_track_frame_args , 0 );
2609
2657
rb_define_module_function (mDebugger , "track_frame_args=" ,
0 commit comments