[comp.unix.questions] disassembling code on system V

Leisner.Henr@xerox.com (Marty) (02/11/88)

I want to disassemble some library code on a Sys V.2 system to get an idea how
efficient the library is (specifically the memory and string instructions)
without having the source code.

I've played some with adb and sdb and I can get it to do an assembler trace as
it executes.  But how do I just say:

	disassemble from Address A to Address B, and if you understand the symbols,
print them out too.

Any magic sequence of commands in adb or sdb?  Or try something else?  

(It seems SDB will mix the assembler and source in code I generate.  But I want
it to give me an indication how complicated the library code is).

marty
ARPA:	leisner.henr@xerox.com
GV:  leisner.henr
NS:  martin leisner:henr801c:xerox

 

Cherry.STCWR@xerox.com (02/13/88)

On Jupiter:STC WR:Xerox]UNIX/...  somewhere you will find a 68k disassembler.
If you are running System-V on a 680x0 based system this will do what you want.

I have changed access to this drawer so that you may copy items of interest out
of it. [  Leisner:HENR801c:xerox  Access: Read ]

I have used this disassembler to perform similiar functions on both Sun (BSD
derived) and Heurikon (System-V) systems.

B.C. & Zot

   _   /|		PUP/GV : Cherry.STCWR
   \`o_O'		   XNS : Robert Cherry:STC WR:Xerox
    =( )= Aachk! Phft!    ARPA | rocksanne!anb02!cherry%rochester:ARPA:Xerox
      U 		       : rocksanne!bob
			       : cherry.STCWR@Xerox.COM
			  UUCP : rocksanne!bob
       :=work, |=home	       | {rocksanne | gryphon | wright}!anb02!cherry
       
	   		   TPC : (714) 474-2273
			   XPC : 8 * 825-2273
			    MS : LARH 5007

stroyan@hpfcdc.HP.COM (Mike Stroyan) (02/14/88)

>I want to disassemble some library code on a Sys V.2 system to get an idea how
>it executes.  But how do I just say:
>
>	disassemble from Address A to Address B, and if you understand the symbols,
>print them out too.
>
>Any magic sequence of commands in adb or sdb?  Or try something else?  

You can disassemble with adb by typing "<symbol>?i" or "<address>?i".
It will take an instruction count before "i", but I don't know any way
to specify an address range rather than a number of instructions.  A
simple way to use this as a disassembler is to make a command file
containing "0?i" followed by a few thousand blank lines, then executing
"adb a.out < command_file > backlist".  The many blank lines will repeat
the single "?i" command, which works better than a large count because
it labels every instruction with a symbolic address.  This approach will
try to interpret everything as instructions, so data areas may look like
strange code, and real code after data may take a few instructions to
'sync up'.

Mike Stroyan, [hplabs!]hpfcla!stroyan

joel@intelisc.UUCP (Joel Clark) (02/18/88)

In article <5740018@hpfcdc.HP.COM> stroyan@hpfcdc.HP.COM (Mike Stroyan) writes:
>>I want to disassemble some library code on a Sys V.2 system to get an idea how
>>it executes.  But how do I just say:
>>
>>	disassemble from Address A to Address B, and if you understand the symbols,
>>print them out too.
>>
>>Any magic sequence of commands in adb or sdb?  Or try something else?  
>
>You can disassemble with adb by typing "<symbol>?i" or "<address>?i".
>It will take an instruction count before "i", but I don't know any way
>to specify an address range rather than a number of instructions.  A
>simple way to use this as a disassembler is to make a command file
>containing "0?i" followed by a few thousand blank lines, then executing
>"adb a.out < command_file > backlist".  The many blank lines will repeat
>the single "?i" command, which works better than a large count because
>it labels every instruction with a symbolic address.  
>
>Mike Stroyan, [hplabs!]hpfcla!stroyan

In `adb` displaying addresses can be achieved with "symbol,200?ia" or 
"address,200?ia".   This will print 200 lines of disassembly with addresses 
starting at symbol.  The '?' means to display from the text (code) section, 
any address not found in the text section will display "Text address not found" 
messages.  In `sdb` this would be done by "symbol?200i" or "address:?200i".