[comp.sys.ibm.pc.programmer] Turbo C Debugger

simon@shiva.trl.oz (Simon Michnowicz - A Free Spirit) (04/09/90)

This question refers to the Disassembler in TurboC's
Stand-alone debugger.

It has a really  nice feature, namely printing a line
of C code, and the assembly instructions that are
equivalent to it.

This is really useful to me, and I would like to
get the WHOLE file done like that.  However there
seems to be no easy way of doing this.  The only way
I can think of is to dump each window full of information
to a log file.   Tedious for long progams!!

Can anyone possibly help me here?

	regards
		Simon Michnowicz

***************************************************************************
Simon Michnowicz                |
Integrated Customer Services    |
Telecom Australia               |
Research Laboratories           |    "We Do It To Bits In Packets"
Phone:  Wk (03) 541 6476        |
	Hm No Fixed Abode       |
ACSNET simon@shiva.trl.oz       |
***************************************************************************

joefritz@pawl.rpi.edu (Jochen M. Fritz) (04/09/90)

In article <1291@trlluna.trl.oz> simon@shiva.trl.oz (Simon Michnowicz - A Free Spirit) writes:
>
>This question refers to the Disassembler in TurboC's
>Stand-alone debugger.
>
>It has a really  nice feature, namely printing a line
>of C code, and the assembly instructions that are
>equivalent to it.
>
>This is really useful to me, and I would like to
>get the WHOLE file done like that.  However there

This feature is included in the TCC compiler (Command line only).  Just
type tcc -s file.c.  You will get a .asm file, that you can use to your 
heart's content.  I hope this works.


------------------------------------------------------------------------
| Jochen Fritz            | For though we live in the world, we do not |
| joefritz@pawl.rpi.edu   | wage war as the world does.-- 2 Cor. 10:3  |      
| usergk2s@rpitsmts.bitnet| You have heard it said, Love your neighbor |
| Noah [the peace monger] | and hate your enemy.  But I tell you: Love |
|                         | your enemies.  Matt. 5:43-44               |
------------------------------------------------------------------------

grimlok@hubcap.clemson.edu (Mike Percy) (04/10/90)

I tried to mail this, but it bounced.

simon@shiva.trl.oz (Simon Michnowicz - A Free Spirit):
> 
> This question refers to the Disassembler in TurboC's
> Stand-alone debugger.
> 
> It has a really  nice feature, namely printing a line
> of C code, and the assembly instructions that are
> equivalent to it.
> 
> This is really useful to me, and I would like to
> get the WHOLE file done like that.  However there
> seems to be no easy way of doing this.  The only way
> I can think of is to dump each window full of information
> to a log file.   Tedious for long progams!!
> 

Well, in answer to your question, I found it to be a handy feature too,
and wanted to get a whole program listed in this form.  What I did was
to write a REXX exec that reads in the C program and merges it with the
ASM file.  I meant to get around to re-writing the exec in C, but
haven't so far.  You should be able to do it pretty simply, though.

Have a look at the output of the following:
       tcc -S prog.c       (namely prog.asm)
Notice the lines labeled
;	debug L ##         (## is the corresponding line in the C prog)
So now make a C prog that reads in a C source code into an array
(because you may need to reference them more than once) and then read
the .ASM file.  When you see a line with the above prefix, spit out the
C line with the right number. Lines without the right prefix, just spit
out.

You could avoid the array by doing a simple merge kind-of-thing.  For
the few cases when you would need a line from the source more than once,
you could vote to simply put out the ?debug line.

Good luck.