static brkp *SetPoint( memory_expr def_seg, mad_type_handle th ) { brkp *bp; const char *start; size_t len; address loc; cmd_list *cmds; char *condition; long countdown; bool resume; bool active; int index; mad_type_info mti; unsigned old; bool unmapped; bool mapaddress; bool symaddress; char *image_name; char *mod_name; char *sym_name; long cue_diff; long addr_diff; int cmd; resume = false; index = 0; active = true; unmapped = false; mapaddress = false; symaddress = false; while( CurrToken == T_DIV ) { Scan(); cmd = ScanCmd( PointNameTab ); if( cmd < 0 ) break; switch( cmd ) { case B_RESUME: resume = true; break; case B_UNRESUME: resume = false; break; case B_ACTIVATE: active = true; break; case B_DEACTIVATE: active = false; break; case B_UNMAPPED: unmapped = true; break; case B_MAPADDRESS: mapaddress = true; ScanItem( true, &start, &len ); image_name = DupStrLen( start, len ); loc.mach.segment = ReqLongExpr(); loc.mach.offset = ReqLongExpr(); ReqComma(); break; case B_SYMADDRESS: symaddress = true; ScanItem( true, &start, &len ); image_name = DupStrLen( start, len ); ScanItem( true, &start, &len ); mod_name = DupStrLen( start, len ); ScanItem( true, &start, &len ); sym_name = DupStrLen( start, len ); cue_diff = ReqLongExpr(); addr_diff = ReqLongExpr(); loc = NilAddr; ReqComma(); break; case B_INDEX: old = NewCurrRadix( 10 ); index = ReqExpr(); NewCurrRadix( old ); ReqComma(); break; /* fall thru */ default: Error( ERR_LOC, LIT_ENG( ERR_BAD_OPTION ), GetCmdName( CMD_BREAK ) ); break; } } if( !unmapped ) { ReqMemAddr( def_seg, &loc ); } for( bp = BrkList; bp != NULL; bp = bp->next ) { if( AddrComp( bp->loc.addr, loc ) == 0 ) { Error( ERR_NONE, LIT_ENG( ERR_POINT_EXISTS ) ); } } cmds = NULL; condition = NULL; countdown = 0; if( ScanQuote( &start, &len ) ) { if( len != 0 ) cmds = AllocCmdList( start, len ); if( ScanQuote( &start, &len ) ) { if( len != 0 ) condition = DupStrLen( start, len ); if( !ScanEOC() ) { countdown = ReqExpr(); } } } ReqEOC(); if( !IS_BP_EXECUTE( th ) ) { MADTypeInfo( th, &mti ); switch( mti.b.bits / BITS_PER_BYTE ) { case 1: case 2: case 4: break; case 8: if( Is8ByteBreakpointsSupported() ) break; default: Error( ERR_NONE, LIT_ENG( ERR_NOT_WATCH_SIZE ) ); break; } } bp = AddPoint( loc, th, unmapped ); if( bp == NULL ) return( NULL ); bp->status.b.unmapped = unmapped; if( mapaddress ) { bp->loc.image_name = image_name; } if( symaddress ) { bp->image_name = image_name; bp->mod_name = mod_name; bp->sym_name = sym_name; bp->cue_diff = cue_diff; bp->addr_diff = addr_diff; } bp->cmds = cmds; if( cmds != NULL ) bp->status.b.use_cmds = true; bp->condition = condition; if( condition != NULL ) bp->status.b.use_condition = true; SetBPCountDown( bp, countdown ); bp->status.b.resume = resume; bp->status.b.active = active; if( index != 0 ) bp->index = index; RecordBreakEvent( bp, B_SET ); return( bp ); }
void SetPointAddr( brkp *bp, address addr ) { DIPHDL( cue, ch ); image_entry *image; mod_handle mod; char const *start; bool ok; if( bp->status.b.unmapped ) return; _Free( bp->source_line ); bp->source_line = NULL; bp->loc.addr = addr; _Free( bp->mod_name ); bp->mod_name = NULL; _Free( bp->image_name ); bp->image_name = NULL; _Free( bp->sym_name ); bp->sym_name = NULL; bp->cue_diff = 0; bp->addr_diff = 0; if( !IS_BP_EXECUTE( bp->th ) ) { GetWPVal( bp ); } else if( DeAliasAddrMod( addr, &mod ) != SR_NONE ) { image = ImageEntry( mod ); if( image == NULL ) return; ModName( mod, TxtBuff, TXT_LEN ); bp->mod_name = DupStr( TxtBuff ); if( image->image_name != NULL ) { start = SkipPathInfo( image->image_name, OP_REMOTE ); bp->image_name = DupStrLen( start, ExtPointer( start, OP_REMOTE ) - start ); } else { bp->image_name = NULL; } switch( DeAliasAddrCue( NO_MOD, addr, ch ) ) { case SR_EXACT: bp->source_line = CopySourceLine( ch ); Format( TxtBuff, "%d", CueLine( ch ) ); bp->sym_name = DupStr( TxtBuff ); ok = GetBPSymAddr( bp, &addr ); break; case SR_CLOSEST: Format( TxtBuff, "%d", CueLine( ch ) ); bp->sym_name = DupStr( TxtBuff ); bp->addr_diff = addr.mach.offset - CueAddr( ch ).mach.offset; ok = GetBPSymAddr( bp, &addr ); break; default: ok = false; } if( !ok ) { _Free( bp->image_name ); _Free( bp->mod_name ); _Free( bp->sym_name ); bp->image_name = NULL; bp->mod_name = NULL; bp->sym_name = NULL; } } }
char *DupStr( const char *str ) { return( DupStrLen( str, strlen( str ) ) ); }