home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
p2demo21.exe
/
PEL
/
DEBUG.PEL
< prev
next >
Wrap
Text File
|
1995-04-04
|
57KB
|
2,048 lines
# $Header: P:\source\wmacros\debug.pev 1.47 04 Apr 1995 18:06:32 PFHDWM0 $
##############################################################################
#
# Compuware Corporation
# 31440 Northwestern Highway
# Farmington Hills, Michigan 48334-2564
#
# This source code listing contains information that is
# proprietary to Compuware Corporation and may not be copied
# duplicated, translated, transmitted, stored, retrieved
# or in any manner or by any method conveyed or disclosed
# to a third party or parties without express written
# permission from Compuware Corporation.
#
#
##############################################################################
#### $Workfile: debug.pel $: sageedit debugger entry points
#
global dhDebug
global original_keymap
local main_window
local main_buffer
local debug_text_fg = COLOR_NEON_BABY_BLUE
local debug_text_bg = COLOR_BLACK
local debug_line_fg = COLOR_RED
local debug_line_bg = COLOR_BLACK
#local debug_color_text = COLOR_NEON_BABY_BLUE
local debug_color_highlight = COLOR_YELLOW
global debug_flip = 1;
local debug_remote_window
local debug_window;
local debug_empty_name = "Debug Window: no function active"
local debug_keymap;
local debug_buffer;
local debug_filename = "";
local debug_enabled # True if debug has been called
local original_window; # Saved when function is debugged.
local original_buffer;
local debug_id;
local debug_tabs = default_buffer_tabs;
local debug_view_file = "???"
local debug_num_steps = 0;
local IDM_FIRST_ITEM = 0x200
local IDM_DEBUG_FILE_OPEN = 0x200
local IDM_DEBUG_FILE_EXIT = 0x201
local IDM_DEBUG_FILE = 0x202
local IDM_DEBUG_BP_LIST = 0x203
local IDM_DEBUG_BP_SETCLR = 0x204
local IDM_DEBUG_BP_CLRALL = 0x205
local IDM_DEBUG_BP = 0x206
local IDM_DEBUG_VIEW_CALLSTACK = 0x207
local IDM_DEBUG_VIEW_LOCALS = 0x208
local IDM_DEBUG_VIEW_VAR = 0x209
local IDM_DEBUG_VIEW = 0x20A
local IDM_DEBUG_RUN_GO = 0x20B
local IDM_DEBUG_RUN_STEPINTO = 0x20C
local IDM_DEBUG_RUN_STEPOVER = 0x20D
local IDM_DEBUG_RUN = 0x20E
local IDM_DEBUG_SEARCH_FORWARD = 0x20F
local IDM_DEBUG_SEARCH_AGAIN = 0x210
local IDM_DEBUG_SEARCH_LINE = 0x211
local IDM_DEBUG_SEARCH = 0x212
local IDM_LAST_ITEM = 0x212
local debug_mta[]
#
# debug_fun_breakpoints is an array of function gids to break on.
# The index is the gid as a string. The value is the gid itself.
# The distinction is important because function_name requires the gid itself.
# debug_fun_lineno are the line numbers of the start of the function,
# determined when we hit it.
#
local debug_fun_breakpoints;
local debug_fun_breakpoint_names;
local debug_fun_bp_types; # 0 = disabled, 1 = enabled, 2 = goto point
local debug_bp_linenos;
local breakpoints_visible = 0;
local ctrl_break_attached = 0;
local BP_ENABLED = 0x01;
local BP_GOTO_POINT = 0x02;
local debug_gid, debug_lineno = 0; # GID and lineno of current debugged function
local debug_step_gid; # GID of function during debug_step
local debug_go_mode;
local debug_tbhand = 0
local debug_menu = 0
local filemenu = 0
local bpmenu = 0
local runmenu = 0
local viewmenu = 0
local searchmenu = 0
#local debug_command_keymap
#local debug_command_window
#local debug_command_buffer
#local CTRL_G = 8711
#local CTRL_T = 5140
local function set_debug_window()
{
current_window = debug_window
current_buffer = debug_buffer
current_keymap = debug_keymap
}
local function set_user_window()
{
current_window = original_window
current_buffer = original_buffer
current_keymap = original_keymap
}
local function update_bp_marks()
{
local old_window = current_window
current_window = debug_window
linenumber_format = linenumber_format
current_window = old_window
}
global debugger_running = 0;
global function debug_reset()
{
debug_gid = 0;
debug_filename = "";
}
global function debug_win( dialogTitle)
{
} #end debug window
local function create_debug_menu( parent )
{
# Create Debugger menu
debug_menu = create_menu()
# File menu
debug_mta[ IDM_DEBUG_FILE_OPEN ] = "~Open..."
debug_mta[ IDM_DEBUG_FILE_EXIT ] = "~Exit"
filemenu = create_menu();
append_menuitem( filemenu, IDM_DEBUG_FILE_OPEN, MI_DEFAULT,
debug_mta[ IDM_DEBUG_FILE_OPEN ], "debug_open" )
append_menuitem( filemenu, IDM_DEBUG_FILE_EXIT, MI_DEFAULT,
debug_mta[ IDM_DEBUG_FILE_EXIT ], "debug_esc" )
append_menuitem( debug_menu, IDM_DEBUG_FILE, MI_SUBDEFAULT, "~File", filemenu )
# Breakpoint submenu
debug_mta[ IDM_DEBUG_BP_LIST ] = "~List..."
debug_mta[ IDM_DEBUG_BP_SETCLR ] = "~Set/Clear"
debug_mta[ IDM_DEBUG_BP_CLRALL ] = "~Clear all"
bpmenu = create_menu();
append_menuitem( bpmenu, IDM_DEBUG_BP_LIST, MI_DEFAULT,
debug_mta[ IDM_DEBUG_BP_LIST ], "debug_breakpoint_list" )
append_menuitem( bpmenu, IDM_DEBUG_BP_SETCLR, MI_DEFAULT,
debug_mta[ IDM_DEBUG_BP_SETCLR ], "bp_line" )
append_menuitem( bpmenu, IDM_DEBUG_BP_CLRALL, MI_DEFAULT,
debug_mta[ IDM_DEBUG_BP_CLRALL ],"bc -1" )
append_menuitem( debug_menu, IDM_DEBUG_BP, MI_SUBDEFAULT, "~Breakpoints", bpmenu )
# Run submenu
debug_mta[ IDM_DEBUG_RUN_GO ] = "~Go"
debug_mta[ IDM_DEBUG_RUN_STEPINTO ] = "~Step into"
debug_mta[ IDM_DEBUG_RUN_STEPOVER ] = "~Step over"
runmenu = create_menu()
append_menuitem( runmenu, IDM_DEBUG_RUN_GO, MI_DEFAULT,
debug_mta[ IDM_DEBUG_RUN_GO ], "debug_go" )
append_menuitem( runmenu, IDM_DEBUG_RUN_STEPINTO, MI_DEFAULT,
debug_mta[ IDM_DEBUG_RUN_STEPINTO ], "debug_trace" )
append_menuitem( runmenu, IDM_DEBUG_RUN_STEPOVER, MI_DEFAULT,
debug_mta[ IDM_DEBUG_RUN_STEPOVER ], "debug_step" )
append_menuitem( debug_menu, IDM_DEBUG_RUN, MI_SUBDEFAULT, "~Run", runmenu )
# View submenu
debug_mta[ IDM_DEBUG_VIEW_CALLSTACK ] = "~Call stack"
debug_mta[ IDM_DEBUG_VIEW_LOCALS ] = "~Local variables"
debug_mta[ IDM_DEBUG_VIEW_VAR ] = "~Variable"
viewmenu = create_menu();
append_menuitem( viewmenu, IDM_DEBUG_VIEW_CALLSTACK, MI_DEFAULT,
debug_mta[ IDM_DEBUG_VIEW_CALLSTACK ], "my_debug_callstack" )
append_menuitem( viewmenu, IDM_DEBUG_VIEW_LOCALS, MI_DEFAULT,
debug_mta[ IDM_DEBUG_VIEW_LOCALS ], "debug_local_variables" )
append_menuitem( viewmenu, IDM_DEBUG_VIEW_VAR, MI_DEFAULT,
debug_mta[ IDM_DEBUG_VIEW_VAR ], "debug_query_var_info" )
append_menuitem( debug_menu, IDM_DEBUG_VIEW, MI_SUBMENU+MI_DISABLED, "~View", viewmenu )
# Search submenu
debug_mta[ IDM_DEBUG_SEARCH_FORWARD ] = "~Search"
debug_mta[ IDM_DEBUG_SEARCH_AGAIN ] = "Search ~again"
debug_mta[ IDM_DEBUG_SEARCH_LINE ] = "~Goto line"
searchmenu = create_menu();
append_menuitem( searchmenu, IDM_DEBUG_SEARCH_FORWARD, MI_DEFAULT,
debug_mta[ IDM_DEBUG_SEARCH_FORWARD ], "search_forward" )
append_menuitem( searchmenu, IDM_DEBUG_SEARCH_AGAIN, MI_DEFAULT,
debug_mta[ IDM_DEBUG_SEARCH_AGAIN ], "search_again" )
append_menuitem( searchmenu, IDM_DEBUG_SEARCH_LINE, MI_DEFAULT,
debug_mta[ IDM_DEBUG_SEARCH_LINE ], "goto_line_key" )
append_menuitem( debug_menu, IDM_DEBUG_SEARCH, MI_SUBDEFAULT, "~Search", searchmenu )
change_menu( debug_menu, parent )
}
# disable all invalid menu options
local function disable_debug_menu()
{
modify_menuitem( debug_menu, IDM_DEBUG_VIEW, MI_DISABLED )
modify_menuitem( debug_menu, IDM_DEBUG_RUN, MI_DISABLED )
}
# enable all invalid menu options
local function enable_debug_menu()
{
modify_menuitem( debug_menu, IDM_DEBUG_VIEW, MI_ENABLED )
modify_menuitem( debug_menu, IDM_DEBUG_RUN, MI_ENABLED )
}
# This function will use the given id and change the menu text so that
# the key assigned to the function that the menu item executes is displayed
# on the menu
#
local function fix_debug_menu_text()
{
local keys
local tab = "\t"
local functionid
local menuid
local oldLevel = message_level
for ( menuid in debug_mta )
{
functionid = function_id( menu_functions[menuid] )
# make sure it's valid
if ( functionid )
{
# turn of messages
message_level = 3
# Get the list of keys bound to the id with no angle brackets and
# with the "+" as separator within the key name
#
keys = function_binding_key( functionid, 1, 1)
modify_menuitem( debug_menu, menuid, MI_ITEMTEXT, debug_mta[menuid] tab keys )
}
}
# restore old message level
message_level = oldLevel
}
local curr_bmp_pos = 0
local function bmp_pos( pos )
{
if ( pos == -1 )
curr_bmp_pos = 0
else if ( pos == TRUE )
curr_bmp_pos += 34
else
curr_bmp_pos += 27
return curr_bmp_pos
}
local function create_debug_toolbar( parent )
{
# copied here from tbar.pel for debugger use
local TBMP_FIND = 10
local TBMP_FINDNEXT = 11
local TBMP_GO = 20
local TBMP_STEP_INTO = 21
local TBMP_STEP_OVER = 22
local TBMP_DEBUG_END = 23
local TBMP_SETBP = 24
local TBMP_QUERY = 25
debug_tbhand = create_toolbar( parent )
insert_toolbaritem( debug_tbhand, IDM_DEBUG_RUN_GO, TOOLBAR_BUTTON, bmp_pos(-1), 4,
TBMP_GO,
function_id( "debug_go" ) )
insert_toolbaritem( debug_tbhand, IDM_DEBUG_RUN_STEPINTO, TOOLBAR_BUTTON, bmp_pos(1), 4,
TBMP_STEP_INTO,
function_id( "debug_trace" ) )
insert_toolbaritem( debug_tbhand, IDM_DEBUG_RUN_STEPOVER, TOOLBAR_BUTTON, bmp_pos(0), 4,
TBMP_STEP_OVER,
function_id( "debug_step" ) )
insert_toolbaritem( debug_tbhand, IDM_DEBUG_SEARCH_FORWARD, TOOLBAR_BUTTON, bmp_pos(1), 4,
TBMP_FIND,
function_id( "search_forward" ) )
insert_toolbaritem( debug_tbhand, IDM_DEBUG_SEARCH_AGAIN, TOOLBAR_BUTTON, bmp_pos(0), 4,
TBMP_FINDNEXT,
function_id( "search_again" ) )
insert_toolbaritem( debug_tbhand, IDM_DEBUG_BP_SETCLR, TOOLBAR_BUTTON, bmp_pos(1), 4,
TBMP_SETBP,
function_id( "bp_line" ) )
insert_toolbaritem( debug_tbhand, TBMP_QUERY, TOOLBAR_BUTTON, bmp_pos(0), 4,
TBMP_QUERY,
function_id( "debug_query_var_info" ) )
# insert_toolbaritem( debug_tbhand, IDM_DEBUG_FILE_EXIT, TOOLBAR_BUTTON, bmp_pos(1), 4,
# TBMP_DEBUG_END,
# function_id( "debug_esc" ) )
show_toolbar( debug_tbhand )
return debug_tbhand
}
local function create_debug_keymap()
{
original_keymap = current_keymap
if ( !debug_keymap )
{
debug_keymap = create_keymap( ascii_keymap )
push_keymap( debug_keymap )
#
# define command keymap bindings for the debug window and
# the command window.
#
assign_key( "<Up>", "up" )
assign_key( "<Down>", "down" )
assign_key( "<Left>", "left" )
assign_key( "<Right>", "right" )
assign_key( "<PageUp>", "page_up" )
assign_key( "<PageDown>", "page_down" )
assign_key( "<Home>", "goto_bol" )
assign_key( "<End>", "goto_eol" )
assign_key( "<Num-Up>", "up" )
assign_key( "<Num-Down>", "down" )
assign_key( "<Num-Left>", "left" )
assign_key( "<Num-Right>", "right" )
assign_key( "<Num-PageUp>", "page_up" )
assign_key( "<Num-PageDown>", "page_down" )
assign_key( "<Num-Home>", "goto_bol" )
assign_key( "<Num-End>", "goto_eol" )
assign_key( "<F5>", "debug_go" )
assign_key( "<F8>", "debug_trace" )
assign_key( "<F9>", "bp_line" )
assign_key( "<F10>", "debug_step" )
assign_key( "<Alt-C>", "my_debug_callstack" )
assign_key( "<Alt-S>", "search_forward" )
assign_key( "<Alt-A>", "search_again" )
assign_key( "<F9>", "bp_line" )
assign_key( "a", "search_again" )
assign_key( "b", "debug_breakpoint_list" )
assign_key( "g", "goto_line_key" )
assign_key( "s", "search_forward" )
assign_key( "v", "debug_open" )
assign_key( "A", "search_again" )
assign_key( "B", "debug_breakpoint_list" )
assign_key( "G", "goto_line_key" )
assign_key( "S", "search_forward" )
assign_key( "V", "debug_open" )
}
else
push_keymap( debug_keymap )
# pop_keymap()
}
local function create_debug_display_window( parent )
{
current_window = debug_window = create_factory_window( 0, 0,
0, 0,
WINDOW_VERT_SB +
WINDOW_HORIZ_SB +
WINDOW_SYSTEM +
WINDOW_EXPANDED +
0x8,
parent )
expand_window()
linenumber_format = " %5d:%m "
color_window_fg = debug_text_fg
color_window_bg = debug_text_bg
color_linenumbers_fg = debug_line_fg
color_linenumbers_bg = debug_line_bg
if ( debug_buffer )
delete_buffer( debug_buffer )
debug_buffer = create_buffer( debug_empty_name,
"",
BUFFER_SYSTEM +
BUFFER_NO_UNDO +
BUFFER_READ_ONLY )
}
local function debug_init()
{
local cw;
local cb;
local i;
local win_height
local debug_sbar_flags
# This was taken out because this function is only called if a
# window is open.
# if ( !current_window )
# {
# current_window = create_window( 0, 0, display_width, display_height);
# attach_window_buffer( current_window, current_buffer );
# }
# DWM 5/10/94
original_window = current_window
original_buffer = current_buffer
original_keymap = current_keymap
cw = current_window
cb = current_buffer
if ( debug_enabled )
{
expand_window( debug_window )
debug_reset()
return;
}
debug_enabled = 1
debug_go_mode = 0
debug_id = function_id( "debug_fun" )
debug_sbar_flags = status_bar_flags
debug_remote_window = create_remote_window( "Pel Debugger" )
status_bar_flags = debug_sbar_flags
create_debug_toolbar( debug_remote_window )
create_debug_menu( debug_remote_window )
create_debug_display_window( debug_remote_window )
create_debug_keymap()
fix_debug_menu_text()
attach_window_buffer( debug_window, debug_buffer );
scroll_context_top = 0;
scroll_context_bottom = 0;
set_debug_window()
}
# array containing all non-debugger mouse events
local debug_event_handlers[]
# call original event handlers of mouse_event
local function original_handler( mouse_event )
{
local handler
for ( handler in debug_event_handlers[ mouse_event ] )
execute_function( debug_event_handlers[mouse_event][handler] )
}
global function dummy_handler()
{
local mouse_event = event_id
if ( current_window == debug_window )
{
if ( mouse_event == EVENT.MOUSE_LEFT_CLICK2 )
debug_lmouse_double_click()
else if ( mouse_event == EVENT.MOUSE_LEFT_DOWN )
{
goto_pos( mouse_event_y + window_first, mouse_event_x + window_margin + 1 );
update_current_view();
}
else if ( mouse_event == EVENT.EXIT_EDITOR )
{
debug_esc()
original_handler()
}
}
else
original_handler( mouse_event )
}
local function override_events()
{
local event
local mouse_events[]
local mouse_drag_events[]
local exit_events[]
local dummy_handler_id = function_id( "dummy_handler" )
# store all mouse event handlers
mouse_events = save_and_remove_events( EVENT.MOUSE_LEFT_DOWN, EVENT.MOUSE_MID_CLICK2 )
mouse_drag_events = save_and_remove_events( EVENT.LMOUSE_DRAG, EVENT.RMOUSE_DRAG )
exit_events = save_and_remove_events( EVENT.EXIT_EDITOR, EVENT.EXIT_EDITOR )
debug_event_handlers = merge_arrays( mouse_events, mouse_drag_events )
debug_event_handlers = merge_arrays( debug_event_handlers, exit_events )
# attach dummy handlers for all mouse events
for ( event in debug_event_handlers )
attach_event_handler( event, dummy_handler_id )
attach_event_handler( EVENT.NEW_CURNT_WINDOW, "changing_windows" )
attach_event_handler( EVENT.CLOSING_REMOTE_WINDOW, "debug_esc" )
}
local function debug_restore_events()
{
local event
local dummy_handler_id = function_id( "dummy_handler" )
# delete dummy handlers for all mouse events
for ( event in debug_event_handlers )
delete_event( event, dummy_handler_id )
restore_events( debug_event_handlers )
delete debug_event_handlers
delete_event( EVENT.NEW_CURNT_WINDOW, "changing_windows" )
delete_event( EVENT.CLOSING_REMOTE_WINDOW, "debug_esc" )
}
# Invoke this to start debugging.
#
function debug()
{
local gid;
local fn;
local user_file = buffer_filename
local user_line = 1
if(!current_window)
{
warning("PEL Debugger may not be run with no windows open.");
return FALSE;
}
# DWM 4/4/95
# Why would this only be useful for modified buffers?
#if ( and(buffer_flags, BUFFER_MODIFIED) )
user_line = current_line
main_window = current_window
main_buffer = current_buffer
attach_break_handler()
override_events()
debug_function( 0 );
debug_init()
# if the user is looking at a pel file, load it
if ( path_ext(user_file) == ".pel" && path_fname(user_file) != "debug" )
{
debug_filename = user_file
debug_view( user_file, user_line )
}
# Put debugger in trace mode.
debug_step_gid = 0
debug_go_mode = 0
debug_num_steps = 0;
for ( gid in debug_fun_breakpoints )
{
if ( and(debug_fun_bp_types[gid], BP_GOTO_POINT) )
debug_remove_goto_point( gid );
}
if ( debugger_running )
debugger_running = 0;
debug_fun( 0, 1 );
}
function changing_windows ()
{
if ( current_window == debug_window )
{
if ( current_keymap != debug_keymap )
original_keymap = current_keymap
if ( debug_keymap )
current_keymap = debug_keymap
if ( !debug_go_mode && debugger_running )
highlight_line()
else
unhighlight_line()
}
else
{
current_keymap = original_keymap
if ( !debug_enabled )
debug_reset()
}
}
# Step over function call.
# This will not work if the function is called recursively.
function debug_step()
{
if ( !debug_go_mode )
{
if ( debug_gid )
{
debug_go_mode = 0
debug_step_gid = debug_gid
process_end( 1 )
}
else
debug_view( debug_view_file )
}
else
beep()
}
function debug_trace()
{
if ( !debug_go_mode )
{
debug_go_mode = 0
debug_step_gid = 0
process_end( 1 )
}
else
beep()
}
function debug_esc()
{
local i
local event = event_id
debug_function( 0 )
debug_restore_events()
debug_go_mode = 0
debug_step_gid = 0
debug_enabled = 0
debug_view_file = "???";
debug_filename = ""
debug_reset()
pop_keymap()
remove_break_handler()
if ( debug_menu )
{
# delete our local list that maps function id's to menu item
# id's. This list was created during the append_menuitem calls.
for ( i = IDM_FIRST_ITEM; i <= IDM_LAST_ITEM; i++ )
if ( i in menu_functions )
delete menu_functions[i]
delete_menu( filemenu, debug_remote_window )
delete_menu( bpmenu, debug_remote_window )
delete_menu( runmenu, debug_remote_window )
delete_menu( viewmenu, debug_remote_window )
delete_menu( searchmenu, debug_remote_window )
delete_menu( debug_menu, debug_remote_window )
debug_menu = 0
filemenu = 0
bpmenu = 0
runmenu = 0
viewmenu = 0
searchmenu = 0
}
if ( debug_tbhand )
{
delete_toolbar( debug_tbhand )
debug_tbhand = 0
}
if ( bl_hdlg )
{
delete_dialog( bl_hdlg )
bl_hdlg = 0
}
if ( debug_keymap )
{
delete_keymap( debug_keymap )
debug_keymap = 0
}
enable_all_windows()
set_user_window()
debug_enabled = FALSE
if ( event != EVENT.CLOSING_REMOTE_WINDOW )
{
delete_remote_window( debug_remote_window )
debug_remote_window = 0
debug_window = 0
}
process_end( 0 )
}
# If name is a function parameter or local variable of the current
# function being debugged, then return the index of that variable.
# stframe is the frame number of the function desired.
local function debug_find_stvar(varname,stframe)
{
local x, list,list1,n,i
if ((x = debug_get_frame(stframe)))
{
split(x[4],list1,";") # x[4] is the parameter;local list
n = split(list1[1],list) # list1[1] is the parameters
for (i = 1; i <= n; i++)
{
if (list[i] == varname)
return(i)
}
n = split(list1[2],list) # list1[2] is the locals
for (i = 1; i <= n; i++)
{
if (list[i] == varname)
return(- i)
}
}
return( 0 )
}
#
# Clear Breakpoint
#
function bc( bpindex )
{
local gid
local mark
if ( bpindex >= 0 )
{
gid = bpindex_to_gid( bpindex )
if ( gid && gid in debug_fun_breakpoints )
{
mark = debug_marks[ debug_fun_breakpoints[ gid ] ]
if ( mark )
delete_mark( mark )
delete debug_fun_breakpoints[ gid ]
delete debug_fun_breakpoint_names[ gid ]
delete debug_fun_bp_types[ gid ]
}
}
# Clear all breakpoints
else
{
for ( gid in debug_fun_breakpoints )
{
mark = debug_marks[ debug_fun_breakpoints[ gid ] ]
if ( mark )
delete_mark( mark )
}
delete debug_fun_breakpoints
delete debug_fun_breakpoint_names;
delete debug_fun_bp_types;
}
update_bl( bpindex )
}
#
# Disable Breakpoint
#
function bd( bpindex )
{
local gid
if ( bpindex >= 0 )
{
gid = bpindex_to_gid( bpindex )
if ( gid && gid in debug_fun_breakpoints )
debug_fun_bp_types[ gid ] = and( debug_fun_bp_types[gid], not(BP_ENABLED) )
}
else
{
for ( gid in debug_fun_bp_types )
debug_fun_bp_types[ gid ] = and( debug_fun_bp_types[gid], not(BP_ENABLED) )
}
update_bl( bpindex )
}
#
# Enable Breakpoint
#
function be( bpindex )
{
local gid
if ( bpindex >= 0 )
{
gid = bpindex_to_gid( bpindex );
if ( gid )
debug_fun_bp_types[ gid ] = or( debug_fun_bp_types[ gid ], BP_ENABLED )
}
else
{
for ( gid in debug_fun_bp_types )
debug_fun_bp_types[ gid ] = or( debug_fun_bp_types[ gid ], BP_ENABLED )
}
update_bl( bpindex )
}
#
# Set Breakpoints
#
function bp( funname )
{
local gid = 0
local i = 0;
debug_init()
gid = function_id( funname )
# This is magic: acceptable gids lie in the range 1000 to 8000
if ( !(!gid || (gid < 1000 || gid >= 8000)) )
{
debug_fun_breakpoints[gid] = 0
debug_fun_breakpoint_names[gid] = function_name( gid );
# DWM 1/24/94
# The old concept of a BP_GOTO_POINT doesn't exist anymore.
# debug_fun_bp_types[gid] = debug_go_mode ? BP_ENABLED + BP_GOTO_POINT : BP_ENABLED;
debug_fun_bp_types[gid] = BP_ENABLED;
if ( !debugger_running )
{
debug_go_mode = 1;
debug_step_gid = 0;
debug_function(debug_id)
}
}
update_bl( gid_to_bpindex(gid) )
return gid;
}
local debug_marks[]
function bp_line()
{
local fn;
local mark
if ( debug_view_file )
{
fn = buildpath( debug_view_file ) ":" current_line;
if ( fn in debug_fun_breakpoints )
{
delete( debug_fun_breakpoints[fn] );
delete( debug_fun_bp_types[fn] );
delete( debug_fun_breakpoint_names[fn] );
delete_mark( debug_marks[ current_line ] )
linenumber_format = linenumber_format
}
else
{
debug_bp_linenos[ current_line ] = 1;
debug_fun_breakpoints[ fn ] = current_line;
debug_fun_bp_types[ fn ] = BP_ENABLED;
debug_fun_breakpoint_names[ fn ] = fn;
mark = pick_unused_mark()
create_mark( mark )
debug_marks[ current_line ] = mark
linenumber_format = linenumber_format
breakpoints_visible = 1;
}
update_bl( gid_to_bpindex(fn) )
}
}
function debug_go()
{
debug_step_gid = 0;
debug_go_mode = 1
process_end( 1 )
set_user_window()
}
global function disable_all_windows()
{
local start_win
local cur_win
set_editwin_property( EWC_DISABLE, 0 )
#set_editwin_property( 18, 0 )
start_win = current_window
cur_win = next_window( "", 0, 1 )
while ( cur_win != start_win )
{
if ( cur_win != debug_window )
set_editwin_property( EWC_DISABLE, cur_win )
cur_win = next_window( "", 0, 1 )
}
if ( cur_win != debug_window )
set_editwin_property( EWC_DISABLE, cur_win )
#set_editwin_property( 18, debug_remote_window )
}
global function enable_all_windows()
{
local start_win
local cur_win
set_editwin_property( EWC_ENABLE, 0 )
#set_editwin_property( 18, 0 )
start_win = current_window
cur_win = next_window( "", 0, 1 )
while ( cur_win != start_win )
{
if ( cur_win != debug_window )
set_editwin_property( EWC_ENABLE, cur_win )
cur_win = next_window( "", 0, 1 )
}
if ( cur_win != debug_window )
set_editwin_property( EWC_ENABLE, cur_win )
#set_editwin_property( 18, debug_remote_window )
}
# Call this with the gid and line number of function being debugged,
# or with gid == 0 to just bring up the debugger on nothing.
# debug_session returns 1 to continue debugging, 0 to quit
local function debug_session()
{
local filename = debug_filename;
local cb;
attach_break_handler()
if ( current_window != debug_window )
{
original_window = current_window
original_keymap = current_keymap
original_buffer = current_buffer
}
if ( !debugger_running )
debugger_running = 1;
debug_at()
disable_all_windows()
if ( debug_gid )
enable_debug_menu()
debugger_running = process_begin() + 0
enable_all_windows()
if ( debug_enabled )
disable_debug_menu()
set_user_window()
if ( debugger_running != 0 )
pop_keymap()
return( debugger_running )
}
local function debug_file_display( filename )
{
local def_buf_eol = default_buffer_eol_string;
debug_view_file = filename;
delete_buffer( debug_buffer )
default_buffer_eol_string = "\r\n"
current_buffer = debug_buffer =
create_buffer( debug_gid \
? "FILE: " debug_filename " FUNCTION: " function_name(debug_gid) \
: debug_empty_name,
debug_filename,
BUFFER_SYSTEM + BUFFER_NO_UNDO + BUFFER_READ_ONLY )
default_buffer_eol_string = def_buf_eol;
buffer_tabs = debug_tabs;
attach_window_buffer( debug_window, debug_buffer );
}
function debug_at()
{
if ( current_window != debug_window )
set_debug_window()
#
# if the current file displayed doesn't equal the one that's
# suppose to be displayed, find the one to display
#
if ( debug_filename != debug_view_file )
{
debug_filename = debug_gid ? get_source_file_name(debug_gid) : "";
debug_file_display( debug_filename );
debug_file_display( debug_filename );
}
if ( debug_gid )
{
current_line = debug_lineno;
unhighlight_line()
center_cursor();
highlight_line( debug_color_highlight );
}
}
local currentFrame = 1;
# Gid is the function_id of the function being executed.
# lineno is the line number in that function.
#
function debug_fun(gid,lineno)
{
local fn;
local i,ln;
local x;
local done;
local ck
ck = current_keymap
if ( ck != debug_keymap )
original_keymap = ck
# If we are performing a debug_step function,
# keep going until we get back to the function
# we did the step in or stepping out of.
#
done = 0
if ( debug_step_gid && (gid != debug_step_gid) )
{
if ( debug_get_frame(currentFrame) )
{
debug_function( debug_id )
return;
}
}
# If we are performing a debug_go function, keep going
# until a breakpoint is reached.
# We remember the first line number of each function.
if ( debug_go_mode )
{
if ( (gid in debug_fun_breakpoints) &&
and(debug_fun_bp_types[gid], BP_ENABLED) &&
(!debug_fun_breakpoints[gid] || (debug_fun_breakpoints[gid] == lineno)) )
{
if ( !debug_fun_breakpoints[gid] )
debug_fun_breakpoints[gid] = lineno;
if ( and(debug_fun_bp_types[gid], BP_GOTO_POINT) )
debug_remove_goto_point( gid );
}
else if ( lineno in debug_bp_linenos )
{
fn = gid ? get_source_file_name( gid ) ":" lineno : ""
# if ( !(fn in debug_fun_breakpoints) && and(debug_fun_bp_types[fn], BP_ENABLED) )
if ( !(fn in debug_fun_breakpoints) )
{
debug_function( debug_id )
return;
}
delete( debug_bp_linenos );
for ( i in debug_fun_breakpoints )
if ( (ln = debug_fun_breakpoints[i]) )
debug_bp_linenos[ ln ] = ln;
} # if lineno in debug_bp_linenos
else
{
debug_function( debug_id )
return;
}
debug_go_mode = 0;
debug_num_steps = 0;
} # if debug_go_mode
if ( debug_gid != gid )
{
debug_filename = gid ? get_source_file_name(gid) : "";
debug_gid = gid;
if ( path_fname(debug_filename) == "debug" &&
path_ext(debug_filename) == ".pel" )
{
# DWM 5/20/94
# don't quit debugger when we get
# into debug code, just step over it
debug_function( debug_id )
return;
#debug_esc()
#current_keymap = original_keymap
#return;
}
}
debug_lineno = lineno;
for ( currentFrame=0; debug_get_frame(currentFrame+1); currentFrame++ )
continue;
remove_break_handler()
if ( debug_session() )
{
debug_function( debug_id )
attach_break_handler()
}
}
local function debug_remove_goto_point( gid )
{
delete( debug_fun_breakpoints[gid] )
delete( debug_fun_bp_types[gid] )
delete( debug_fun_breakpoint_names[gid] )
}
local function bpindex_to_gid( index )
{
local gid
for ( gid in debug_fun_bp_types )
{
if ( !index )
return gid
index--;
}
return 0
}
local function gid_to_bpindex( gid )
{
local bpindex = 0
local curr_gid
for ( curr_gid in debug_fun_bp_types )
{
if ( gid == curr_gid )
break
bpindex++
}
if ( gid != curr_gid )
bpindex = -1
return bpindex
}
function debug_view( fname, line )
{
local cb = current_buffer;
local def_buf_eol = default_buffer_eol_string;
fname = ltrim( trim( fname ) )
default_buffer_eol_string = "\r\n"
current_buffer = create_buffer( "FILE: " path_fname(fname) path_ext(fname),
fname,
BUFFER_SYSTEM +
BUFFER_NO_UNDO +
BUFFER_READ_ONLY )
default_buffer_eol_string = def_buf_eol;
if ( buffer_size )
{
buffer_tabs = debug_tabs;
#new_buf = current_buffer
#current_buffer = debug_buffer
delete_buffer(debug_buffer);
debug_buffer = current_buffer
# debug_buffer = new_buf;
#current_buffer = debug_buffer
# debug_buffer = current_buffer;
#if ( buffer_last_line >= line )
# ;
# if ( argcount() > 1 && buffer_last_line >= line )
current_line = line
debug_view_file = fname;
attach_window_buffer( debug_window, debug_buffer )
}
else
current_buffer = cb;
}
#local y_highlight = -1;
#local y_ext = -1;
#local x_ext = -1;
local function highlight_line( attr )
{
remove_selection()
update_current_view()
save_position()
current_line = debug_lineno
begin_selection(LINE_SELECTION)
end_selection()
update_current_view()
restore_position(TRUE)
}
local function unhighlight_line()
{
remove_selection()
update_current_view()
# if ( breakpoints_visible )
# {
# breakpoints_visible = 0;
# update_current_view()
# }
# else
# {
# # use the last highlighted line setting to unhighlight
# #
# if ( (y_highlight >= 0) && (y_highlight < y_ext) )
# {
# highlight_window( 0, y_highlight, x_ext, 1, debug_color_text,
# debug_window );
# }
# }
#
# y_highlight = -1;
}
local function get_source_file_name( gid )
{
local fn = source_file_name( gid );
local src_name;
if (findfirst( fn ) == "")
return buildpath( path_fname( fn ) path_ext( fn ) );
else
return fn;
}
global function debug_ctrl_break()
{
debug_num_steps = 0;
debug_go_mode = 0;
}
function attach_break_handler()
{
if (!ctrl_break_attached)
{
attach_event_handler( EVENT.CTRL_BREAK, function_id( "debug_ctrl_break" ));
ctrl_break_attached = 1;
}
}
function remove_break_handler()
{
if (ctrl_break_attached)
{
delete_event( EVENT.CTRL_BREAK, function_id( "debug_ctrl_break" ) )
ctrl_break_attached = 0;
}
}
local function my_debug_cvdebug(outline)
{
local MAX = 80;
outline = prefix(outline, MAX);
cvdebug(outline);
}
local my_debug_gid = 0
local my_last_gid = 0
local my_target_gid = 0
local my_do_callstack = FALSE
local my_last_stacklevel = 0
local my_debug_level = 0
local my_last_caller = 0
global function my_debug_fun( gid, lineno )
{
local currentFrame
if ( !my_debug_gid )
my_debug_gid = function_id("my_debug_fun")
if ( argcount() > 0 && gid && gid != my_debug_gid )
{
if ( my_target_gid != 0 && gid == my_target_gid )
{
if ( argcount() < 2 )
lineno = -1
if ( my_do_callstack )
{
my_debug_callstack()
my_do_callstack = FALSE
}
else
my_debug_fun_call( my_debug_level, currentFrame )
}
else if ( my_target_gid == 0 && gid != my_last_gid )
{
if ( argcount() < 2 )
lineno = -1
for ( currentFrame=0; debug_get_frame(currentFrame+1); currentFrame++ )
continue;
if ( my_last_stacklevel && currentFrame > my_last_stacklevel )
{
my_last_caller = my_last_gid
my_debug_cvdebug(sprintf("%s{", strrepeat("\t",my_last_stacklevel-1) ));
}
if ( my_last_stacklevel && currentFrame < my_last_stacklevel )
my_debug_cvdebug(sprintf( "%s}", strrepeat("\t",currentFrame-1) ));
if ( gid != my_last_caller )
my_debug_fun_call( my_debug_level, currentFrame )
my_last_stacklevel = currentFrame
}
my_last_gid = gid
}
debug_function( my_debug_gid )
}
global function my_debug( onOff )
{
if ( argcount() > 0 && !onOff )
debug_function( 0 )
else
my_debug_fun( 0, 0 )
}
global function my_debug_var_at( fname, var_name )
{
}
global function my_debug_at_fun( fname )
{
my_target_gid = function_id( fname )
my_do_callstack = FALSE
# cvdebug( "targetting %s(%d)", fname, my_target_gid )
return my_target_gid
}
global function my_debug_in( file_name )
{
}
global function my_debug_callstack()
{
local list[]
local vars[]
local x[]
local argc = 0
local i = 1
local n = 1
local arglist = ""
local var_val = ""
local var_type = ""
local popbuf[]
if (!debug_gid)
return;
for (n=1; (x = debug_get_frame(n)); n++)
{
# x[1] is gid, x[2] is lineno, x[3] is argc, x[4] is param list
# Create the list of function arguments
argc = x[3]
split( x[4], list, ";" ) # list[1] = parameters, list[2] = local vars
split( list[1], vars )
for (i = 1; i <= argc; i++)
{
var_val = debug_get_stack_var( 1, i )
var_type = typeof( var_val )
if ( var_type == "string" || var_type == "regular expression" )
var_val = "\"" var_val "\""
if ( var_val )
{
arglist = arglist vars[i] "=" var_val
if ( i != argc )
arglist = arglist ", "
}
}
popbuf[ n ] = sprintf( "%s %d: %s( %s )",
get_source_file_name(x[1]),
x[2],
function_name( x[1] ),
arglist )
}
debug_display_info( popbuf, "Pel Debugger: Call Stack" )
}
function my_debug_fun_call()
{
local list[]
local vars[]
local x[]
local argc = 0
local i = 1
local arglist = ""
local var_val = ""
local var_type = ""
x = debug_get_frame( 1 )
# x[1] is gid, x[2] is lineno, x[3] is argc, x[4] is param list
# Create the list of function arguments
argc = x[3]
split( x[4], list, ";" ) # list[1] = parameters, list[2] = local vars
split( list[1], vars )
for (i = 1; i <= argc; i++)
{
var_val = debug_get_stack_var( 1, i )
var_type = typeof( var_val )
if ( var_type == "string" || var_type == "regular expression" )
var_val = "\"" var_val "\""
if ( var_val )
{
arglist = arglist vars[i] "=" var_val
if ( i != argc )
arglist = arglist ", "
}
}
cvdebug( "%s %d: %s( %s )",
get_source_file_name(x[1]),
x[2],
function_name( x[1] ),
arglist )
}
# displays type/value of named var
global function debug_query_var_info( var )
{
local type = ""
local i = 0
local value = 0
local var_fid = 0
local info[]
local str
if ( !var )
{
str = symbol_under_cursor()
var = prompt_history( "DEBUG_QUERY", "Query pel var: ", str, str ? FALSE : TRUE, 1, "debug_query_prompt" )
}
if ( var )
{
i = debug_find_stvar( var, 1 )
if ( i != 0 )
{
value = debug_get_stack_var( 1, i )
type = typeof( value )
}
else
{
# try for a var local to the file
var_fid = function_id( path_fname(debug_filename) ":" var )
# else see if its a global var
if ( !var_fid )
var_fid = function_id( var )
if ( var_fid )
{
# is it a user function id?
if ( var_fid >= 1000 && var_fid <= 2999 )
{
value = var_fid
type = typeof( var_fid )
}
else
{
# switch context in case its buffer_filename, etc
set_user_window()
value = execute_function( var_fid )
set_debug_window()
type = typeof( value )
}
}
}
if ( type )
{
if ( type == "string" )
value = "\"" value "\""
if ( type == "array" )
display_array( value )
else
{
info[ 1 ] = type " " var " : " value
debug_display_info( info, "Pel Debugger: Inspector" )
}
}
else
beep()
}
}
global function debug_lmouse_double_click()
{
local var = ""
if ( current_window == debug_window )
{
var = symbol_under_cursor()
if ( var && debug_gid && mouse_event_x >= 1 )
debug_query_var_info( var )
else if ( mouse_event_x < 1 )
bp_line()
}
}
local function debug_display_info( info, title )
{
local i = ""
local width = 30
local dhArray
# check argument type
if ( typeof( info ) != "array" )
return
if ( !title )
title = "Pel Debugger"
# create a dialog box for the list
dhArray = create_selection_dialog( title, width )
set_dialog_item( dhArray, DI_OK, DAC_HIDE)
# insert the array contents
for ( i in info )
{
set_dialog_item( dhArray, IDL_LIST, DAC_ADD_ITEM, info[i] )
}
begin_dialog(dhArray)
}
global function debug_local_variables()
{
local list[]
local vars[]
local local_list[]
local type = ""
local value = ""
local pad = 0
local frame = 0
local n = 0
local i = 1
local j = 1
local longest_var = 0
local longest_type = 0
if ( (frame = debug_get_frame(1)) )
{
split( frame[4], vars, ";" ) # frame[4] is the parameter;local list
n = split( vars[1], list ) # vars[1] is the parameters
longest_var = 0
for (i = 1; i <= n; i++)
longest_var = max( length( list[i] ), longest_var )
longest_var += 5
longest_type = 0
for (i = 1; i <= n; i++)
longest_type = max( length( typeof(list[i]) ), longest_type )
longest_type += 5
j = 1
for (i = 1; i <= n; i++,j++)
{
value = debug_get_stack_var( 1, i )
type = typeof( value )
if ( type == "string" && value == "" )
value = "\"\""
local_list[ j ] = sprintf( "%s%s %s%s : %s",
type,
strrepeat(" ", longest_type - length(type) ),
list[i],
strrepeat(" ", longest_var - length(list[i]) ),
value )
}
n = split( vars[2], list ) # vars[2] is the locals
longest_var = 0
for (i = 1; i <= n; i++)
longest_var = max( length( list[i] ), longest_var )
longest_var += 5
longest_type = 0
for (i = 1; i <= n; i++)
longest_type = max( length( typeof(list[i]) ), longest_type )
longest_type += 5
for (i = 1; i <= n; i++,j++)
{
value = debug_get_stack_var( 1, -i )
type = typeof( value )
if ( type == "string" && value == "" )
value = "\"\""
local_list[ j ] = sprintf( "%s%s %s%s : %s",
type,
strrepeat(" ", longest_type - length(type) ),
list[i],
strrepeat(" ", longest_var - length(list[i]) ),
value )
}
}
debug_display_info( local_list, "Pel Debugger: Local Variables" )
}
local function debug_calc_functions()
{
local i
local j
local sorted_global_funs[]
local sorted_local_funs[]
local global_funs = symbol_match( "", 0x4 )
local local_funs = symbol_match( "", 0x10 )
local fun_list[]
message( "Working..." )
# sort global functions
for ( i in global_funs )
sorted_global_funs[ global_funs[ i ] ] = i
# add globals to info list
j = 1
for ( i in sorted_global_funs )
fun_list[ j++ ] = i
# sort local functions
for ( i in local_funs )
sorted_local_funs[ local_funs[ i ] ] = i
# append locals to info list
for ( i in sorted_local_funs )
fun_list[ j++ ] = i
return fun_list
}
global function my_debug_functions()
{
debug_display_info( debug_calc_functions(), "Pel Debugger: User Functions" )
}
#
# List Breakpoints
#
global function my_debug_bl()
{
local i
local j
local info[]
j = 0
for ( i in debug_fun_breakpoint_names )
info[ j + 1 ] = sprintf("%4d %s %s",
j++,
and(debug_fun_bp_types[i],BP_ENABLED) ? "Enabled " : "Disabled",
debug_fun_breakpoint_names[i] )
debug_display_info( info, "Pel Debugger: Breakpoint List" )
}
local lastPath = "*.pel"
global function debug_open()
{
local fileArray[]
local fileToOpen
local str
local file
local mode
# if infileToOpen is specified use it otherwise use
# use the last path that was used.
fileToOpen = open_dialog( lastPath, "Open" )
split( fileToOpen, fileArray, ";" )
file = fileArray[ 2 ]
if ( file )
{
str = buildpath( file )
mode = filemode(str)
if ( str && mode != -1 && mode != _SUBDIR )
{
lastPath = path_path( str ) "*.pel"
debug_view( str )
}
else
beep()
}
}
local DI_ABLE_BUTTON = DI_NEXT_BUTTON
local DI_CLEAR_BUTTON = DI_PREV_BUTTON
local DI_CLEAR_ALL_BUTTON = DI_STOP_BUTTON
local function debug_create_bl_dlg()
{
local dlgid
local newtitle
local id = 1
local callbackid = function_id( "debug_bl_callback" )
dlgid = create_mdialog( callbackid, 0, DLG_LIST_DIALOG, resource_dll )
set_dialog_item( dlgid, DI_GOTO_BUTTON, DAC_DISABLE )
add_dialog_item( dlgid, DI_STOP_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_CLEAR_ALL_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, IDL_LIST, DCTRL_LIST_BOX )
# add items for the buttons. Since the buttons are disabled the assumed type
# is incorrect so we must explicitly tell the dialog manager what type these
# controls are.
add_dialog_item( dlgid, DI_GOTO_BUTTON, DCTRL_DEFAULT_PUSH_BUTTON )
add_dialog_item( dlgid, DI_CLEAR_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_ABLE_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_CLEAR_ALL_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_HELP, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, IDL_LIST, DCTRL_LIST_BOX )
add_dialog_item( dlgid, IDB_CLOSE_BTN, DCTRL_PUSH_BUTTON )
set_dialog_item( dlgid, DI_ABLE_BUTTON, DAC_TEXT, "~Disable" )
set_dialog_item( dlgid, DI_CLEAR_BUTTON, DAC_TEXT, "~Clear" )
set_dialog_item( dlgid, DI_CLEAR_ALL_BUTTON, DAC_TEXT, "Clear ~all" )
set_dialog_window( dlgid, DWC_TITLE, "Pel Debugger Breakpoints" )
# attach_help(help_file, dlgid)
return dlgid
}
local bl_hdlg = 0
local function update_bl( bpindex )
{
local j = 0
local i = 0
local info = ""
local num_items = 0
if ( !bl_hdlg )
{
bl_hdlg = debug_create_bl_dlg()
set_debug_window()
}
set_dialog_item( bl_hdlg, IDL_LIST, DAC_CLEAR_LIST )
j = 0
for ( i in debug_fun_breakpoint_names )
{
info = sprintf( "%4d %s %s",
j++,
and(debug_fun_bp_types[i],BP_ENABLED) \
? "Enabled " \
: "Disabled",
debug_fun_breakpoint_names[i] )
set_dialog_item( bl_hdlg, IDL_LIST, DAC_ADD_ITEM, info )
}
if ( bpindex >= 0 )
{
num_items = query_dialog_item( bl_hdlg, IDL_LIST, DAC_COUNT_ITEMS )
if ( bpindex < num_items )
set_dialog_item( bl_hdlg, IDL_LIST, DAC_SELECT_INDEX, bpindex+0 )
else
set_dialog_item( bl_hdlg, IDL_LIST, DAC_SELECT_INDEX, num_items-1 )
}
else
set_dialog_item( bl_hdlg, IDL_LIST, DAC_SELECT_INDEX, 0 )
# update breakpoints
update_bp_marks()
}
global function debug_breakpoint_list()
{
local i
local j
local info[]
if ( !bl_hdlg )
bl_hdlg = debug_create_bl_dlg()
update_bl()
begin_dialog( bl_hdlg )
}
global function debug_bl_callback()
{
local j
local able_str
local bpindex
local gid
local file
local data[]
local pos
local str
local line
local ret_val = DRC_CONTINUE
if ( callback_msg == DM_SET_FOCUS && callback_index != IDL_LIST )
set_dialog_item( callback_dialog_handle, IDL_LIST, DAC_SETFOCUS )
else if ( callback_msg == DM_INIT )
set_dialog_item( callback_dialog_handle, IDL_LIST, DAC_SELECT_INDEX, 0 )
else if ( callback_msg == DM_SELECT )
{
bpindex = query_dialog_item( callback_dialog_handle, IDL_LIST, DAC_SELECT_INDEX )
if ( bpindex != -1 )
{
gid = bpindex_to_gid( bpindex )
if ( debug_fun_breakpoints[ gid ] )
set_dialog_item( callback_dialog_handle, DI_GOTO_BUTTON, DAC_ENABLE )
else
set_dialog_item( callback_dialog_handle, DI_GOTO_BUTTON, DAC_DISABLE )
if ( and( debug_fun_bp_types[gid], BP_ENABLED ) )
able_str = "~Disable"
else
able_str = "~Enable"
set_dialog_item( callback_dialog_handle, DI_ABLE_BUTTON, DAC_ENABLE )
set_dialog_item( callback_dialog_handle, DI_CLEAR_BUTTON, DAC_ENABLE )
set_dialog_item( callback_dialog_handle, DI_CLEAR_ALL_BUTTON, DAC_ENABLE )
set_dialog_item( callback_dialog_handle, DI_ABLE_BUTTON, DAC_TEXT, able_str )
}
else
{
set_dialog_item( callback_dialog_handle, DI_GOTO_BUTTON, DAC_DISABLE )
set_dialog_item( callback_dialog_handle, DI_ABLE_BUTTON, DAC_DISABLE )
set_dialog_item( callback_dialog_handle, DI_CLEAR_BUTTON, DAC_DISABLE )
set_dialog_item( callback_dialog_handle, DI_CLEAR_ALL_BUTTON, DAC_DISABLE )
}
}
else if ( callback_msg == DM_CLICK || callback_msg == DM_DOUBLE_CLICK )
{
ret_val = DRC_MSG_PROCESSED
bpindex = query_dialog_item( callback_dialog_handle, IDL_LIST, DAC_SELECT_INDEX )
gid = bpindex_to_gid( bpindex )
if ( callback_index == DI_GOTO_BUTTON && debug_fun_breakpoints[gid] > 0 )
{
str = query_dialog_item( callback_dialog_handle, IDL_LIST, DAC_SELECT_ITEM )
# parse out the filename
str = suffix( str, length(str) - rindex(str, " ") )
pos = rindex( str, ":" )
file = prefix( str, pos - 1 )
line = suffix( str, length(str) - pos )
debug_view( file, line )
}
else if ( callback_index == DI_ABLE_BUTTON )
{
if ( bpindex >= 0 )
{
able_str = query_dialog_item( callback_dialog_handle, DI_ABLE_BUTTON, DAC_TEXT )
if ( able_str == "Enable" )
be( bpindex )
else
bd( bpindex )
}
}
else if ( callback_index == DI_CLEAR_BUTTON )
{
if ( bpindex >= 0 )
bc( bpindex )
}
else if ( callback_index == DI_CLEAR_ALL_BUTTON )
bc( -1 )
else if ( callback_index == IDB_CLOSE_BTN )
ret_val = DRC_EXIT
else
ret_val = dlg_list_callback()
}
else if (callback_msg == DM_CLOSE || callback_msg == DM_CANCEL )
ret_val = DRC_EXIT;
else
ret_val = dlg_list_callback()
return ret_val
}