the attached text is how it looks like since newly

On Wed, Feb 2, 2022 at 3:35 PM L A Walsh <b...@tlinx.org> wrote:
>
> I was trying to find parameters to a function that gave an error, so
> I 'turned on' (included my backtracing routine), which showed:
>
> ./24bc: line 46: printf: `txt=\nRed,': not a valid identifier
> STOPPING execution @ "printf ${_:+-v $_} '\x1b[48;2;%s;%s;%sm' $1 $2 $3"
> in "setBgColor()" at ./24bc #46
>   called in setBackBlack() at ./24bc #56
>   called in title() at ./24bc #74
>   called in main() at ./24bc #81
>
> ----
> I was all, 'rats, its not showing the params', I wondered why and looked
> at the code,
> and realized that while I can backtrace function, source line+file, I didn't
> know how to display the params that were used when the function was called.
>
> Is there, or maybe 'can there', be a BASH var like
> FUNCPARMS[1]="(P1 P2 P3)"
>
> Of course it would be handy if bash could parse this w/o using an
> intermediate var:
>
> echo "${${FUNCPARMS[@]}[1]}"   =>
>    #  (tmp=${FUNCPARMS[@]}   tmp=(P1 P2 P3) )
>    #  echo "${tmp[1]}"
> P1
>
> ---
> But even without the enhanced parsing output, it would still
> be useful if bash had & filled in the param vars.
>
> FUNCPARMS would parallel 'FUNCNAME', i.e.
> FUNCPARMS[1] would hold the quoted array "()" PARMS for FUNCNAME[1].
>
> FWIW, my primitive backtrace function (source or "include")  follows:
>
> ----
> #!/bin/bash -u
>
> shopt -s expand_aliases
> alias my='declare ' int='my -i '
>
> backtrace () {
>   trap  ERR
>   int   level=0
>   my    cmd fn src ln
>   int   iter=0
>   while {
>       cmd=$BASH_COMMAND; fn=${FUNCNAME[level+1]:-}
>       src=${BASH_SOURCE[level+1]:-} ln=${BASH_LINENO[level]:-}
>   }; do
>     [[ $fn && $src && $ln ]] && {
>       if ((iter++==0)); then
>         printf 'STOPPING execution @ "%s" in "%s()" at %s #%s\n' "$cmd"
> "$fn" "$src" "$ln"
>       else
>         printf '  called in %s() at %s #%s\n' "$fn"  "$src" "$ln"
>       fi
>       level+=1
>       continue;
>     }
>     exit 1
>   done
> }
> set -o errtrace
> trap backtrace ERR
> trap backtrace QUIT
> set -E
>
>
>
gdb /bin/bash
GNU gdb (Debian 10.1-2) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /bin/bash...
(gdb) r
Starting program: /bin/bash 
[Detaching after fork from child process 19238]
[Detaching after fork from child process 19239]
[Detaching after fork from child process 19241]
[Detaching after fork from child process 19247]
[Detaching after fork from child process 19248]
[Detaching after fork from child process 19250]
[Detaching after fork from child process 19252]
[Detaching after fork from child process 19258]
[Detaching after fork from child process 19259]
[Detaching after fork from child process 19261]
[Detaching after fork from child process 19263]
[Detaching after fork from child process 19269]
[Detaching after fork from child process 19270]
[Detaching after fork from child process 19272]
[Detaching after fork from child process 19273]
[Detaching after fork from child process 19274]
[Detaching after fork from child process 19275]
0 exit 0s old @1643813132.626878 == Wed Feb 2022-02-02 15:45:32.626878 +0100
# root:0:0 # @ /dev/pts/4 ( 0 ) boost -> /root
apt_update.log neovide/ .bash .viminfo .profile .bashrc .lesshst apt_update* 
maint/ CandyCrush.app/ .wget-hsts .ssh/ xbl.tgz .bash_history code/ work/ a 
.bumblebee/ bash/ bash../ 7/ .xbl/ 7e/ .vim/ bashgawkdebiandocs/ 7e./ 7./ 
.xmbash2 .xmbash xbl5e/ xbl5/ xbl5e.293370402/ xbl5.3623237236/ xmbdocs/ 
xmbdocs.tgz ikhxc@ xbl5.tgz bl5/ bl5e/ bl5.tgz bash2/ .vimrc desk@

Program received signal SIGTERM, Terminated.
pselect64_syscall (sigmask=0x555555690000 <_rl_orig_sigset>, timeout=<optimized 
out>, 
    exceptfds=0x0, writefds=0x0, readfds=0x7fffffffd8d0, nfds=1)
    at ../sysdeps/unix/sysv/linux/pselect.c:35
35      ../sysdeps/unix/sysv/linux/pselect.c: No such file or directory.
(gdb) bt
#0  pselect64_syscall (sigmask=0x555555690000 <_rl_orig_sigset>, 
timeout=<optimized out>, 
    exceptfds=0x0, writefds=0x0, readfds=0x7fffffffd8d0, nfds=1)
    at ../sysdeps/unix/sysv/linux/pselect.c:35
#1  __pselect (nfds=1, readfds=readfds@entry=0x7fffffffd8d0, 
writefds=writefds@entry=0x0, 
    exceptfds=exceptfds@entry=0x0, timeout=<optimized out>, timeout@entry=0x0, 
    sigmask=0x555555690000 <_rl_orig_sigset>) at 
../sysdeps/unix/sysv/linux/pselect.c:57
#2  0x00005555556333ef in rl_getc (stream=0x7ffff7f7ea80 <_IO_2_1_stdin_>) at 
input.c:548
#3  0x0000555555633d05 in rl_read_key () at input.c:514
#4  0x0000555555617962 in readline_internal_char () at readline.c:586
#5  0x00005555556182c5 in readline_internal_charloop () at readline.c:694
#6  readline_internal () at readline.c:706
#7  readline (prompt=<optimized out>) at readline.c:385
#8  0x00005555555873fe in yy_readline_get () at 
/Users/chet/src/bash/src/parse.y:1488
#9  0x0000555555589950 in yy_getc () at /Users/chet/src/bash/src/parse.y:1422
#10 shell_getc (remove_quoted_newline=remove_quoted_newline@entry=1)
    at /Users/chet/src/bash/src/parse.y:2358
#11 0x000055555558ce6c in read_token (command=0) at 
/Users/chet/src/bash/src/parse.y:3290
#12 0x0000555555590d71 in yylex () at /Users/chet/src/bash/src/parse.y:2797
#13 yyparse () at y.tab.c:1835
#14 0x0000555555586516 in parse_command () at eval.c:347
#15 0x00005555555866b4 in read_command () at eval.c:391
#16 0x00005555555868c8 in reader_loop () at eval.c:138
#17 0x0000555555585450 in main (argc=1, argv=0x7fffffffec68, env=0x7fffffffec78)
    at shell.c:811
(gdb) 

Reply via email to