From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19661 invoked by alias); 1 Aug 2004 16:29:31 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19654 invoked from network); 1 Aug 2004 16:29:30 -0000 Received: from unknown (HELO blount.mail.mindspring.net) (207.69.200.226) by sourceware.org with SMTP; 1 Aug 2004 16:29:30 -0000 Received: from user-119a90a.biz.mindspring.com ([66.149.36.10] helo=berman.michael-chastain.com) by blount.mail.mindspring.net with esmtp (Exim 3.33 #1) id 1BrJDE-0000ZI-00; Sun, 01 Aug 2004 12:29:28 -0400 Received: from mindspring.com (localhost [127.0.0.1]) by berman.michael-chastain.com (Postfix) with SMTP id 30D8A4B102; Sun, 1 Aug 2004 12:29:30 -0400 (EDT) Date: Sun, 01 Aug 2004 16:29:00 -0000 From: Michael Chastain To: kettenis@chello.nl Subject: prologue ripper Cc: gdb-patches@sources.redhat.com, eliz@gnu.org Message-ID: <410D1A69.nailMDH1AX7PW@mindspring.com> References: <200408011244.i71CicIt041460@elgar.kettenis.dyndns.org> In-Reply-To: <200408011244.i71CicIt041460@elgar.kettenis.dyndns.org> User-Agent: nail 10.8 6/28/04 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2004-08/txt/msg00010.txt.bz2 Mark Kettenis wrote: mark> Thanks! This really is the info I need. Could you post (or mail me) mark> the perl fu? Yeah, I'll just stick it at the end of this message, just in case anyone besides me and thee ever cares. :) mark> On systems that use the -freg-struct-return by default (FreeBSD, mark> OpenBSD, Cygwin and a few others) I guess there are a bit more mark> possibilities. I don't have a Cygwin, but I have been using FreeBSD and OpenBSD in the HP Test Drive cluster. I'll just hop on, do some builds, and prologue-rip them. Michael C === #! /usr/bin/perl # # Copyright Abandoned 2004, Michael Chastain, # This script is public domain. # # Process the prologues from an executable file. # # Usage: # # objdump -d cc1plus > cc1plus.odd # perl prologue.pl cc1plus.odd > cc1plus.pro # sort cc1plus.pro | uniq -c > cc1plus.sort # # The stuff at the end is x86 specific. # You can hack it for other arches. # Have fun! use integer; use strict; use warnings; $| = 1; while (<>) { # scan for beginning of function next unless $_ =~ m/^0[^<]*<([^>]*)>.*$/; my $name = $1; my $line = ""; # scan the first few instructions my @insn = (); while (<>) { last if $_ =~ m/^Disassembly of /; last if $_ =~ m/^$/; chomp $_; # standardize the whitespace a bit $_ =~ s/^\s*[0-9A-Fa-f]+:\s*([0-9A-Fa-f]+\s+)*//; $_ =~ s/,/, /g; $_ =~ s/\s+/ /g; $_ =~ s/^\s+//g; push @insn, $_; last if scalar(@insn) >= 7; } # the following is x86 specific # print short lines for the simple folks if ( $insn[0] eq 'push %ebp' and $insn[1] eq 'mov %esp, %ebp') { print "\@0\@ $insn[0] | $insn[1]\n"; next; } # print lines for the 1-insn-inserted folks if ( $insn[0] eq 'push %ebp' and $insn[2] eq 'mov %esp, %ebp') { my $i1 = $insn[1]; $i1 =~ s/\$0x[0-9A-Fa-f]+/\$0xIMMEDIATE/; $i1 =~ s/0x[0-9A-Fa-f]+/0xADDRESS/; print "\@1\@ $insn[0] | $i1 | $insn[2]\n"; next; } # print lines for the 2-insn-inserted folks if ( $insn[0] eq 'push %ebp' and $insn[3] eq 'mov %esp, %ebp') { my $i1 = $insn[1]; $i1 =~ s/\$0x[0-9A-Fa-f]+/\$0xIMMEDIATE/; $i1 =~ s/0x[0-9A-Fa-f]+/0xADDRESS/; my $i2 = $insn[2]; $i2 =~ s/\$0x[0-9A-Fa-f]+/\$0xIMMEDIATE/; $i2 =~ s/0x[0-9A-Fa-f]+/0xADDRESS/; print "\@2\@ $name : $insn[0] | $i1 | $i2 | $insn[3]\n"; next; } # print the whole schmeer for the complex folks print "\@Z\@ $name : ", join (' | ', @insn), "\n"; }