ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: Re: [Ethereal-dev] H.225 problem, and running under gdb

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Sat, 19 Jun 2004 02:43:44 -0700
On Fri, Jun 18, 2004 at 04:59:39PM +0100, Martin Mathieson wrote:
> - stepping through the code would work a little then it would jump back to
> the breakpoint

Welcome to the wonderful world of instruction scheduling.

Modern compilers don't necessarily turn, for example

	a = b + c;
	d = e + f;

into code such as

	load	r1, b
	add	r1, c
	store	r1, a
	load	r1, e
	add	r1, f
	store	r1, d

It might, instead, generate

	load	r1, b
	load	r2, e
	add	r1, c
	add	r2, f
	store	r1, a
	store	r2, d

as a superscalar processor might be able to execute two instructions
with no interdependencies in parallel, e.g.

	add	r1, c
	add	r2, f

but wouldn't necessarily be able to execute

	add	r1, c
	store	r1, a

in parallel, so the first code sequence might take 6 clock cycles
(assuming cache hits on the loads) but the second code sequence might
take only 3.

This means that single-stepping through code might appear to jump among
statements.

Compiling without optimization might get rid of the
instruction-scheduling pass, and make single-stepping behave a bit more
as one would expect.