@@ -18,7 +18,7 @@ import {
1818 createPortName , GenericCustomEvent , quoteShellCmdLine , toStringDecHexOctBin , ADAPTER_DEBUG_MODE , defSymbolFile , CTIAction , getPathRelative ,
1919 SWOConfigureEvent , RTTCommonDecoderOpts
2020} from './common' ;
21- import { GDBServer , ServerConsoleLog } from './backend/server' ;
21+ import { GDBServer , getServerLogFilePath , ServerConsoleLog } from './backend/server' ;
2222import { MINode } from './backend/mi_parse' ;
2323import { expandValue , isExpandable } from './backend/gdb_expansion' ;
2424import { GdbDisassembler } from './backend/disasm' ;
@@ -423,6 +423,9 @@ export class GDBDebugSession extends LoggingDebugSession {
423423 this . handleMsg ( 'stdout' ,
424424 `Cortex-Debug: VSCode debugger extension version ${ args . pvtVersion } git(${ __COMMIT_HASH__ } ). `
425425 + 'Usage info: https://github.com/Marus/cortex-debug#usage' ) ;
426+ if ( this . args . showDevDebugOutput ) {
427+ this . handleMsg ( 'stderr' , `INFO: A log of gdb-servers, gdb, debug adapter start/stop/pid info can be found in '${ getServerLogFilePath ( ) } '.\n` ) ;
428+ }
426429
427430 this . setHWBreakpointInfo ( ) ;
428431
@@ -3628,4 +3631,23 @@ function initTwoCharsToIntMap(): object {
36283631
36293632const twoCharsToIntMap = initTwoCharsToIntMap ( ) ;
36303633
3631- LoggingDebugSession . run ( GDBDebugSession ) ;
3634+ process . on ( 'uncaughtException' , ( err ) => {
3635+ const msg = err && err . stack ? err . stack : ( err . message ? err . message : 'unknown error' ) ;
3636+ console . error ( 'cortex-debug: Caught exception:' , msg ) ;
3637+ ServerConsoleLog ( 'Caught exception: ' + msg ) ;
3638+ process . exit ( 1 ) ; // The process is in an unreliable state, so exit is recommended
3639+ } ) ;
3640+
3641+ process . on ( 'unhandledRejection' , ( reason , promise ) => {
3642+ const msg = 'cortex-debug: Unhandled Rejection: reason: ' + reason . toString ( ) + ' promise: ' + promise . toString ( ) ;
3643+ console . error ( msg ) ;
3644+ ServerConsoleLog ( msg ) ;
3645+ } ) ;
3646+
3647+ try {
3648+ LoggingDebugSession . run ( GDBDebugSession ) ;
3649+ } catch ( error ) {
3650+ console . error ( 'cortex-debug: Error occurred while running GDBDebugSession:' , error ) ;
3651+ ServerConsoleLog ( 'cortex-debug: Caught exception: ' + error . toString ( ) ) ;
3652+ throw error ;
3653+ }
0 commit comments