Page 1 of 1

GCC Question

Posted: Tue Nov 09, 2004 8:40 am
by linverse
Is there a way to output c++ code and it's final assembled version like Visual Studio can do. x86 ex:

Code: Select all

; 41   : void statsClose() {

	sub	esp, 8
	push	esi
	push	edi

; 42   : 	time_t t;
; 43   : 	FILE *f;
; 44   : 
; 45   : 	t = time(NULL) - vsyncTime;

	push	0
	call	_time
	mov	edi, eax
	sub	edi, DWORD PTR _vsyncTime
LInverse

Posted: Tue Nov 09, 2004 9:06 am
by ooPo
To spit out unassembled code, use:

gcc -S

I think. :)

Posted: Tue Nov 09, 2004 9:54 am
by pixel
Well, this won't "interlace" source code...

Posted: Tue Nov 09, 2004 10:43 am
by ooPo
Stop that! You make me sad!

Posted: Tue Nov 09, 2004 1:45 pm
by Guest
pixel wrote:Well, this won't "interlace" source code...
This actually sounds like it could be a cool feature, but I guess that GCC doesn't have it ?

Of course, optimization would wreak havoc, but the same issues exist for and haven't stopped optimization being used in conjunction with debugging turned on.

Objdump lets debugging information be printed along with disassembly, including sourcefile names and line numbers, and also I think including source code, but thats done on already compiled binaries that hopefully had debug turned on and source files laying around.

My advice to the original poster - check the objdump command. It comes with the gcc distribution.