[PATCH] Fix /bin/sh compilation with CFLAGS += -DDEBUG > 1

Garrett Cooper yanegomi at gmail.com
Tue Oct 12 10:47:50 UTC 2010


Hi,
    It looks like the format strings are broken on 64-bit archs in
/bin/sh's TRACE functionality (can be enabled by uncommenting -DDEBUG
> 1 in bin/sh/Makefile). The attached patch fixes this functionality
again so one can trace sh's calls with TRACE, which may or may be
helpful to those debugging /bin/sh.
    Tested build and execution on amd64; tested build on i386.
Thanks!
-Garrett

PS If someone can help review, and potentially commit this patch, it
would be much appreciated.

Tracing started.
Shell args:  "./sh" "-x"
cmdloop(1) called
showjobs(1) called
token word sleep
pipeline: entered
reread token word sleep
reread token word sleep
reread token word sleep
reread token word sleep
reread token word sleep
token word 100
token "&"
reread token "&"
reread token "&"
reread token "&"
token newline
evaltree(0x800d4b658: 1) called
evalcommand(0x800d4b658, 0) called
evalcommand arg: sleep
evalcommand arg: 100
searchexec "sleep" returns "/bin/sleep"
makejob(0x800d4b658, 1) returns %1
forkshell(%0, 0x800d4b658, 1) called
dowait(0) called
wait returns -1, status=8
Child shell 16632
normal command:  "sleep" "100"
In parent shell:  child = 16632
showjobs(1) called
dowait(0) called
wait returns 0, status=-256
token word echo
pipeline: entered
reread token word echo
reread token word echo
reread token word echo
reread token word echo
reread token word echo
token word hallo
token end of file
reread token end of file
reread token end of file
reread token end of file
token word foo=„
pipeline: entered
reread token word foo=„
reread token word foo=„
reread token word foo=„
reread token word foo=„
reread token word foo=„
token newline
reread token newline
reread token newline
reread token newline
evaltree(0x800d4b6a8: 1) called
evalcommand(0x800d4b6a8, 0) called
evalcommand(0x800d4b668, 4) called
evalcommand arg: echo
evalcommand arg: hallo
builtin command:  "echo" "hallo"
evalbackcmd done: fd=-1 buf=0x800c570c0 nleft=6 jp=0x0
expbackq: size=5: "hallo"
builtin command:  showjobs(1) called
dowait(0) called
wait returns 0, status=-256
token word jobs
pipeline: entered
reread token word jobs
reread token word jobs
reread token word jobs
reread token word jobs
reread token word jobs
token newline
reread token newline
reread token newline
reread token newline
evaltree(0x800d4b630: 1) called
evalcommand(0x800d4b630, 0) called
evalcommand arg: jobs
builtin command:  "jobs"
showjobs(0) called
dowait(0) called
wait returns 0, status=-256
showjobs(1) called
dowait(0) called
wait returns 0, status=-256
token word fg
pipeline: entered
reread token word fg
reread token word fg
reread token word fg
reread token word fg
reread token word fg
token newline
reread token newline
reread token newline
reread token newline
evaltree(0x800d4b630: 1) called
evalcommand(0x800d4b630, 0) called
evalcommand arg: fg
builtin command:  "fg"
waitforjob(%1) called
dowait(1) called
wait returns 16632, status=0
Changing status of proc 16632 from 0xffffffff to 0x0
Job 1: changing state from 0 to 2
showjobs(1) called
dowait(0) called
wait returns -1, status=0
token word exit
pipeline: entered
reread token word exit
reread token word exit
reread token word exit
reread token word exit
reread token word exit
token newline
reread token newline
reread token newline
reread token newline
evaltree(0x800d4b630: 1) called
evalcommand(0x800d4b630, 0) called
evalcommand arg: exit
builtin command:  "exit"
exitshell(0) pid=16619
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-bin-sh-DEBUG-functionality.diff
Type: application/octet-stream
Size: 2656 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20101012/f443f403/fix-bin-sh-DEBUG-functionality.obj


More information about the freebsd-hackers mailing list