D5.1: One refactoring bug in BlockFrame; a suggestion for StackFrame

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D5.1: One refactoring bug in BlockFrame; a suggestion for StackFrame

Maxim Fridental
The method BlockFrame>>argsOffset is sending #base to the self, that is
leading to the DNU error. I suppose the right version could be

argsOffset
 ^(self tempsBeforeIp: self basicBP initialIP - 1) size


We're fiddling about BlockFrames because we override #unhandledException: to
add our project-specific info into the log. Among other things we have
patched StackFrame>>displayOn: so that it's printing the frame with all its
arguments:

displayOn: aStream
 "Append a short textual description of the receiver to aStream appropriate
 for displaying in a stack trace."

 "Display processing will fail if this stack frame is dead"

 | method class mClass selector currentMethod |
 self isDead
  ifTrue:
   [self printOn: aStream.
   ^self].
 method := self method.
 class := self receiver basicClass. "Use basic class to avoid deref'ing
proxies"
 aStream nextPutAll: class name.
 mClass := method methodClass.
 mClass == class
  ifFalse:
   [aStream
    nextPut: $(;
    display: mClass name;
    nextPut: $)].
 aStream nextPutAll: '>>'.
 method isUnbound
  ifTrue:
   ["Method is unbound if it is either not in the class' method dictionary,
or it doesn't have the same
   source as that currently in the dictionary"
   aStream nextPutAll: '{unbound}'].
 selector := method selector readStream.
 aStream nextPutAll: (selector upTo: $:).
 self arguments do:
   [:a |
   aStream
    nextPutAll: ': {';
    print: a;
    nextPutAll: '} ';
    nextPutAll: (selector upTo: $:)]

We believe it's a feature everyone could want to have.


Reply | Threaded
Open this post in threaded view
|

Re: One refactoring bug in BlockFrame; a suggestion for StackFrame

Blair McGlashan-2
Maxim

You wrote in message news:bckpun$khgt1$[hidden email]...
> The method BlockFrame>>argsOffset is sending #base to the self, that is
> leading to the DNU error. I suppose the right version could be
>
> argsOffset
>  ^(self tempsBeforeIp: self basicBP initialIP - 1) size
>

Thanks, this will be fixed in the next patch level.

> We're fiddling about BlockFrames because we override #unhandledException:
to
> add our project-specific info into the log. Among other things we have
> patched StackFrame>>displayOn: so that it's printing the frame with all
its
> arguments:
> ...[snip]...
>
> We believe it's a feature everyone could want to have.

Well, each to his own, but personally I don't like the cluttering effect on
the debugger. Also you should be a bit careful about this because the
operation of the walkback window and debugger is now dependent on each
arguments printString (a) working correctly, (b) completing in a reasonable
time, (c) producing reasonably short output. I would suggest using
#debugPrintString instead, and also include an exception trap to catch any
errors that might occur attempting to print the arguments. If you don't do
this, then you will lose all ability to debug should any of the printOn:
methods raise an error, and in fact the system will probably crash when it
is trying to display a walkback and/or bring up the debugger.

I would also recommend taking a look at the
VMLibrary>>dump:path:stackDepth:walkbackDepth: for production of error
traces in deployed applications The walkback in the dump includes all
arguments and temps, and the raw stack contents are available as well.
Althougth the VM dump is not able to run specialised printString
implementations, it has a number of advantages:
1) It will work no matter what has been stripped from the image, and what
the state of the image is at the time of the dump.
2) It is not dependent on the correctness of any printOn: or other overrides
3) It includes sufficient information for us (and therefore yourselves) to
perform post-mortem debugging with reasonable effectiveness.
4) You can specify a dump file, or accept the default (<appname>.errors),
and if it is unable to open that file (e.g. because of insufficient rights
to write to the directory), then the dump is directed to OS debug trace
stream

This dump is produced by default by the base session manager's
#unhandledException: implementation (actually in #logError:).

Regards

Blair