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

Re: Proposal: A symbolic debugger for OOC



Stewart Greenhill <greenhil@murdoch.edu.au> writes:

> With a sufficiently powerful meta-programming system (eg. the Refs that
> Harmut is proposing), it should be possible to introspect at run-time to
> determine:
> 1) The state of the stack.
> 2) Local variables in modules.
> 3) Records and arrays on the heap.

As I said in my previous mail, the 1) is a problem.  To give an
example for this, here is the code emitted for the procedure
Strings.Assign, compiled with "-O --no-rtc":

void Strings_Assign(const unsigned char* source__ref, int source_0d, unsigned ch
ar* destination, int destination_0d) {
  register int i0, i1, i2, i3;
  unsigned char* source;
  _push_value_alloca(int, source, source__ref, source_0d);
  i1 = destination_0d - 1;
  i2 = -1;
l0:
  i2++;
  i3 = (int)source + i2;
  i0 = (int)destination + i2;
  i3 = *(unsigned char*)i3;
  *(unsigned char*)i0 = i3;
  i0 = *(unsigned char*)i0;
  i0 = i0 == 0;
  if (i0) goto l1;
  i0 = i2 != i1;
  if (i0) goto l0;
l1:
  i0 = (int)destination + i2;
  *(unsigned char*)i0 = 0;
}

As you can see, it's 
a) ugly
b) does not declare any local variable `i'
c) there are a lot of "register" variables `ix'
d) the "registers" are reused for different tasks, and not bound to a
   O2 variable

Getting meaningful information from the stack frame of the C function
`Strings_Assign' is not possible without much more information on the
inner workings of the function.

> It would be possible to implement a post-mortem debugger as a small HTTP
> server linked into an OOC application. [...]

An excellent idea, and it can probably be implemented without much
effort -- as soon as more powerful meta-programming facilities exist.

-- mva