Skip to content

Commit

Permalink
Add gdb "info functions"
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jun 8, 2020
1 parent 2b8f511 commit 07d8922
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 13 deletions.
5 changes: 3 additions & 2 deletions command/info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typeset -A _Dbg_command_help_info
_Dbg_help_add info '' # Help routine is elsewhere

typeset -a _Dbg_info_subcmds
_Dbg_info_subcmds=( breakpoints display files line program source stack variables )
_Dbg_info_subcmds=( breakpoints display files "function" "line" program source stack variables )

# Load in "info" subcommands
for _Dbg_file in ${_Dbg_libdir}/command/info_sub/*.sh ; do
Expand All @@ -50,13 +50,14 @@ _Dbg_do_info_internal() {
typeset label=$2

# Warranty is omitted below.
typeset subcmds='breakpoints display files line source stack variables'
typeset subcmds='breakpoints display files functions line source stack variables'

if [[ -z $info_cmd ]] ; then
typeset thing
for thing in $subcmds ; do
_Dbg_do_info $thing 1
done
set +x
return 0
elif [[ -n ${_Dbg_debugger_info_commands[$info_cmd]} ]] ; then
${_Dbg_debugger_info_commands[$info_cmd]} $label "$@"
Expand Down
1 change: 1 addition & 0 deletions command/info_sub/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pkgdatadir = ${datadir}/@PACKAGE@/command/info_sub
pkgdata_DATA = \
breakpoints.sh \
files.sh \
functions.sh \
program.sh \
variables.sh \
warranty.sh
Expand Down
44 changes: 44 additions & 0 deletions command/info_sub/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- shell-script -*-
# "info functions" debugger command
#
# Copyright (C) 2020 Rocky Bernstein [email protected]
#
# zshdb is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later
# version.
#
# zshdb is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with zshdb; see the file COPYING. If not, write to the Free Software
# Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.

_Dbg_help_add_sub info functions '
**info functions** [*string-pattern*]
List function names. If *string-pattern* is given, the results
are filtered using the shell "=" (or "==") test.
Examples:
---------
info functions # show all functions
info functions co # show all functions with "co" in the name
' 1

_Dbg_do_info_functions() {
# Remove "functions" or "xx functions"
if [[ "$1" != "functions" ]] ; then
shift
fi
if [[ "$1" == "functions" ]]; then
shift
fi
_Dbg_do_list_typeset_attr '+f' $@
return 0
}
14 changes: 7 additions & 7 deletions command/info_sub/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,39 @@ _Dbg_do_info_variables() {
return 0
;;
fu|fun|func|funct|functi|functio|function|functions )
_Dbg_do_list_typeset_attr '+f' $*
_Dbg_do_list_typeset_attr '+f' $@
return 0
;;
fi|fix|fixe|fixed )
_Dbg_do_list_typeset_attr '+F' $*
_Dbg_do_list_typeset_attr '+F' $@
return 0
;;
fl|flo|floa|float|floats)
_Dbg_do_list_typeset_attr '+E' $*
_Dbg_do_list_typeset_attr '+E' $@
return 0
;;
# g | gl | glo | glob | globa | global )
# _Dbg_do_list_globals
# return 0
# ;;
h | ha | has | hash )
_Dbg_do_list_typeset_attr '+A' $*
_Dbg_do_list_typeset_attr '+A' $@
return 0
;;
i | in | int| inte | integ | intege | integer | integers )
_Dbg_do_list_typeset_attr '+i' $*
_Dbg_do_list_typeset_attr '+i' $@
return 0
;;
# l | lo | loc | loca | local | locals )
# _Dbg_do_list_locals
# return 0
# ;;
# p | pr | pro| prop | prope | proper | propert | properti | propertie | properties )
# _Dbg_do_list_typeset_attr '+p' $*
# _Dbg_do_list_typeset_attr '+p' $@
# return 0
# ;;
r | re | rea| read | reado | readon | readonl | readonly )
_Dbg_do_list_typeset_attr '+r' $*
_Dbg_do_list_typeset_attr '+r' $@
return 0
;;
* )
Expand Down
2 changes: 1 addition & 1 deletion command/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ _Dbg_do_list_typeset_attr() {
(($# == 0)) && return 1
typeset attr="$1"; shift
typeset -a list
list=( $(_Dbg_get_typeset_attr "$attr" $*) )
list=( $(_Dbg_get_typeset_attr "$attr" $@) )
typeset -i rc=$?
(( rc != 0 )) && return $rc
_Dbg_list_columns
Expand Down
2 changes: 1 addition & 1 deletion dbg-opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ _Dbg_parse_options() {
[[ -n $_Dbg_release ]] ; then
echo "$_Dbg_shell_name debugger, $_Dbg_debugger_name, release $_Dbg_release"
printf '
Copyright 2008-2011, 2014, 2016-2019 Rocky Bernstein
Copyright 2008-2011, 2014, 2016-2020 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Expand Down
1 change: 1 addition & 0 deletions docs/commands/info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Type `info` for a list of info subcommands and what they do. Type ``help info``
info/breakpoints
info/display
info/files
info/functions
info/line
info/program
info/source
Expand Down
19 changes: 19 additions & 0 deletions docs/commands/info/functions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. index:: info; functions
.. _info_functions:

Info Variables
----------------

**info functions** [*string-pattern*]

List function names. If *string-pattern* is given, the results
are filtered using the shell `=` (or `==`) test.
list global and static variable names.

Examples:
+++++++++

::

info functions # show all functions
info functions co # show all functions with "co" in the name
9 changes: 7 additions & 2 deletions lib/info-help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# with zshdb; see the file COPYING. If not, write to the Free Software
# Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.

typeset -r _Dbg_info_cmds='breakpoints display files line program source stack variables warranty'
typeset -r _Dbg_info_cmds='breakpoints display files functions line program source stack variables warranty'

_Dbg_info_help() {

Expand Down Expand Up @@ -68,9 +68,14 @@ _Dbg_info_help() {
'info files -- Source files in the program'
return 0
;;
'fu' | fun | func | funct | functi | functio | 'function' | functions )
_Dbg_msg \
'info functions -- Functions defined in the program'
return 0
;;
l | li| lin | line )
_Dbg_msg \
'info line -- list current line number and and file name'
'info line -- List current line number and and file name'
return 0
;;
p | pr | pro | prog | progr | progra | program )
Expand Down

0 comments on commit 07d8922

Please sign in to comment.