Example #1
0
static  bool    FileGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    int         len;
    file_window *file = WndFile( wnd );
    address     addr;
    brkp        *bp;
    bool        curr;
    DIPHDL( cue, ch );

    line->text = LIT( Empty );
    if( file->viewhndl == NULL && ModHasInfo( file->mod, HK_CUE ) != DS_OK ) {
        return( FALSE );
    }
    curr = ( row == file->active && ContextMod == file->mod );
    switch( piece ) {
    case PIECE_BREAK:
        line->tabstop = FALSE;
        if( row >= file->eof ) return( FALSE );
        if( file->mod == NO_MOD ) return( TRUE );
        addr = NilAddr;
        if( !WndDoingSearch ) { // too expensive
            addr = GetRowAddr( file, row, TRUE );
        }
        if( !IS_NIL_ADDR( addr ) ) {
            bp = FindBreakByLine( file->mod, file->file_id, row+1 );
            FileBreakGadget( wnd, line, curr, bp );
        }
        return( TRUE );
    case PIECE_SOURCE:
        line->text = TxtBuff;
        line->extent = WND_MAX_EXTEND;
        if( curr ) line->attr = WND_STANDOUT;
        if( file->mod != NO_MOD ) {
            line->indent = MaxGadgetLength;
        }
        if( file->viewhndl == NULL ) {
            Format( TxtBuff, LIT( No_Source_Line ), row+1 );
            if( LineCue( file->mod, file->file_id, 0, 0, ch ) != SR_NONE ) {
                if( (CueAdjust( ch, -1, ch ) & DS_ERR) ) {
                    file->eof = CueLine( ch );
                }
            }
            return( TRUE );
        }
        len = FReadLine( file->viewhndl, row+1, 0, TxtBuff, MAX_LINE_LEN );
        if( len < 0 ) {
            file->eof = row;
            return( FALSE );
        }
        if( len == MAX_LINE_LEN ) {
            StrCopy( " ...", TxtBuff + MAX_LINE_LEN );
        } else {
            TxtBuff[len] = '\0';
        }
        if( row >= file->rows ) {
            file->rows = row+1;
            file->rows_offset = FLastOffset( file->viewhndl );
        }
        return( TRUE );
    default:
        return( FALSE );
    }
}
Example #2
0
static int S_render_node(cmark_renderer *renderer, cmark_node *node,
                         cmark_event_type ev_type, int options) {
  cmark_node *tmp;
  int list_number;
  cmark_delim_type list_delim;
  int numticks;
  int i;
  bool entering = (ev_type == CMARK_EVENT_ENTER);
  const char *info, *code, *title;
  size_t info_len, code_len;
  char listmarker[20];
  char *emph_delim;
  bufsize_t marker_width;

  // Don't adjust tight list status til we've started the list.
  // Otherwise we loose the blank line between a paragraph and
  // a following list.
  if (!(node->type == CMARK_NODE_ITEM && node->prev == NULL && entering)) {
    tmp = get_containing_block(node);
    renderer->in_tight_list_item =
        (tmp->type == CMARK_NODE_ITEM &&
         cmark_node_get_list_tight(tmp->parent)) ||
        (tmp && tmp->parent && tmp->parent->type == CMARK_NODE_ITEM &&
         cmark_node_get_list_tight(tmp->parent->parent));
  }

  switch (node->type) {
  case CMARK_NODE_DOCUMENT:
    break;

  case CMARK_NODE_BLOCK_QUOTE:
    if (entering) {
      LIT("> ");
      cmark_strbuf_puts(renderer->prefix, "> ");
    } else {
      cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 2);
      BLANKLINE();
    }
    break;

  case CMARK_NODE_LIST:
    if (!entering && node->next && (node->next->type == CMARK_NODE_CODE_BLOCK ||
                                    node->next->type == CMARK_NODE_LIST)) {
      // this ensures 2 blank lines after list,
      // if before code block or list:
      LIT("\n");
    }
    break;

  case CMARK_NODE_ITEM:
    if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
      marker_width = 2;
    } else {
      list_number = cmark_node_get_list_start(node->parent);
      list_delim = cmark_node_get_list_delim(node->parent);
      tmp = node;
      while (tmp->prev) {
        tmp = tmp->prev;
        list_number += 1;
      }
      // we ensure a width of at least 4 so
      // we get nice transition from single digits
      // to double
      sprintf(listmarker, "%d%s%s", list_number,
              list_delim == CMARK_PAREN_DELIM ? ")" : ".",
              list_number < 10 ? "  " : " ");
      marker_width = safe_strlen(listmarker);
    }
    if (entering) {
      if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
        LIT("* ");
        cmark_strbuf_puts(renderer->prefix, "  ");
      } else {
        LIT(listmarker);
        for (i = marker_width; i--;) {
          cmark_strbuf_putc(renderer->prefix, ' ');
        }
      }
    } else {
      cmark_strbuf_truncate(renderer->prefix,
                            renderer->prefix->size - marker_width);
      CR();
    }
    break;

  case CMARK_NODE_HEADER:
    if (entering) {
      for (int i = cmark_node_get_header_level(node); i > 0; i--) {
        LIT("#");
      }
      LIT(" ");
      renderer->no_wrap = true;
    } else {
      renderer->no_wrap = false;
      BLANKLINE();
    }
    break;

  case CMARK_NODE_CODE_BLOCK:
    BLANKLINE();
    info = cmark_node_get_fence_info(node);
    info_len = safe_strlen(info);
    code = cmark_node_get_literal(node);
    code_len = safe_strlen(code);
    // use indented form if no info, and code doesn't
    // begin or end with a blank line, and code isn't
    // first thing in a list item
    if (info_len == 0 &&
        (code_len > 2 && !isspace(code[0]) &&
         !(isspace(code[code_len - 1]) && isspace(code[code_len - 2]))) &&
        !(node->prev == NULL && node->parent &&
          node->parent->type == CMARK_NODE_ITEM)) {
      LIT("    ");
      cmark_strbuf_puts(renderer->prefix, "    ");
      OUT(cmark_node_get_literal(node), false, LITERAL);
      cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 4);
    } else {
      numticks = longest_backtick_sequence(code) + 1;
      if (numticks < 3) {
        numticks = 3;
      }
      for (i = 0; i < numticks; i++) {
        LIT("`");
      }
      LIT(" ");
      OUT(info, false, LITERAL);
      CR();
      OUT(cmark_node_get_literal(node), false, LITERAL);
      CR();
      for (i = 0; i < numticks; i++) {
        LIT("`");
      }
    }
    BLANKLINE();
    break;

  case CMARK_NODE_HTML:
    BLANKLINE();
    OUT(cmark_node_get_literal(node), false, LITERAL);
    BLANKLINE();
    break;

  case CMARK_NODE_HRULE:
    BLANKLINE();
    LIT("-----");
    BLANKLINE();
    break;

  case CMARK_NODE_PARAGRAPH:
    if (!entering) {
      BLANKLINE();
    }
    break;

  case CMARK_NODE_TEXT:
    OUT(cmark_node_get_literal(node), true, NORMAL);
    break;

  case CMARK_NODE_LINEBREAK:
    if (!(CMARK_OPT_HARDBREAKS & options)) {
      LIT("\\");
    }
    CR();
    break;

  case CMARK_NODE_SOFTBREAK:
    if (renderer->width == 0 && !(CMARK_OPT_HARDBREAKS & options)) {
      CR();
    } else {
      OUT(" ", true, LITERAL);
    }
    break;

  case CMARK_NODE_CODE:
    code = cmark_node_get_literal(node);
    code_len = safe_strlen(code);
    numticks = shortest_unused_backtick_sequence(code);
    for (i = 0; i < numticks; i++) {
      LIT("`");
    }
    if (code_len == 0 || code[0] == '`') {
      LIT(" ");
    }
    OUT(cmark_node_get_literal(node), true, LITERAL);
    if (code_len == 0 || code[code_len - 1] == '`') {
      LIT(" ");
    }
    for (i = 0; i < numticks; i++) {
      LIT("`");
    }
    break;

  case CMARK_NODE_INLINE_HTML:
    OUT(cmark_node_get_literal(node), false, LITERAL);
    break;

  case CMARK_NODE_STRONG:
    if (entering) {
      LIT("**");
    } else {
      LIT("**");
    }
    break;

  case CMARK_NODE_EMPH:
    // If we have EMPH(EMPH(x)), we need to use *_x_*
    // because **x** is STRONG(x):
    if (node->parent && node->parent->type == CMARK_NODE_EMPH &&
        node->next == NULL && node->prev == NULL) {
      emph_delim = "_";
    } else {
      emph_delim = "*";
    }
    if (entering) {
      LIT(emph_delim);
    } else {
      LIT(emph_delim);
    }
    break;

  case CMARK_NODE_LINK:
    if (is_autolink(node)) {
      if (entering) {
        LIT("<");
        if (strncmp(cmark_node_get_url(node), "mailto:", 7) == 0) {
          LIT((char *)cmark_node_get_url(node) + 7);
        } else {
          LIT((char *)cmark_node_get_url(node));
        }
        LIT(">");
        // return signal to skip contents of node...
        return 0;
      }
    } else {
      if (entering) {
        LIT("[");
      } else {
        LIT("](");
        OUT(cmark_node_get_url(node), false, URL);
        title = cmark_node_get_title(node);
        if (safe_strlen(title) > 0) {
          LIT(" \"");
          OUT(title, false, TITLE);
          LIT("\"");
        }
        LIT(")");
      }
    }
    break;

  case CMARK_NODE_IMAGE:
    if (entering) {
      LIT("![");
    } else {
      LIT("](");
      OUT(cmark_node_get_url(node), false, URL);
      title = cmark_node_get_title(node);
      if (safe_strlen(title) > 0) {
        OUT(" \"", true, LITERAL);
        OUT(title, false, TITLE);
        LIT("\"");
      }
      LIT(")");
    }
    break;

  default:
    assert(false);
    break;
  }

  return 1;
}
Example #3
0
STATIC bint readSampleFile( void )
/********************************/
{
    file_handle             fh;
    uint_16                 size;
    void                    *buff;
    int                     buff_len;
    off_t                   start_position;
    bint                    main_exe;
    samp_block_prefix       prefix;
    samp_block_prefix       *next_prefix;

    /* we can add error checking for things like */
    /**/
    /*    - number of samples match the info # of samples */
    /*    - main exe load if there is an overlay table */
    /**/
    fh = CurrSIOData->fh;
    start_position = lseek( fh, CurrSIOData->header.sample_start, SEEK_SET );
    if( start_position == (off_t) -1 ) {
        ErrorMsg( LIT( Smp_File_IO_Err ), CurrSIOData->samp_file_name );
        return( P_FALSE );
    }
    if( read( fh, &prefix, SIZE_PREFIX ) != SIZE_PREFIX ) {
        ErrorMsg( LIT( Smp_File_IO_Err ), CurrSIOData->samp_file_name );
        return( P_FALSE );
    }
    buff = ProfAlloc( SIZE_DATA );
    buff_len = SIZE_DATA;
    main_exe = P_FALSE;
    while( prefix.kind != SAMP_LAST ) {
        size = prefix.length;
        if( buff_len < size ) {
            buff = ProfRealloc( buff, size );
            buff_len = size;
        }
        /* reads data & next prefix */
        if( BigRead( fh, buff, size ) != size ) {
            ErrorMsg( LIT( Smp_File_IO_Err ), CurrSIOData->samp_file_name );
            ProfFree( buff );
            return( P_FALSE );
        }
        next_prefix = (void *)( ((char *) buff) + ( size - SIZE_PREFIX ));

        /* if we're reading a sample record from a callgraph sample */
        /* file, the next record should contain callgraph information */
        /* which we will also want stored in memory for processing */
        /* 16-jul-92 CMS */

//        if( CallGraph && prefix.kind == SAMP_SAMPLES &&
//                         next_prefix->kind == SAMP_CALLGRAPH ) {
//            size = next_prefix->length;
//            /* reads callgraph data & next prefix   */
//            if( BigRead( fh, next_prefix, size ) != size ) {
//                errorIO();
//                ProfFree( buff );
//                ErrorMsg( LIT( Smp_File_IO_Err ), CurrSIOData->samp_file_name );
//                return( P_FALSE );
//            }
//            next_prefix = (void *)( ((char *) next_prefix) + ( size - SIZE_PREFIX ));
//        }

        switch( prefix.kind ) {
        case SAMP_INFO:
            procInfoBlock( prefix.tick, buff );
            break;
        case SAMP_SAMPLES:
            if( !procSampleBlock( prefix.tick, prefix.length, buff ) ) {
                return( P_FALSE );
            }
            break;
        case SAMP_MARK:
            procMarkBlock( prefix.tick, buff );
            break;
        case SAMP_OVL_LOAD:
            procOverlayBlock( prefix.tick, buff );
            break;
        case SAMP_ADDR_MAP:
            procAddrBlock( prefix.length, buff );
            break;
        case SAMP_MAIN_LOAD:
            main_exe = P_TRUE;
        /* fall through */
        case SAMP_CODE_LOAD:
            procImageBlock( buff, main_exe );
            main_exe = P_FALSE;
            break;
        case SAMP_REMAP_SECTION:
            procRemapBlock( prefix.tick, prefix.length, buff );
            break;
        case SAMP_CALLGRAPH:
//            printf( "sample callgraph\n" );
            break;
        }
        prefix = *next_prefix;
    }
    ProfFree( buff );
    return( P_TRUE );
}
Example #4
0
static void     FileMenuItem( a_window *wnd, unsigned id, int row, int piece )
{
    address     addr;
    mod_handle  mod;
    bool        has_addr;
    bool        has_popitem;
    file_window *file = WndFile( wnd );

    piece=piece;
    addr = GetRowAddr( file, row, id != MENU_FILE_ASSEMBLY );
    has_addr = !IS_NIL_ADDR( addr );
    switch( id ) {
    case MENU_INITIALIZE:
        has_popitem = ( *WndPopItem( wnd ) != '\0' );
        if( has_popitem && !ScanSelectedExpr( WndPopItem( wnd ) ) ) {
            has_popitem = FALSE;
        }
        WndMenuEnable( wnd, MENU_FILE_SHOW, TRUE );
        WndMenuEnable( wnd, MENU_FILE_SHOW_ADDRESS, TRUE );
        WndMenuEnable( wnd, MENU_FILE_SHOW_MODULE, TRUE );
        WndMenuEnable( wnd, MENU_FILE_FUNCTIONS, file->mod != NO_MOD );
        WndMenuEnable( wnd, MENU_FILE_HOME, TRUE );
        addr = GetRowAddr( file, row, FALSE );
        WndMenuEnable( wnd, MENU_FILE_ASSEMBLY, !IS_NIL_ADDR( addr ) );
        WndMenuEnable( wnd, MENU_FILE_WATCH, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_INSPECT, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_STEP_INTO, file->mod != NO_MOD && has_popitem );
        WndMenuEnable( wnd, MENU_FILE_BREAK, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_RUN, has_addr );
        WndMenuEnable( wnd, MENU_FILE_SKIP_TO_CURSOR, has_addr );
        break;
    case MENU_FILE_RUN:
        GoToAddr( addr );
        break;
    case MENU_FILE_SKIP_TO_CURSOR:
        SkipToAddr( addr );
        break;
    case MENU_FILE_BREAK:
        BreakOnSelected( WndPopItem( wnd ) );
        break;
    case MENU_FILE_HOME:
        GoHome();
        break;
    case MENU_FILE_SHOW_MODULE:
        mod = file->mod;
        if( DlgModName( LIT( New_Module ), &mod ) ) {
            WndModInspect( mod );
        }
        break;
    case MENU_FILE_SHOW_ADDRESS:
        if( DlgCodeAddr( LIT( New_Addr ), &addr ) ) {
            WndSrcInspect( addr );
        }
        break;
    case MENU_FILE_STEP_INTO:
        StepIntoFunction( WndPopItem( wnd ) );
        break;
    case MENU_FILE_INSPECT:
        WndInspect( WndPopItem( wnd ) );
        break;
    case MENU_FILE_WATCH:
        WndVarInspect( WndPopItem( wnd ) );
        break;
    case MENU_FILE_SEARCH:
        WndSaveToHistory( SrchHistory, WndPopItem( wnd ) );
        DbgWndSearch( wnd, FALSE, DlgSearch( wnd, SrchHistory ) );
        break;
    case MENU_FILE_ASSEMBLY:
        AsmWndFind( file->asw, addr, file->track );
        break;
    case MENU_FILE_LINE:
        GotoLine( wnd );
        break;
    case MENU_FILE_FUNCTIONS:
        WndFuncInspect( file->mod );
        break;
    }
}
Example #5
0
STATIC void loadImageInfo( image_info * curr_image )
/**************************************************/
{
    int             name_len;
    int             object_file;
    int             sym_file;
    struct stat     file_status;

    sym_file = -1;
    object_file = -1;
    curr_image->dip_handle = NO_MOD;
    if( curr_image->sym_deleted ) {
    } else if( curr_image->sym_name != NULL ) {
        sym_file = open( curr_image->sym_name, O_RDONLY|O_BINARY );
        if( sym_file != -1 ) {
            curr_image->dip_handle = WPDipLoadInfo( sym_file,
                                       curr_image->sym_name, curr_image,
                                       sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
        }
    } else {
        name_len = strlen( curr_image->name ) + 1;
        memcpy( FNameBuff, curr_image->name, name_len );
        ReplaceExt( FNameBuff, ".sym" );
        name_len = strlen( FNameBuff ) + 1;
        curr_image->sym_name = ProfAlloc( name_len );
        memcpy( curr_image->sym_name, FNameBuff, name_len );
        sym_file = open( curr_image->sym_name, O_RDONLY|O_BINARY );
        if( sym_file != -1 ) {
            curr_image->dip_handle = WPDipLoadInfo( sym_file,
                                      curr_image->sym_name, curr_image,
                                      sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
        }
        if( curr_image->dip_handle == NO_MOD ) {
            ProfFree( curr_image->sym_name );
            curr_image->sym_name = NULL;
        }
    }
    object_file = open( curr_image->name, O_RDONLY|O_BINARY );
    if( object_file == -1 ) {
        curr_image->exe_not_found = true;
        if( curr_image->main_load ) {
            ErrorMsg( LIT( Exe_Not_Found ), curr_image->name );
        }
    } else if( curr_image->time_stamp == 0 ) {
        /*
           If sample timestamp is 0, the sampler couldn't figure out
           the right value. Assume it's OK.
        */
    } else if( fstat( object_file, &file_status ) == 0 ) {
        /* QNX creation dates and time stamps tend to be 1 */
        /* unit different, so do not test for equality */
        if( file_status.st_mtime - curr_image->time_stamp > 1 ) {
            curr_image->exe_changed = true;
            if( curr_image->main_load ) {
                ErrorMsg( LIT( Exe_Has_Changed ), curr_image->name );
            }
        }
    }
    if( curr_image->dip_handle == NO_MOD && !curr_image->sym_deleted
     && object_file != -1 ) {
        curr_image->dip_handle = WPDipLoadInfo( object_file,
                                   curr_image->name, curr_image,
                                   sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
    }
    if( curr_image->dip_handle == NO_MOD ) {
        if( sym_file != -1 ) {
            close( sym_file );
        }
        if( object_file != -1 ) {
            close( object_file );
        }
    }
    initModuleInfo( curr_image );
    if( curr_image->dip_handle != NO_MOD ) {
        WalkModList( curr_image->dip_handle, &loadModuleInfo, curr_image );
    }
}
Example #6
0
static void TrapFailed( void )
{
    KillTrap();
    StartupErr( LIT( ERR_REMOTE_LINK_BROKEN ) );
}
Example #7
0
LONG __stdcall DCUnhandledExceptionFilter( LPEXCEPTION_POINTERS e )
{	
#ifdef __DEBUG
	MessageBox(NULL, _T("If you would like to debug DCUnhandledExceptionFilter - attach to this process now"), _T(APPNAME), MB_OK);
#endif
	Lock l(cs);

	if(recursion++ > 30)
		exit(-1);

#ifndef _DEBUG
#if _MSC_VER == 1200
	__pfnDliFailureHook = FailHook;
#elif _MSC_VER == 1300 || _MSC_VER == 1310 || _MSC_VER == 1400
	__pfnDliFailureHook2 = FailHook;
#else
#error Unknown Compiler version
#endif

	// The release version loads the dll and pdb:s here...
	InitSymInfo(Text::toT(Util::getDataPath()).c_str());

#endif
	TCHAR pdbPath[MAX_PATH];
	GetModuleFileName(NULL, pdbPath, sizeof(pdbPath));
	TCHAR* dotPtr = _tcschr(pdbPath, '.');
	if (dotPtr != NULL) {
		_tcscpy(dotPtr, _T(".pdb"));
	}

	if (GetFileAttributes(pdbPath) == INVALID_FILE_ATTRIBUTES) {
		// No debug symbols, we're not interested...
		::MessageBox(WinUtil::mainWnd, _T(APPNAME) _T(" has crashed and you don't have .PDB file installed. Hence, I can't find out why it crashed, so don't report this as a bug unless you find a solution..."), _T(APPNAME) _T(" has crashed"), MB_OK);
#ifndef _DEBUG
		exit(1);
#else
		return EXCEPTION_CONTINUE_SEARCH;
#endif
	}
	File f(Util::getConfigPath() + "exceptioninfo.txt", File::WRITE, File::OPEN | File::CREATE);
	f.setEndPos(0);
	
	char buf[DEBUG_BUFSIZE];
	sprintf(buf, 
		"Code: %x (%s)\r\n"
		"Version: %d (%s)\r\n", 
		e->ExceptionRecord->ExceptionCode,
		getExceptionName(e->ExceptionRecord->ExceptionCode),
		BUILDID, 
		Util::getCompileDate().c_str());

	tstring exceptioninfo = Text::toT(buf);
	f.write(buf, strlen(buf));	
	
	OSVERSIONINFOEX ver;
	WinUtil::getVersionInfo(ver);
	const char *productType;
	if (ver.wProductType == VER_NT_DOMAIN_CONTROLLER) {
		productType = "domain controller";
	}
	else if (ver.wProductType == VER_NT_SERVER) {
		productType = "server";
	}
	else if (ver.wProductType == VER_NT_WORKSTATION) {
		productType = "workstation";
	}
	else {
		productType = "unknown product type";
	}

	sprintf(buf, "OS Version: %d.%d build %d service pack %d %s\r\n",
		(DWORD)ver.dwMajorVersion, (DWORD)ver.dwMinorVersion, (DWORD)ver.dwBuildNumber,
		(DWORD)ver.wServicePackMajor, productType);

	exceptioninfo += Text::toT(buf);
	f.write(buf, strlen(buf));

	time_t now;
	time(&now);
	strftime(buf, DEBUG_BUFSIZE, "Time: %Y-%m-%d %H:%M:%S\r\n", localtime(&now));

	exceptioninfo += Text::toT(buf);
	f.write(buf, strlen(buf));

#if 0
	WinUtil::exceptioninfo += LIT(_T("TTH: "));
	WinUtil::exceptioninfo += Text::toT(tth);
	WinUtil::exceptioninfo += LIT(_T("\r\n\r\n"));
#endif

    f.write(LIT("\r\n"));
	exceptioninfo += _T("\r\n");

        // !SMT!
        sprintf(buf,
	       "exception code %08X at eip=%08X, nested: %08X\r\n"
	       "eax=%08X ebx=%08X ecx=%08X edx=%08X\r\n"
          "esi=%08X edi=%08X ebp=%08X esp=%08X\r\n",
		e->ExceptionRecord->ExceptionCode, 
		e->ExceptionRecord->ExceptionAddress, 
		e->ExceptionRecord->ExceptionRecord,
		e->ContextRecord->Eax, 
		e->ContextRecord->Ebx,
		e->ContextRecord->Ecx, 
		e->ContextRecord->Edx,
		e->ContextRecord->Esi, 
		e->ContextRecord->Edi,
		e->ContextRecord->Ebp,
		e->ContextRecord->Esp);
	exceptioninfo += Text::toT(buf);
        f.write(buf, strlen(buf));

	const tstring trace = StackTrace(GetCurrentThread(), e->ContextRecord);

	f.write(LIT("\r\n"));
	f.write(Text::fromT(trace));
	f.close();

#if 0
	memcpy(&CurrExceptionRecord, e->ExceptionRecord, sizeof(EXCEPTION_RECORD));
	memcpy(&CurrContext, e->ContextRecord, sizeof(CONTEXT));
#endif

	exceptioninfo += _T("\r\n");
	exceptioninfo += trace;

	Sounds::PlaySound(SettingsManager::SOUND_EXC);

	if (WinUtil::mainWnd != NULL) {
		NOTIFYICONDATA m_nid = {0};
		m_nid.cbSize = sizeof(NOTIFYICONDATA);
		m_nid.hWnd = WinUtil::mainWnd;
		m_nid.uID = 0;
		m_nid.uFlags = NIF_INFO;
		m_nid.uTimeout = 5000;
		m_nid.dwInfoFlags = NIIF_WARNING;
		_tcsncpy(m_nid.szInfo, _T("exceptioninfo.txt was generated"), 255);
		_tcsncpy(m_nid.szInfoTitle, _T(APPNAME) _T(" has crashed"), 63);
		Shell_NotifyIcon(NIM_MODIFY, &m_nid);
	}

	CExceptionDlg dlg(exceptioninfo);
	int iLastExceptionDlgResult = dlg.DoModal(WinUtil::mainWnd);
	if (iLastExceptionDlgResult == IDCANCEL) {
		ExitProcess(1);
	}

#ifndef _DEBUG
	UninitSymInfo();
	
	return EXCEPTION_CONTINUE_EXECUTION;
#else
	return EXCEPTION_CONTINUE_SEARCH;
#endif
}
Example #8
0
extern wp_asmfile * WPAsmOpen( sio_data * curr_sio, int src_row, bint quiet )
/***************************************************************************/
{
    wp_asmfile *        wpasm_file;
    cue_handle *        ch;
    cue_handle *        ch2;
    mod_info *          curr_mod;
    file_info *         curr_file;
    massgd_sample_addr * samp_data;
    wp_asmline *        asm_line;
    mod_handle          mh;
    file_handle         fh;
    address             addr;
    cue_file_id         fid;
    search_result       cue_find;
    int                 rows;
    int                 asm_group;
    int                 asm_row;
    int                 file_index;
    int                 addr_cmp;
    clicks_t            addr_tick_index;

    quiet=quiet;
    ch = alloca( DIPHandleSize( HK_CUE ) );
    ch2 = alloca( DIPHandleSize( HK_CUE ) );
    curr_file = curr_sio->curr_file;
    curr_mod = curr_sio->curr_mod;
    if( curr_file->fid == 0 || LineCue( curr_mod->mh, curr_sio->curr_file->fid,
                                        src_row, 0, ch2 ) == SR_NONE ) {
        ch2 = NULL;
    }
    fh = ExeOpen( curr_sio->curr_image->name );
    if( fh == -1 ) {
        ErrorMsg( LIT( Exe_Not_Found ), curr_sio->curr_image->name );
        return( NULL );
    }
    wpasm_file = ProfCAlloc( sizeof(wp_asmfile) );
    curr_sio->asm_file = wpasm_file;
    wpasm_file->asm_buff = ProfAlloc( MAX_ASM_BUFF_LEN );
    wpasm_file->asm_buff_len = MAX_ASM_BUFF_LEN;
    SetNumBytes( 0 );
    SetExeFile( fh, P_FALSE );
    wpasm_file->fh = fh;
    addr = ModAddr( curr_mod->mh );
    SetExeOffset( addr );
    wpasm_file->max_time = 0;
    addr_tick_index = curr_mod->first_tick_index - 1;
    samp_data = WPGetMassgdSampData( curr_sio, addr_tick_index++ );
    wpasm_file->asm_data = ProfAlloc( sizeof(wp_asm_groups) );
    wpasm_file->asm_data[0].asm_lines = ProfAlloc( MAX_ASM_LINE_SIZE );
    wpasm_file->asm_groups = 0;
    rows = 0;
    for( ;; ) {
        mh = curr_mod->mh;
        if( EndOfSegment()
                || AddrMod( addr, &mh ) == SR_NONE || mh != curr_mod->mh ) break;
        cue_find = (AddrCue( curr_mod->mh, addr, ch ) == SR_EXACT);
        if( ch2 != NULL && CueCmp( ch, ch2 ) == 0 ) {
            wpasm_file->entry_line = rows;
            ch2 = NULL;
        }
        asm_line = WPGetAsmLoc( wpasm_file, rows, &asm_group, &asm_row );
        if( cue_find ) {
            asm_line->source_line = P_TRUE;
            asm_line->u.src.line = CueLine( ch );
            asm_line->u.src.src_file = NULL;
            if( !curr_file->unknown_file ) {
                fid = CueFileId( ch );
                file_index = 0;
                while( file_index < curr_mod->file_count ) {
                    curr_file = curr_mod->mod_file[file_index];
                    if( curr_file->fid == fid ) {
                        asm_line->u.src.src_file =
                            FOpenSource( curr_file->name, mh, fid );
                        break;
                    }
                    file_index++;
                }
            }
            rows++;
            asm_line = WPGetAsmLoc( wpasm_file, rows, &asm_group, &asm_row );
        }
        asm_line = &wpasm_file->asm_data[asm_group].asm_lines[asm_row];
        asm_line->source_line = P_FALSE;
        asm_line->u.asm_line.addr = addr;
        asm_line->u.asm_line.tick_count = 0;
        for( ;; ) {
            if( samp_data == NULL ) break;
            addr_cmp = AddrCmp( &addr, samp_data->raw );
            if( addr_cmp < 0 ) break;
            if( addr_cmp == 0 ) {
                asm_line->u.asm_line.tick_count = samp_data->hits;
                if( asm_line->u.asm_line.tick_count > wpasm_file->max_time ) {
                    wpasm_file->max_time = asm_line->u.asm_line.tick_count;
                }
            }
            samp_data = WPGetMassgdSampData( curr_sio, addr_tick_index++ );
        }
        rows++;
        CodeAdvance( &addr );
    }
    WPGetAsmLoc( wpasm_file, rows, &asm_group, &asm_row );
    wpasm_file->asm_data[asm_group].asm_lines =
        ProfRealloc( wpasm_file->asm_data[asm_group].asm_lines,
                     sizeof(wp_asmline)*(asm_row+1) );
    wpasm_file->asm_rows = rows;
    return( wpasm_file );
}
Example #9
0
bool DlgIncompleteUndo( void )
{
    return( WndDisplayMessage( LIT( WARN_Incomplete_Undo ), LIT( Empty ),
                             GUI_YES_NO ) == GUI_RET_YES );
}
Example #10
0
extern a_window *WndImgOpen()
{
    return( DbgTitleWndCreate( LIT( WindowImages ), &ImgInfo, WND_IMAGE,
            NULL, &ImgIcon, TITLE_SIZE, TRUE ) );
}
Example #11
0
void PopErrBox( char *buff )
{
    printf( "%s: %s\n", buff, LIT( Debugger_Startup_Error ) );
//    MessageBox( (HWND) NULL, buff, LIT( Debugger_Startup_Error ),
//            MB_OK | MB_ICONHAND | MB_SYSTEMMODAL );
}
Example #12
0
a_window *WndTrdOpen()
{
    return( DbgTitleWndCreate( LIT( WindowThreads ), &TrdInfo, WND_THREAD, NULL,
                               &TrdIcon, TITLE_SIZE, TRUE ) );
}
Example #13
0
static  bool    TrdGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    thread_state        *thd = GetThreadRow( row );

    line->indent = Indents[ piece ] * WndAvgCharX( wnd );
    if( row < 0 ) {
        row += TITLE_SIZE;
        switch( row ) {
        case 0:
            switch( piece ) {
            case PIECE_ID:
                line->text = LIT( ID );
                return( TRUE );
            case PIECE_STATE:
                line->text = LIT( State );
                return( TRUE );
            case PIECE_NAME:
                line->text = TxtBuff;
                RemoteThdName( 0, TxtBuff ); // nyi - pui - line up in proportional font
                return( TRUE );
            default:
                return( FALSE );
            }
        case 1:
            if( piece != 0 ) return( FALSE );
            SetUnderLine( wnd, line );
            return( TRUE );
        default:
            return( FALSE );
        }
    } else {
        if( thd == NULL ) return( FALSE );
        line->tabstop = FALSE;
        line->use_prev_attr = TRUE;
        line->extent = WND_MAX_EXTEND;
        switch( piece ) {
        case PIECE_ID:
            line->tabstop = TRUE;
            line->use_prev_attr = FALSE;
            line->text = TxtBuff;
            CnvULongHex( thd->tid, TxtBuff );
            return( TRUE );
        case PIECE_STATE:
            if( IsThdCurr( thd ) ) {
                line->text = LIT( Current );
            } else {
                switch( thd->state ) {
                case THD_THAW:
                    line->text = LIT( Runnable );
                    break;
                case THD_FREEZE:
                    line->text = LIT( Frozen );
                    break;
                case THD_WAIT:
                    line->text = LIT( Wait );
                    break;  
                case THD_SIGNAL:
                    line->text = LIT( Signal );
                    break;  
                case THD_KEYBOARD:
                    line->text = LIT( Keyboard );
                    break;  
                case THD_BLOCKED:
                    line->text = LIT( Blocked );
                    break;  
                case THD_RUN:
                    line->text = LIT( Executing );
                    break;  
                case THD_DEBUG:
                    line->text = LIT( Debug );
                    break;
                case THD_DEAD:
                    line->text = LIT( Dead );
                    break;
                }
            }
            return( TRUE );
        case PIECE_NAME:
            line->tabstop = FALSE;
            line->use_prev_attr = TRUE;
            line->text = thd->name;
            return( TRUE );
        }
    }
    return( FALSE );
}
Example #14
0
void PopErrBox( char *buff )
{
    WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, buff,
                  LIT(Debugger_Startup_Error), 1001,
                  MB_MOVEABLE | MB_CUACRITICAL | MB_CANCEL );
}
Example #15
0
static int S_render_node(cmark_renderer *renderer, cmark_node *node,
                         cmark_event_type ev_type, int options) {
  cmark_node *tmp;
  int list_number;
  bool entering = (ev_type == CMARK_EVENT_ENTER);
  bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options);

  if (node->extension && node->extension->man_render_func) {
    node->extension->man_render_func(node->extension, renderer, node, ev_type, options);
    return 1;
  }

  switch (node->type) {
  case CMARK_NODE_DOCUMENT:
    if (entering) {
      /* Define a strikethrough macro */
      /* Commenting out because this makes tests fail
      LIT(".de ST");
      CR();
      LIT(".nr ww \\w'\\\\$1'");
      CR();
      LIT("\\Z@\\v'-.25m'\\l'\\\\n[ww]u'@\\\\$1");
      CR();
      LIT("..");
      CR();
      */
    }
    break;

  case CMARK_NODE_BLOCK_QUOTE:
    if (entering) {
      CR();
      LIT(".RS");
      CR();
    } else {
      CR();
      LIT(".RE");
      CR();
    }
    break;

  case CMARK_NODE_LIST:
    break;

  case CMARK_NODE_ITEM:
    if (entering) {
      CR();
      LIT(".IP ");
      if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
        LIT("\\[bu] 2");
      } else {
        list_number = cmark_node_get_list_start(node->parent);
        tmp = node;
        while (tmp->prev) {
          tmp = tmp->prev;
          list_number += 1;
        }
        char list_number_s[LIST_NUMBER_SIZE];
        snprintf(list_number_s, LIST_NUMBER_SIZE, "\"%d.\" 4", list_number);
        LIT(list_number_s);
      }
      CR();
    } else {
      CR();
    }
    break;

  case CMARK_NODE_HEADING:
    if (entering) {
      CR();
      LIT(cmark_node_get_heading_level(node) == 1 ? ".SH" : ".SS");
      CR();
    } else {
      CR();
    }
    break;

  case CMARK_NODE_CODE_BLOCK:
    CR();
    LIT(".IP\n.nf\n\\f[C]\n");
    OUT(cmark_node_get_literal(node), false, NORMAL);
    CR();
    LIT("\\f[]\n.fi");
    CR();
    break;

  case CMARK_NODE_HTML_BLOCK:
    break;

  case CMARK_NODE_CUSTOM_BLOCK:
    CR();
    OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
        false, LITERAL);
    CR();
    break;

  case CMARK_NODE_THEMATIC_BREAK:
    CR();
    LIT(".PP\n  *  *  *  *  *");
    CR();
    break;

  case CMARK_NODE_PARAGRAPH:
    if (entering) {
      // no blank line if first paragraph in list:
      if (node->parent && node->parent->type == CMARK_NODE_ITEM &&
          node->prev == NULL) {
        // no blank line or .PP
      } else {
        CR();
        LIT(".PP");
        CR();
      }
    } else {
      CR();
    }
    break;

  case CMARK_NODE_TEXT:
    OUT(cmark_node_get_literal(node), allow_wrap, NORMAL);
    break;

  case CMARK_NODE_LINEBREAK:
    LIT(".PD 0\n.P\n.PD");
    CR();
    break;

  case CMARK_NODE_SOFTBREAK:
    if (options & CMARK_OPT_HARDBREAKS) {
      LIT(".PD 0\n.P\n.PD");
      CR();
    } else if (renderer->width == 0 && !(CMARK_OPT_NOBREAKS & options)) {
      CR();
    } else {
      OUT(" ", allow_wrap, LITERAL);
    }
    break;

  case CMARK_NODE_CODE:
    LIT("\\f[C]");
    OUT(cmark_node_get_literal(node), allow_wrap, NORMAL);
    LIT("\\f[]");
    break;

  case CMARK_NODE_HTML_INLINE:
    break;

  case CMARK_NODE_CUSTOM_INLINE:
    OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
        false, LITERAL);
    break;

  case CMARK_NODE_STRONG:
    if (entering) {
      LIT("\\f[B]");
    } else {
      LIT("\\f[]");
    }
    break;

  case CMARK_NODE_EMPH:
    if (entering) {
      LIT("\\f[I]");
    } else {
      LIT("\\f[]");
    }
    break;

  case CMARK_NODE_LINK:
    if (!entering) {
      LIT(" (");
      OUT(cmark_node_get_url(node), allow_wrap, URL);
      LIT(")");
    }
    break;

  case CMARK_NODE_IMAGE:
    if (entering) {
      LIT("[IMAGE: ");
    } else {
      LIT("]");
    }
    break;

  case CMARK_NODE_FOOTNOTE_DEFINITION:
  case CMARK_NODE_FOOTNOTE_REFERENCE:
    // TODO
    break;

  default:
    assert(false);
    break;
  }

  return 1;
}