Menu

#90 tkdiff -d suggested improvements

V5.5.2
closed-wont-fix
None
5
2022-09-10
2022-09-01
Duncan Roe
No

When researching for my previous 2 reports, I thought it would be useful to see the shell command that runcmd was called to do. So I patched in a Dbg:

@@ -1053,6 +1053,7 @@
 ###############################################################################
 proc run-command {cmd {out {}}} {
     global ASYNc errorCode
+    Dbg "runcmd cmd=$cmd; out=$out"

     # Arrange for requested output format (given execution constraints)
     #  N.B> 'fout' will become one of: a channel, a cmd indirection, or empty.

But this made tkiff crash:

13:51:10$ tkdiff -d -v184
Dbg: Running TkDiff 5.5.2
Dbg:  0 filespecs, 1-0 revisions
Dbg:  Recovered 0 filespecs, 1 revisions
Dbg:  PAIRing SCM(/) Fspec(0) Rev(1) Tchk()
Dbg: Posted ASYNc(trigger)(after#0)
Dbg: runcmd cmd=svn diff --summarize -r 184; out=
Dbg: temp file /usr/tmp/23991-cmderr-1
Dbg: Cmd running in ASYNC mode
Dbg: Back from ASYNC cmd: rc(0)
Dbg: temp file /usr/tmp/23991-scm1-2
Dbg: scm-chkget (1) -> 'svn cat -r 184 "CHANGELOG.txt"': /usr/tmp/23991-scm1-2
Error in startup script: extra characters after close-quote
    while executing
"set na "runcmd cmd=svn cat -r 184 "C"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 set na "\"$message\"""
    (procedure "Dbg" line 5)
    invoked from within
"Dbg "runcmd cmd=$cmd; out=$out""
    (procedure "run-command" line 3)
    invoked from within
"run-command "$finfo(${A}tmp,$ndx)" "$finfo(${A}pth,$ndx)""
    (procedure "scm-chkget" line 14)
    invoked from within
"scm-chkget ${A}$ndx"
    (procedure "get-file-rev" line 206)
    invoked from within
"get-file-rev $file $cnt $rev($i) SVN"
    (procedure "inquire-svn" line 84)
    invoked from within
"inquire-svn $revs"
    (procedure "assemble-args" line 153)
    invoked from within
"assemble-args"
    (procedure "main" line 72)
    invoked from within
"main"

When I looked int Dbg {} itself, I found it was doing an uplevel with the debug data in double-quotes. I changed these to braces:

@@ -65,7 +65,7 @@
     global g

     if {$force >= 0 && ($g(debug) || $force)} {
-        puts $where "$hdr[uplevel 1 set na "\"$message\""]"
+        puts $where "$hdr[uplevel 1 set na "\{$message\}"]"
     }
 }

This cleared the crash:

14:00:56$ tkdiff -d -v184
Dbg: Running TkDiff 5.5.2
Dbg:  0 filespecs, 1-0 revisions
Dbg:  Recovered 0 filespecs, 1 revisions
Dbg:  PAIRing SCM(/) Fspec(0) Rev(1) Tchk()
Dbg: Posted ASYNc(trigger)(after#0)
Dbg: runcmd cmd=svn diff --summarize -r 184; out=
Dbg: temp file $fnam
Dbg: Cmd running in ASYNC mode
Dbg: Back from ASYNC cmd: rc(0)
Dbg: temp file $fnam
Dbg: scm-chkget ($ndx) -> '$finfo(${A}tmp,$ndx)': $finfo(${A}pth,$ndx)
Dbg: runcmd cmd=svn cat -r 184 "CHANGELOG.txt"; out=/usr/tmp/24912-scm1-2
Dbg: temp file $fnam
Dbg: Cmd running in ASYNC mode
Dbg: Back from ASYNC cmd: rc(0)
Dbg: Final: 1 revs  0 filespecs -> 6/2 pairings  0 Err
Dbg: ASYNC mode has been dropped
Dbg:  Assigning labels to headers
Dbg: PROPOSED wm grid is WxH($GW(1)x$GH(1)) of WxH($GcW(1)x$GcH(1))pxls\n \twhile PREVsz was WxH($GW(0)x$GH(0))       ($GcW(0)x$GcH(0))
Dbg: Trim BOTH L/R to NEW computed width($GW(1)) - and detach gridding
Dbg:   NEW   wm grid is ($GW($i) X $GH($i))   ($GcW(1) x $GcH(1))
Dbg: centering(${wWidth}x$wHeight) onto parent(${pWidth}x$pHeight)
Dbg: Centering has targeted at $ctr above parent @($pX,$pY)
Dbg: Custom code IS in use...beware
Dbg: is3way(0)
Dbg: MergeFileSet(0): /usr/src/tkdiff/CHANGELOG-merge.txt
Dbg: runcmd cmd=diff /usr/tmp/24912-scm1-2 CHANGELOG.txt; out=
Dbg: temp file $fnam
Dbg: DIFF([llength $g(DIFF)]) .vs. diff([llength $g(diff)])
Dbg: Left  ancestral datums: [llength $g(d3Left)]

I then noticed lots of Dbg calls with the argument in braces, leading to output like temp file $fnam above. So I patched all such Dbg calls to use double quotes giving:

14:09:47$ tkdiff -d -v184
Dbg: Running TkDiff 5.5.2
Dbg:  0 filespecs, 1-0 revisions
Dbg:  Recovered 0 filespecs, 1 revisions
Dbg:  PAIRing SCM(/) Fspec(0) Rev(1) Tchk()
Dbg: Posted ASYNc(trigger)(after#0)
Dbg: runcmd cmd=svn diff --summarize -r 184; out=
Dbg: temp file /usr/tmp/25721-cmderr-1
Dbg: Cmd running in ASYNC mode
Dbg: Back from ASYNC cmd: rc(0)
Dbg: temp file /usr/tmp/25721-scm1-2
Dbg: scm-chkget (1) -> 'svn cat -r 184 "CHANGELOG.txt"': /usr/tmp/25721-scm1-2
Dbg: runcmd cmd=svn cat -r 184 "CHANGELOG.txt"; out=/usr/tmp/25721-scm1-2
Dbg: temp file /usr/tmp/25721-cmderr-3
Dbg: Cmd running in ASYNC mode
Dbg: Back from ASYNC cmd: rc(0)
Dbg: Final: 1 revs  0 filespecs -> 6/2 pairings  0 Err
Dbg: ASYNC mode has been dropped
Dbg:  Assigning labels to headers
Dbg: PROPOSED wm grid is WxH(80x30) of WxH(8x15)pxls
        while PREVsz was WxH(x)       (x)
Dbg: Trim BOTH L/R to NEW computed width(80) - and detach gridding
Dbg:   NEW   wm grid is (160 X 30)   (8 x 15)
Dbg: centering(724x442) onto parent(1628x588)
Dbg: Centering has targeted at =+1102+920 above parent @(650,847)
Dbg: Custom code IS in use...beware
Dbg: is3way(0)
Dbg: MergeFileSet(0): /usr/src/tkdiff/CHANGELOG-merge.txt
Dbg: runcmd cmd=diff /usr/tmp/25721-scm1-2 CHANGELOG.txt; out=
Dbg: temp file /usr/tmp/25721-cmderr-4
Dbg: DIFF(1) .vs. diff(1)
Dbg: Left  ancestral datums: 0
Dbg: Right ancestral datums: 0

The 2 patches are attached. I hope you see fit to apply them.

BTW, there isn't any custom code

2 Attachments

Discussion

  • Duncan Roe

    Duncan Roe - 2022-09-02

    Scrub this: I should have used braces:

    @@ -1053,6 +1053,7 @@
     ###############################################################################
     proc run-command {cmd {out {}}} {
         global ASYNc errorCode
    +    Dbg {runcmd cmd=$cmd; out=$out}
    
         # Arrange for requested output format (given execution constraints)
         #  N.B> 'fout' will become one of: a channel, a cmd indirection, or empty.
    

    A bit counter-intuitive perhaps, but it works.
    Also @vampm emailed me this:

    FYI - there is another way you COULD have watched what "run-command" (or most any OTHER Proc) was passed as args, using an undocumented extension of the "-d" commandline flag...

    While the flag itself is enough to ACTIVATE all uses of "Dbg", there is a way to ENCODE specific PROCS to further respond by reporting their being invoked and INCLUDING their arguments:

    This is done by APPENDING either a "w" or "p" TO the commandline flag and concatenating the SPECIFIC procname you are interested in seeing. Such supplied procname can even be a Regular expression if desired. Naturally, this commandline arg can be repeated as necessary to enumerate ALL such procs you want "announced" during execution. The distinction of "w/p" simply identifies if the procname in question is a "w"idget proc or not (you CAN request either). If you leave OFF the actual NAME you get everything from the "p/w" category (a LOT of output)!

    Thus "-dprun-command" would have yielded the debugging you were looking for, without modifying anything in the script itself.

    All this happens during script LOAD time and thus permits the TCL runtime compiler to convert everything to bytecode for maximum performance. However, only those Procs that are defined AFTER a particular point in the overall script can be interrogated - thus there is a "linear ordering" requirement when introducing NEW procs regarding their participation in this particular mechanism.

     
  • Duncan Roe

    Duncan Roe - 2022-09-04

    @vampm also explained that by having Dbg take an arg in braces, the interpreter doesn't need to expand the arg when debugging is off. Neat.

     

    Last edit: Duncan Roe 2022-09-04
  • michael-m

    michael-m - 2022-09-10
    • status: open --> closed-wont-fix
    • assigned_to: michael-m
     
  • michael-m

    michael-m - 2022-09-10

    Unneeded. Ability exists via alternate methods.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.