Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com X-Injected-Via-Gmane: http://gmane.org/ Path: not-for-mail From: Joe Buehler Subject: [SCRIPT] Windows system dll function addresses Date: Fri, 13 Dec 2002 09:16:58 -0500 Lines: 50 Message-ID: NNTP-Posting-Host: 64.47.34.2 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1039789003 15220 64.47.34.2 (13 Dec 2002 14:16:43 GMT) X-Complaints-To: usenet AT main DOT gmane DOT org NNTP-Posting-Date: Fri, 13 Dec 2002 14:16:43 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.2) Gecko/20021126 X-Accept-Language: en-us, en Sometimes it is useful to be able to tell what Windows DLL functions are at the top of a stack trace in gdb (not everyone can remember functions by address instead of name). Here is a perl script to dump a sorted list of symbol addresses from the dlls on a Windows system. You need dumpbin to run this. Only tested on Windows NT -- dumpbin may have different output on other versions, in which case this may break. Oh, one thing -- I have a mount point named "/sys" that is the directory where the dlls reside. I think I made that myself. You will have to substitute whatever the appropriate path is on your machine. Joe Buehler #!/usr/bin/perl # # dump symbols and absolute address from Windows system dlls # # You need dumpbin for this to work. # You also need to change /sys to whatever is appropriate. # opendir(SYSDIR, "/sys"); while ($dll = readdir(SYSDIR)) { next unless $dll =~ /[.]dll$/io; next unless -f "/sys/$dll"; open(DUMPBIN, qq{ cd /sys && dumpbin /headers /exports $dll | }); while () { s/\r*\n//o; next if /^\s*$/o; if (/^\s*(\S+)\s+image\s+base\s*$/io) { $image_base_address = hex $1; } elsif (/^\s+ordinal\s+hint\s+RVA\s+name\s*$/io .. /^\S/o) { next if /^\s+ordinal\s+hint\s+RVA\s+name\s*$/io; next if /^\S/io; next unless ($ordinal, $hint, $RVA, $name) = /^\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$/o; $RVA = hex $RVA; push(@out, sprintf("0x%08x %16s %s\n", $image_base_address + $RVA, $dll, $name)); } } close(DUMPBIN); } closedir(SYSDIR); print sort @out; -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/