[Mono-list] control flow graph support in monograph

Martin Baulig martin@gnome.org
12 Mar 2002 14:43:18 +0100


Dan Lewis <dihlewis@yahoo.co.uk> writes:

> > What does the debugger care about the cfg?
> 
> I was thinking of a GUI attached to the debugger that highlights the basic
> blocks on a CFG as you step through the program. Completely unnecessary of
> course, just seems like a cool idea :)

Dude, wait until you have seen my new debugging code - this is not so
far from reality as you might expect :-)

The DWARF 2 debugging format knows about basic blocks and statements,
so all that you need is a debugger which can read and interpret this
information, it's currently ignored by GDB.

That's the new line number generation code:

====
	record_line_number (minfo, cfg->start + st_address, st_line, FALSE);

	/* start lines of basic blocks */
	for (i = 0; i < cfg->block_count; ++i) {
		int j;

		for (j = 0; j < cfg->bblocks [i].forest->len; ++j) {
			MBTree *t = (MBTree *) g_ptr_array_index (cfg->bblocks [i].forest, j);
			gint32 line_inc = 0, addr_inc;

			if (!i && !j) {
				st_line = minfo->first_line;
				st_address = t->addr;

				record_line_number (minfo, cfg->start + st_address, st_line, TRUE);
			}

			if (t->cli_addr != -1) {
				int *lines = info->moffsets + st_line;
				int *k = lines;

				while ((*k != -1) && (*k < t->cli_addr))
					k++;

				line_inc = k - lines;
			}
			addr_inc = t->addr - st_address;

			st_line += line_inc;
			st_address += addr_inc;

			record_line_number (minfo, cfg->start + st_address, st_line, j == 0);
		}
	}
====

where record_line_number() is

====
static void
record_line_number (DebugMethodInfo *minfo, gpointer address, guint32 line, int is_basic_block);
====

-- 
Martin Baulig
martin@gnome.org