/**PFE-DEBUG --- analyze compiled code Copyright (C) Tektronix, Inc. 1998 - 2001. All rights reserved. @see GNU LGPL @author Tektronix CTE @(#) %derived_by: guidod % @version %version: bln_mpt1!5.36 % (%date_modified: Tue Jun 18 14:49:54 2002 %) @description The Portable Forth Environment provides a decompiler for colon words and a single stepper for debugging. After setting a breakpoint at a word saying => DEBUG <tt>word</tt>. The next time the <tt>word</tt> gets executed the single stepper takes control. When this happens you see the top stack items displayed in one line. The topmost stack item is the first in line, the second and following stack items are displayed throughout the end of line. This line is empty if the stack is empty when the word in question executes. On the next line you see the first word to become executed inside the debugged <tt>word</tt>. There is a prompt <tt>></tt> to the right of the displayed word. At this prompt you have several options. Choose one by typing a key (<tt>[h]</tt> shows helpscreen): <dl> <dt> <tt>[enter], [x], [k], [down]</tt> </dt> <dd> The displayed word will be executed without single stepping. Note that the execution of the word is slowed down a little compared to execution outside the single stepper. This is because the single stepper has to keep control to detect when the word has finished. After the actual word finished execution the resulting stack is printed on the current line. The next line shows the next word to become executed. Having repeated this step several times, you can see to the the right of every decompiled word what changes to the stack this word caused by comparing with the stack display just one line above. </dd> <dt> <tt>[d], [l], [right]</tt> </dt><dd> Begin single step the execution of the actual word. The first word to become executed inside the definition is displayed on the next line. The word's display is intended by two spaces for each nesting level. */ /* You can single step through colon-definitions and the children of defining words. Note that most of the words in PFE are rewritten in C for speed, and you can not step those kernel words. </dd> <dt> <tt>[s], [j], [left]</tt> </dt><dd> Leaves the nesting level. The rest of the definition currently being executed is run with further prompt. If you leave the outmost level, the single stepper won't get control again. Otherwise the debugger stops after the current word is finished and offers the next word in the previous nesting level. </dd> <dt> <tt>[space]</tt> </dt><dd> The next word to be executed is decompiled. This should help to decide as if to single step that word. </dd> <dt> <tt>[q]</tt> </dt><dd> Quits from the debugger. The execution of the debugged word is not continued. The stacks are not cleared or changed. </dd> <dt> <tt>[c]</tt> </dt><dd> Displays the profiling instruction counter. <dt> <tt>[r]</tt> </dt><dd> Reset the instruction counter, to profile some code. The debugger counts how often the inner interpreter i.e. how many Forth-primitives are executed. Use this option to reset the counter to 0 to measure an arbitrary part of code. </dd> </dl> @{ */ #if defined(__version_control__) && defined(__GNUC__)static char* id __attribute__((unused)) = "@(#) $Id: %full_filespec: debug-ext.c~31.5 % $" #endif #define _P4_SOURCE 1 #include <pfe/pfe-base.h> #include <pfe/def-xtra.h> #include <pfe/def-types.h> #include <pfe/def-comp.h> #include <pfe/term-sub.h> #include <ctype.h> #include <string.h> #include <pfe/_missing.h> /*; ********************************************************************** */ /*decompiler */
/* |
/* |
_export p4xt* p4_local_SEE (p4xt* ip, char* p, p4_Semant* s)
|
_export p4xt* p4_literal_SEE (p4xt* ip, char* p, p4_Semant* s)
|
_export p4xt* /*
|
_export p4xt* /*
|
_export p4xt* /*
|
_export p4xt* /*
|
static p4xt * p4_decompile_word (p4xt* ip, char *p, p4_Decomp *d)
|
_export void p4_decompile_rest (p4xt *ip, int nl, int indent)
|
static P4_CODE_RUN(p4_variable_RT_SEE)
|
static P4_CODE_RUN(p4_builds_RT_SEE)
|
static P4_CODE_RUN(p4_constant_RT_SEE)
|
static P4_CODE_RUN(p4_value_RT_SEE)
|
static P4_CODE_RUN(p4_two_constant_RT_SEE)
|
static P4_CODE_RUN(p4_marker_RT_SEE)
|
static P4_CODE_RUN(p4_defer_RT_SEE)
|
static P4_CODE_RUN(p4_vocabulary_RT_SEE)
|
static P4_CODE_RUN(p4_offset_RT_SEE)
|
static P4_CODE_RUN(p4_colon_RT_SEE)
|
static P4_CODE_RUN(p4_does_RT_SEE)
|
_export void p4_decompile (char *nfa, p4xt xt)
|
/* |
_export char p4_category (p4code p)
|
static void prompt_col (void)
|
static void display (p4xt *ip)
|
static void interaction (p4xt *ip)
|
static void do_adjust_level (p4xt xt)
|
static void p4_debug_execute (p4xt xt)
|
static void p4_debug_on (void)
|
_export void p4_debug_off (void)
|
static void /*
|
FCode (p4_debug_colon_RT)
|
static FCode (p4_debug_colon)
|
FCode (p4_debug_does_RT)
|
static FCode (p4_debug_does)
|
/**
|
/**
|
/**
|
/**
|
/**
|
/**
|
P4_LISTWORDS (debug) =
|
/* |