-C options do not work for code evaluation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

I run this command:

git log --graph --decorate --pretty=oneline --abbrev-commit --color-moved -C -L 534,545:lib/DB/Hooks.pm

at some point of evalutation I see:

http://joxi.net/Y2L4GQ0in480l2

* e348241 Wrap whole DB::DB into &dbcall by moving DB::db into DB::interact
| 
| diff --git a/lib/DB/Hooks.pm b/lib/DB/Hooks.pm
| --- a/lib/DB/Hooks.pm
| +++ b/lib/DB/Hooks.pm
| @@ -528,5 +528,12 @@
| -  dbcall \&emit, 'btrap', $source, $f, $l;
| -  dbcall \&emit, 'interact';
| -  dbcall \&emit, 'atrap';
| +sub db {
| +  my $dd =  DB::new   if DB::state( 'dbcall' );
| +  DB::start_dd   if $DB::DB  ||  DB::state( 'dbcall' );
| +  local $DB::DB =  1;
| +
| +  &save_context;
| +  my $dbg =  DB::new \&restore_context;
| +
| +  my( undef, $f, $l ) =  caller(1);
| +  dbcall \&interact, $f, $l;
|  }
|  


When I look at commit e348241 I can see that code is moved:
http://joxi.net/eAOMjW1I4W7LBm

commit e348241bfb9ba563c82d28c05d3f45ab9c1a765d
Author: Eugen Konkov <kes-kes@xxxxxxxxx>
Date:   Fri Jan 5 15:58:17 2018 +0200

    Wrap whole DB::DB into &dbcall by moving DB::db into DB::interact
    
    This allow us to not wrap each &emit call into &dbcall

diff --git a/lib/DB/Hooks.pm b/lib/DB/Hooks.pm
index 6ade20a..dabe701 100644
--- a/lib/DB/Hooks.pm
+++ b/lib/DB/Hooks.pm
@@ -490,23 +490,16 @@ sub goto {
 }
 
 
-sub db {
-    my $dd =  DB::new   if DB::state( 'dbcall' );
-    DB::start_dd   if $DB::DB  ||  DB::state( 'dbcall' );
-    local $DB::DB =  1;
 
-    &save_context;
-    my $dbg =  DB::new \&restore_context;
-
-
-    my( undef, $f, $l ) =  caller(1);
+sub interact {
+    my( $f, $l ) =  @_;
 
     my $source =  DB::source( $f )->[ $l ]; chomp $source;
-    dbcall \&emit, 'trace', $source, $f, $l   if $DB::trace;
+    emit( 'trace', $source, $f, $l )   if $DB::trace;
 ... #<<<<I remove part of patch to minify text
@@ -525,9 +518,23 @@ sub db {
 
 
 
-    dbcall \&emit, 'btrap', $source, $f, $l;
-    dbcall \&emit, 'interact';
-    dbcall \&emit, 'atrap';
+    emit( 'btrap', $source, $f, $l );
+    emit( 'interact' );
+    emit( 'atrap' );
+}
+
+
+
+sub db {
+    my $dd =  DB::new   if DB::state( 'dbcall' );
+    DB::start_dd   if $DB::DB  ||  DB::state( 'dbcall' );
+    local $DB::DB =  1;
+
+    &save_context;
+    my $dbg =  DB::new \&restore_context;
+
+    my( undef, $f, $l ) =  caller(1);
+    dbcall \&interact, $f, $l;
 }
 


To workaround this problem I run:
git log --graph --decorate --pretty=oneline --abbrev-commit --color-moved -C -L 492,505:lib/DB/Hooks.pm e348241b
http://joxi.ru/vAWMwOZIkNy7Rm
* e348241 Wrap whole DB::DB into &dbcall by moving DB::db into DB::interact
| 
| diff --git a/lib/DB/Hooks.pm b/lib/DB/Hooks.pm
| --- a/lib/DB/Hooks.pm
| +++ b/lib/DB/Hooks.pm
| @@ -492,21 +492,14 @@
|  
| -sub db {
| -  my $dd =  DB::new   if DB::state( 'dbcall' );
| -  DB::start_dd   if $DB::DB  ||  DB::state( 'dbcall' );
| -  local $DB::DB =  1;
|  
| -  &save_context;
| -  my $dbg =  DB::new \&restore_context;
| -
| -
| -  my( undef, $f, $l ) =  caller(1);
| +sub interact {
| +  my( $f, $l ) =  @_;
|  
|    my $source =  DB::source( $f )->[ $l ]; chomp $source;
| -  dbcall \&emit, 'trace', $source, $f, $l   if $DB::trace;
| +  emit( 'trace', $source, $f, $l )   if $DB::trace;
|  
|    my @trap;
|    if( my $info =  DB::traps( $f )->{ $l } ) {
| -      @trap =  dbcall \&emit, 'trap', $info, $f, $l;
| +      @trap =  emit( 'trap', $info, $f, $l );
|        # Stop unconditionally if there is no subscribers for the event
|        @trap =  (1)   unless @trap;
|    }
* 30c07c0 If we come from { dbcall } start debugger debugging too
| 
| diff --git a/lib/DB/Hooks.pm b/lib/DB/Hooks.pm
| --- a/lib/DB/Hooks.pm
| +++ b/lib/DB/Hooks.pm
| @@ -489,20 +489,21 @@
|  
|  sub db {
| -  DB::start_dd   if $DB::DB;
| +  my $dd =  DB::new   if DB::state( 'dbcall' );
| +  DB::start_dd   if $DB::DB  ||  DB::state( 'dbcall' );
|    local $DB::DB =  1;
|  
|    &save_context;
|    my $dbg =  DB::new \&restore_context;
|  
|  
|    my( undef, $f, $l ) =  caller(1);
|  
|    my $source =  DB::source( $f )->[ $l ]; chomp $source;
|    dbcall \&emit, 'trace', $source, $f, $l   if $DB::trace;
|  
|    my @trap;
|    if( my $info =  DB::traps( $f )->{ $l } ) {
|        @trap =  dbcall \&emit, 'trap', $info, $f, $l;
|        # Stop unconditionally if there is no subscribers for the event
|        @trap =  (1)   unless @trap;
|    }


1. In the example above moved code is not displayed as moved. It seems the whole 
changeset (commit) is not inspected despite on the `-C` option is supplied

2. Please provide an option which will allow to follow moved code (maybe this should be done by default,
because 71% (77%) of code in interested block is moved and not changed)

| @@ -528,5 +528,12 @@
| -  dbcall \&emit, 'btrap', $source, $f, $l;
| -  dbcall \&emit, 'interact';
| -  dbcall \&emit, 'atrap';
| +sub db {
| +  my $dd =  DB::new   if DB::state( 'dbcall' );
| +  DB::start_dd   if $DB::DB  ||  DB::state( 'dbcall' );
| +  local $DB::DB =  1;
| +
| +  &save_context;
| +  my $dbg =  DB::new \&restore_context;
| +
| +  my( undef, $f, $l ) =  caller(1);
| +  dbcall \&interact, $f, $l;
|  }

Maybe supply interactive mode which will suggest where to follow

Thank you



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux