Re: GCC option to create assembly listing with C source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2024-07-05 at 11:43 +0000, Johannes Krottmayer via Gcc-help
wrote:
> Hi!
> 
> I have some troubles on a project when I enable optimizing (-O2). The 
> code works without optimizing. To fix this issue I need to know, the 
> correct line in my C code, where the issue persist.
> 
> Is there an option to produce an output from the assembled code WITH
> the C code? There exists the option -S, but I only outputs the
> assembly.

-fverbose-asm is the thing most similar to what you want.  For a "hello
world" program with -O2 -S -fverbose-asm:

main:
.LFB11:
	.cfi_startproc
	subq	$8, %rsp	#,
	.cfi_def_cfa_offset 16
# hw.c:6:   printf ("Hello, world.\n");
	leaq	.LC0(%rip), %rdi	#, tmp99
	call	puts@PLT	#
# hw.c:7: }
	xorl	%eax, %eax	#
	addq	$8, %rsp	#,
	.cfi_def_cfa_offset 8
	ret	
	.cfi_endproc

But there's no guarantee that this will lead you to the line where your
bug really exists.  The optimization passes of modern compilers are
complicated and these passes may make your bug "non-local."  For example
if the C code violates the aliasing rule at the line 114, the "breakage"
may seem to be "the compiler ignores a statement at the line 514." 
(This really frequently happens and causes many invalid "bug reports" in
GCC bugzilla.)

-- 
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux