* making unwcheck.sh
@ 2003-11-14 18:38 David Mosberger
2003-11-15 6:20 ` Matt Chapman
0 siblings, 1 reply; 3+ messages in thread
From: David Mosberger @ 2003-11-14 18:38 UTC (permalink / raw)
To: linux-ia64
Is anybody willing/capable/interested in fixing unwcheck.sh so it can
actually handle 64-bit addresses? I'm not much of an awk hacker but I
noticed that the only reason the script works on the kernel is because
it drops the first digit of each address (look for gsub() to see what
I mean). Of course, that makes it work on the kernel, but it won't
work for checking a shared object, for example. Perhaps the whole
script should just be converted to a real[1] language?
--david
[1] real = anything other than awk, perl, or tcl... ;-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: making unwcheck.sh
2003-11-14 18:38 making unwcheck.sh David Mosberger
@ 2003-11-15 6:20 ` Matt Chapman
0 siblings, 0 replies; 3+ messages in thread
From: Matt Chapman @ 2003-11-15 6:20 UTC (permalink / raw)
To: linux-ia64
What's wrong with Perl? :) Okay, so there's plenty wrong with Perl, but
I think it's a decent tool for the job.
I wrote a quick Perl version, though it only works properly on 64-bit
platforms (reports an integer overflow otherwise). It wouldn't be too
hard to work around this if it's an issue (since for a given function
the upper 32 bits should presumably be invariant), in fact the same
workaround could probably be done in the awk script.
http://www.cse.unsw.edu.au/~matthewc/files/unwcheck.pl
Python seems to handle big numbers better but I don't really know enough
Python.
Matt
On Fri, Nov 14, 2003 at 10:38:39AM -0800, David Mosberger wrote:
> Is anybody willing/capable/interested in fixing unwcheck.sh so it can
> actually handle 64-bit addresses? I'm not much of an awk hacker but I
> noticed that the only reason the script works on the kernel is because
> it drops the first digit of each address (look for gsub() to see what
> I mean). Of course, that makes it work on the kernel, but it won't
> work for checking a shared object, for example. Perhaps the whole
> script should just be converted to a real[1] language?
>
>
> --david
>
> [1] real = anything other than awk, perl, or tcl... ;-)
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: making unwcheck.sh
@ 2004-01-15 23:33 David Mosberger
0 siblings, 0 replies; 3+ messages in thread
From: David Mosberger @ 2004-01-15 23:33 UTC (permalink / raw)
To: linux-ia64
>>>>> On Sat, 15 Nov 2003 17:20:48 +1100, Matt Chapman <matthewc@cse.unsw.edu.au> said:
Matt> Python seems to handle big numbers better but I don't really
Matt> know enough Python.
Well, attached is what I came up with (I'm not terribly proficient
in Python, I should say, so suggestions for improvements are welcome).
Of course, it promptly found a problem in mca_asm.S:
ERROR: function ia64_monarch_init_handler: 186 slots, sum of region len = 179
Actually, the entire mca_asm.S file looks rather atrocious. For
example, it doesn't take advantage of the ENTRY/END macros in
asm_macro.h. Could somebody look into fixing and cleaning this up?
Thanks,
--david
#!/usr/bin/env python
#
# Usage: unwcheck.py FILE
#
# This script checks the unwind info of each function in file FILE
# and verifies that the sum of the region-lengths matches the total
# length of the function.
#
# Based on a shell/awk script originally written by Harish Patil,
# which was converted to Perl by Matthew Chapman, which was converted
# to Python by David Mosberger.
#
import os
import re
import sys
if len(sys.argv) != 2:
print "Usage: %s FILE" % sys.argv[0]
sys.exit(-1)
readelf = os.getenv("READELF", "readelf")
start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]")
rlen_pattern = re.compile(".*rlen=([0-9]+)")
def check_func (func, slots, rlen_sum):
if slots != rlen_sum:
global num_errors
num_errors += 1
if not func: func = "at %#x" % start
print "ERROR: function %s: %lu slots, sum of region lengths = %lu" \
% (func, slots, rlen_sum)
return
num_funcs = 0
num_errors = 0
func = False
slots = 0
rlen_sum = 0
for line in os.popen("%s -u %s" % (readelf, sys.argv[1])):
m = start_pattern.match(line)
if m:
check_func(func, slots, rlen_sum)
func = m.group(1)
start = long(m.group(2), 16)
end = long(m.group(3), 16)
slots = 3 * (end - start) / 16
rlen_sum = 0L
num_funcs += 1
else:
m = rlen_pattern.match(line)
if m:
rlen_sum += long(m.group(1))
check_func(func, slots, rlen_sum)
if num_errors = 0:
print "No errors detected in %u functions." % num_funcs
else:
print "%u errors detected in %u functions." % (num_errors, num_funcs)
sys.exit(-1)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-15 23:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-14 18:38 making unwcheck.sh David Mosberger
2003-11-15 6:20 ` Matt Chapman
-- strict thread matches above, loose matches on Subject: below --
2004-01-15 23:33 David Mosberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox