[m-dev.] for review: the new debugger command set (part 3 of 5)

Tyson Dowd trd at cs.mu.OZ.AU
Fri Sep 18 15:59:35 AEST 1998


On 16-Sep-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:

> +/*
> +** MR_prepare_insert_into_sorted(array[], int& next, int& element, COMPARE)
> +**
> +** Given a sorted array `items', this prepares for the insertion of a new
> +** item into the array at the proper point. It find the index at which
> +** the new item should be inserted, and moves all items at and above that
> +** index one position to the right to make room for the new item.
> +**
> +** The `next' parameter holds the number of elements in the array;
> +** it is incremented by this macro. The macro returns the indexs of the slot

s/indexs/index/

> +** at which the new item should be inserted in the `element' parameter.
> +** The `COMPARE' parameter should be an expression which compares
> +** the item at the index specified by the current value of `element' with
> +** the item being inserted, and returns <0, 0, or >0 according to whether
> +** it is less than, equal to, or greater than the item being inserted.
> +*/
> +
> +#define MR_prepare_insert_into_sorted(items, next, element, COMPARE)	\
> +	do {								\
> +		(element) = (next) - 1;					\
> +		while ((element) >= 0 && COMPARE > 0) {			\
> +			items[element + 1] = items[element];		\
> +			(element) -= 1;					\
> +		}							\
> +		(element) += 1;						\
> +		(next) += 1;						\
> +	} while(0)
> +


> +
> +Define_entry(MR_do_trace_redo_fail);
> +#if 0
> +	printf("MR_curfr = %p\n", MR_curfr);
> +	printf("MR_redofr_slot(MR_curfr) = %p\n", MR_redofr_slot(MR_curfr));
> +	printf("&MR_redo_layout_framevar(MR_redofr_slot(MR_curfr) = %p\n",
> +		&MR_redo_layout_framevar(MR_redofr_slot(MR_curfr)));
> +	printf("MR_redo_layout_framevar(MR_redofr_slot(MR_curfr) = %p\n",
> +		MR_redo_layout_framevar(MR_redofr_slot(MR_curfr)));
>  #endif

Do you still want this code inside the #if 0?

> +static int
> +MR_search_spy_table_for_proc(const MR_Stack_Layout_Entry *entry)
> +{
> +	int				lo;
> +	int				hi;
> +	int				mid;
> +
> +	lo = 0;
> +	hi = MR_spied_proc_next - 1;
> +	while (lo <= hi) {
> +		mid = (lo + hi) / 2;
> +		if (MR_spied_procs[mid].spy_proc == entry) {
> +			return mid;
> +		} else if (MR_spied_procs[mid].spy_proc < entry) {
> +			lo = mid + 1;
> +		} else {
> +			hi = mid - 1;
> +		}
> +	}
> +
> +	return -1;
> +}

Why don't you use the MR_bsearch macro to perform the search?

-- 
Those who would give up essential liberty to purchase a little temporary
safety deserve neither liberty nor safety.     - Benjamin Franklin

Tyson Dowd   <tyson at tyse.net>   http://tyse.net



More information about the developers mailing list