DLL dependency listing utility for MinGW applications
Revision | a80f93b3ab073007b892bb0bda22695031a3ab49 (tree) |
---|---|
Time | 2020-09-06 18:43:32 |
Author | Keith Marshall <keith@user...> |
Commiter | Keith Marshall |
Diagnose missing files at top level.
* mingw32-ldd.sh (show_depends): Rename original function...
(plot_depends): ...as this; use it in reimplementation, as new, of...
(show_depends): ...this; add diagnostics to report missing files.
(CMD): New script variable; define, and use it in diagnostics...
(usage, show_depends): ...in each of these.
(STATUS): New variable.
@@ -32,11 +32,12 @@ | ||
32 | 32 | # DEALINGS IN THE SOFTWARE. |
33 | 33 | # |
34 | 34 | # |
35 | - usage(){ echo >&2 "Usage: `basename $0` {EXENAME | DLLNAME} ..."; echo; } | |
35 | + CMD=`basename $0` | |
36 | + usage(){ echo >&2 "Usage: $CMD {EXENAME | DLLNAME} ..."; STATUS=2; echo; } | |
36 | 37 | # |
37 | 38 | PROGRAM_FILES="$SYSTEM_DRIVE/program files" |
38 | 39 | SYSTEM_DLLPATH="$SYSTEM_DRIVE/windows/system32" |
39 | - EXEPATH=`dirname "$1"` | |
40 | + EXEPATH=`dirname "$1"` STATUS=0 | |
40 | 41 | # |
41 | 42 | set_dllpath(){ |
42 | 43 | # Usage: set_dllpath "colon:separated:path:list" |
@@ -73,8 +74,8 @@ | ||
73 | 74 | objdump -x "$1" | awk 'BEGIN{IGNORECASE=1}/dll name/{print $NF}' |
74 | 75 | } |
75 | 76 | # |
76 | - show_depends(){ | |
77 | - # Usage: show_depends {EXENAME | DLLNAME} [count] [prefix] | |
77 | + plot_depends(){ | |
78 | + # Usage: plot_depends {EXENAME | DLLNAME} [count] [prefix] | |
78 | 79 | # |
79 | 80 | # Recursively plot the DLL dependency graph for the executable or |
80 | 81 | # dynamic link library file named by EXENAME or DLLNAME; the count |
@@ -88,11 +89,11 @@ | ||
88 | 89 | local ref count references="`depends $1`" |
89 | 90 | for ref in $references |
90 | 91 | do references=`ref_shift $references` count=`ref_count $references` |
91 | - show_depends $ref $count ${2+"$3 `plot_linkage $2` "} | |
92 | + plot_depends $ref $count ${2+"$3 `plot_linkage $2` "} | |
92 | 93 | done |
93 | 94 | } |
94 | 95 | # |
95 | -# Helper functions, called by show_depends(), to assist in formatting | |
96 | +# Helper functions, called by plot_depends(), to assist in formatting | |
96 | 97 | # the plot of the DLL dependency graph; ref_count() simply reports the |
97 | 98 | # number of entries in the reference list, (passed as an argument list), |
98 | 99 | # while ref_shift() removes the first such reference from the same list, |
@@ -114,6 +115,18 @@ | ||
114 | 115 | test $1 -gt 0 && echo "|" || echo " " |
115 | 116 | } |
116 | 117 | # |
118 | + show_depends(){ | |
119 | + # Usage: show_depends {EXENAME | DLLNAME} | |
120 | + # | |
121 | + # Wrapper to invoke plot_depends() for EXENAME or DLLNAME, provided | |
122 | + # it exists, otherwise display a diagnostic message | |
123 | + # | |
124 | + test -f "$1" && plot_depends "$1" || { | |
125 | + echo >&2 "$CMD: ***ERROR*** $1: file not found" | |
126 | + STATUS=2 | |
127 | + } | |
128 | + } | |
129 | +# | |
117 | 130 | # Effective program entry point: set up the DLLPATH (in space separated, |
118 | 131 | # quoted path list format), then plot the DLL dependency graph for each |
119 | 132 | # EXENAME or DLLNAME specified on the command line. |
@@ -121,5 +134,6 @@ | ||
121 | 134 | test $# -gt 0 || { usage; exit 2; } |
122 | 135 | set_dllpath "${DLLPATH-$PROGRAM_FILES:/mingw/bin:$SYSTEM_DLLPATH}" |
123 | 136 | while test $# -gt 0; do show_depends "$1"; shift; test $# -gt 0 && echo; done |
137 | + exit $STATUS | |
124 | 138 | # |
125 | 139 | # $RCSfile$: end of file |