Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Mar 1995 07:18:58 -0800
From:      pascal@netcom.com (Richard A Childers)
To:        PVinci@ix.netcom.com, questions@FreeBSD.org
Subject:   Re:  How to search through sources??
Message-ID:  <199503221518.HAA01124@netcom13.netcom.com>

next in thread | raw e-mail | index | archive | help

"How can I search through the sources to find a Procedure?  For example, 
 if I wanted to look at the panic() function.  Is there a tool that will 
 scan the sources?  (P.S. I'm not looking for panic())"


Well, before you go looking through the sources, try the man pages.

	% man -k panic		# finds all man pages with keyword 'panic'

Try a more manual approach to searching the man pages :

	% ls /usr/share/man/*/*panic*

( If you don't have the man pages installed correct this right away. )

If you still need to search the sources :

	% find /usr/src -type f -name '*panic*' -print

This will find all files with the pattern '*panic*' in the filename.

However, it is quite common for several routines ( function, procedures,
what have you ) to be collected into a single 'header' file, as a library,
so another technique ( taking this into account ) might be :

	% find /usr/src -type f -exec grep -n "panic" {} \; -print

This searches every file under /usr/src for the pattern "panic", printing
those lines it encounters the pattern in, followed by the name of the file
the line(s) were encountered in. ( The '-n' flag gives the line number. )
Redirect this into a file and use a text editor to browse it for the place
where the routine is originally defined.

Caveat : this is all based upon the assumption that /usr/src is readable
to the world or that you have placed yourself in the appropriate groups to
access the /usr/src tree. If you see 'Permission denied', you probably need
to try this as root ( although fixing the problem and returning to running
the search, as yourself, is really the best solution ).


-- richard

       Pontius Pilate was politically correct. So was Benedict Arnold.
       So was Vidkun Quisling ... and so was Adolph Hitler.	|-:

   richard childers        san francisco, california        pascal@netcom.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503221518.HAA01124>