* header dependency; Was: [rfc] Re-merged regcache.h patch
[not found] <3A9D137C.BF7050EA@cygnus.com>
@ 2001-02-28 7:29 ` Andrew Cagney
2001-02-28 15:48 ` Andrew Cagney
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cagney @ 2001-02-28 7:29 UTC (permalink / raw)
To: GDB Discussion
Hello,
When revising the regcache.h patch, I knocked up the attatched (perl
free zone :-) script. It grubs around the source identifying which .c
files actually use functions/variables from a given header file.
While this script is probably best treated as a novelty - it only just
works for regcache.h - I'm wondering if anyone knows of a GPL package
that does this analysis properly.
Andrew
#!/bin/sh
parser=/tmp/do-analize-include-parse
refs=/tmp/do-analize-include-refs
files=/tmp/do-analize-include-files
good=/tmp/do-analize-include-good
rm ${parser}
rm ${refs}
# Generate a parser to recognize any reference to a method in "$@"
echo "Creating parse script" 1>&2
cat "$@" | awk '
# external pointer
$0 != n = gensub (/^extern [^\(\*]*\*([_[:alpha:]][_[:alnum:]]*);$/, "\\1", 1) {
print "/[^[:alnum:]]" n "[[:space:]]*\\[/ { p = 1 } # pointer"
}
$0 != n = gensub (/^extern [^\(]*[^_\([:alnum:]]([_[:alpha:]][_[:alnum:]]*)[[:space:]]\(.*$/, "\\1", 1) {
print "/[^[:alnum:]]" n "[[:space:]]*\\(/ { p = 1 } # function"
}
' >> ${parser}
cat <<EOF >> ${parser}
p { print FILENAME ":" NR ":" \$0; p = 0; }
EOF
cat ${parser}
# Parse the source files printing out a list of all references
echo "Parsing" 1>&2
find * \
-name '*-stub.c' -prune \
-o -name 'nlm' -prune \
-o -name 'gdbserver' -prune \
-o -name 'testsuite' -prune \
-o -name '*\.c' -type f -print | xargs awk -f ${parser} > ${refs}
# Create a summary file of files containing refs
cut -d: -f1 < ${refs} | sort -u > ${files}
# Check to see if the file includes our target
xargs grep -e '#include *"'$1'"' < ${files} | cut -d: -f 1 | sort > ${good}
diff ${good} ${files}
From keiths@cygnus.com Wed Feb 28 07:53:00 2001
From: Keith Seitz <keiths@cygnus.com>
To: Edward Peschko <edwardp@excitehome.net>
Cc: gdb@sourceware.cygnus.com
Subject: Re: using perl in gdbinit
Date: Wed, 28 Feb 2001 07:53:00 -0000
Message-id: <Pine.SOL.3.91.1010228073240.19631D-100000@ryobi.cygnus.com>
References: <20010227160952.A25814@excitehome.net>
X-SW-Source: 2001-02/msg00432.html
Content-length: 1123
On Tue, 27 Feb 2001, Edward Peschko wrote:
> I'd like to use perl in gdbinit to make gdb commands and bind them to a key.
> So I could say stuff like:
>
> local($/) = undef;
> my $functions = `info functions`;
[snip]
I would guess that you should be able to add a perl interpreter to gdb. I
don't know a whole lot about how perl was written, but if there is a way
to create your own perl interpreter like this:
init_perl ()
{
g_interp = Perl_New_Interpreter ();
}
You should be able to do what you want (albeit in a hacky kind of way).
For insight, we added a tcl interpreter and bound tcl's command parser to
the gdb command "tk". We also have a tcl command, "gdb_cmd", which can be
used to execute gdb commands in the tcl interpreter.
I could do things like what you want above (although I never have):
(gdb) tk set help [gdb_cmd help]; puts stdout $help
(gdb) tk set functions [gdb_cmd "info func main"]; puts stdout $functions
Of course, you are still leaving yourself at the mercy of gdb's human
readable output, so you'll need to parse gdb's output to do some things
well.
Keith
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: header dependency; Was: [rfc] Re-merged regcache.h patch
2001-02-28 7:29 ` header dependency; Was: [rfc] Re-merged regcache.h patch Andrew Cagney
@ 2001-02-28 15:48 ` Andrew Cagney
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2001-02-28 15:48 UTC (permalink / raw)
To: GDB Discussion
Andrew Cagney wrote:
>
> Hello,
>
> When revising the regcache.h patch, I knocked up the attatched (perl
> free zone :-) script. It grubs around the source identifying which .c
> files actually use functions/variables from a given header file.
>
> While this script is probably best treated as a novelty - it only just
> works for regcache.h - I'm wondering if anyone knows of a GPL package
> that does this analysis properly.
To answer my own question, Steven Johnson pointed out that source
navigator can do this.
It creates a database with complete information and you can query
anything - only now I need to read the manual :-)
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-02-28 15:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <3A9D137C.BF7050EA@cygnus.com>
2001-02-28 7:29 ` header dependency; Was: [rfc] Re-merged regcache.h patch Andrew Cagney
2001-02-28 15:48 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox