I'm doing some work on the cog vm for which I need to instrument cogged
bytecodes to collect runtime information and my plan is to do this via
trampolines. The idea is to update the Cogit such that calls to the
relevant trampolines are generated before or after the usual machine code
that is generated for these bytecodes.
As a first test, I added a dummy trampoline that just prints a message to
stdout and updated the machine code translation of a bytecode to generate a
call to said trampoline at the beginning. For this I:
1. Updated StackToRegisterMappingCogit class>>#numTrampolines.
2. Added a ceDummyTrampoline inst var to StackToRegisterMappingCogit.
3. Updated StackToRegisterMappingCogit to generate the dummy trampoline.
ceDummyTrampoline := self genTrampolineFor: #dummyTrampoline:
4. Added the dummy trampoline method in the CoInterpreter.
self cCode: 'printf("dummy trampoline\n");'.
5. Instrumented a bytecode.
self Call: ceDummyTrampoline.
6. Generated and compiled a new vm with VMMaker generateSqueakSpurCog64VM.
With the newly compiled vm I'm able to open an image and I can see the
message from the trampoline being printed to stdout, however, it quickly
crashes when I start doing things in the UI. These are some of the
behaviors I've observed:
* The vm does not seem to crash as long as I do simple things like moving
around the cursor, opening context menus and dragging collapsed windows,
however, it quickly -but not always immediately- crashes when I start
* The chances of a window crashing the vm increases with time. e.g. I'm
able to open a browser if I do it as soon as I open the image, but not if I
wait 5 seconds.
* Some windows are more likely to crash the vm than others. e.g. I'm able
to open multiple workspaces and transcripts before the vm crashes, but at
most one browser.
* The vm outputs a crash dump sometimes, but not always.
I've attached to this message some of the crash dumps I've gotten.
Any help will be greatly appreciated. I've tried debugging using the
simulator and gdb but was not able to get very far as I don't know how to
best troubleshoot these types of errors. Suggestions in this regard are
welcome as well.