@@ -1365,6 +1365,9 @@ class EideTerminalProvider implements vscode.TerminalProfileProvider {
13651365///////////////////////////////////////////////////
13661366
13671367import { FileWatcher } from '../lib/node-utility/FileWatcher' ;
1368+ import { ToolchainManager , ToolchainName } from './ToolchainManager' ;
1369+
1370+ type MapViewParserType = 'memap' | 'builtin' ;
13681371
13691372interface MapViewRef {
13701373
@@ -1374,7 +1377,9 @@ interface MapViewRef {
13741377
13751378 title : string ;
13761379
1377- toolName : string ;
1380+ parser : MapViewParserType ;
1381+
1382+ toolchainId : string ;
13781383
13791384 treeDepth : number ;
13801385
@@ -1418,24 +1423,40 @@ class MapViewEditorProvider implements vscode.CustomTextEditorProvider {
14181423 return ;
14191424 }
14201425
1421- let toolName = 'ARM_MICRO' ;
1426+ let toolchainId = conf . tool ;
14221427 let fileDepth = SettingManager . GetInstance ( ) . getMapViewParserDepth ( ) ;
14231428
14241429 if ( fileDepth < 0 )
14251430 fileDepth = 1 ;
14261431
1427- switch ( conf . tool ) {
1432+ let parser : MapViewParserType = 'memap' ;
1433+
1434+ switch ( toolchainId ) {
14281435 case 'AC5' :
14291436 case 'AC6' :
1430- toolName = 'ARM_MICRO' ;
1431- break ;
14321437 case 'GCC' :
1433- toolName = 'GCC_ARM ' ;
1438+ parser = 'memap ' ;
14341439 break ;
14351440 default :
1436- webviewPanel . webview . html = this . genHtmlCont ( title ,
1441+ parser = 'builtin' ;
1442+ break ;
1443+ }
1444+
1445+ // check: do we have support a builtin parser ?
1446+ if ( parser == 'builtin' ) {
1447+
1448+ let isSupported = false ;
1449+
1450+ const toolchain = ToolchainManager . getInstance ( ) . getToolchainByName ( < ToolchainName > toolchainId ) ;
1451+ if ( toolchain ) {
1452+ isSupported = toolchain . parseMapFile != undefined ;
1453+ }
1454+
1455+ if ( ! isSupported ) {
1456+ webviewPanel . webview . html = this . genHtmlCont ( title ,
14371457 `<span class="error">Error</span>: We don't support this toolchain type: '${ conf . tool } ' yet !` ) ;
14381458 return ;
1459+ }
14391460 }
14401461
14411462 // get map file
@@ -1462,7 +1483,8 @@ class MapViewEditorProvider implements vscode.CustomTextEditorProvider {
14621483 uid : uid ,
14631484 vscWebview : webviewPanel . webview ,
14641485 title : title ,
1465- toolName : toolName ,
1486+ parser : parser ,
1487+ toolchainId : toolchainId ,
14661488 treeDepth : fileDepth ,
14671489 mapPath : mapFile . path
14681490 } ) ;
@@ -1510,18 +1532,52 @@ class MapViewEditorProvider implements vscode.CustomTextEditorProvider {
15101532 for ( const vInfo of mInfo . refList ) {
15111533 try {
15121534
1513- let lines : string [ ] ;
1514-
1515- if ( os . platform ( ) == 'win32' ) {
1516- lines = ChildProcess
1517- . execSync ( `memap -t ${ vInfo . toolName } -d ${ vInfo . treeDepth } "${ vInfo . mapPath } "` )
1518- . toString ( ) . split ( / \r \n | \n / ) ;
1519- } else {
1520- const memapRoot = ResManager . GetInstance ( ) . getBuilderDir ( ) . path + File . sep + 'utils' ;
1521- const command = `python memap -t ${ vInfo . toolName } -d ${ vInfo . treeDepth } "${ vInfo . mapPath } "` ;
1522- lines = ChildProcess
1523- . execSync ( command , { cwd : memapRoot } )
1524- . toString ( ) . split ( / \r \n | \n / ) ;
1535+ let lines : string [ ] = [ ] ;
1536+
1537+ // use memap tools
1538+ if ( vInfo . parser == 'memap' ) {
1539+
1540+ let memapTyp = 'ARM_MICRO' ;
1541+
1542+ switch ( vInfo . toolchainId ) {
1543+ case 'AC5' :
1544+ case 'AC6' :
1545+ memapTyp = 'ARM_MICRO' ;
1546+ break ;
1547+ case 'GCC' :
1548+ memapTyp = 'GCC_ARM' ;
1549+ break ;
1550+ default :
1551+ throw new Error ( `We don't support this toolchain type: '${ vInfo . toolchainId } ' yet !` ) ;
1552+ }
1553+
1554+ if ( os . platform ( ) == 'win32' ) {
1555+ lines = ChildProcess
1556+ . execSync ( `memap -t ${ memapTyp } -d ${ vInfo . treeDepth } "${ vInfo . mapPath } "` )
1557+ . toString ( ) . split ( / \r \n | \n / ) ;
1558+ } else {
1559+ const memapRoot = ResManager . GetInstance ( ) . getBuilderDir ( ) . path + File . sep + 'utils' ;
1560+ const command = `python memap -t ${ memapTyp } -d ${ vInfo . treeDepth } "${ vInfo . mapPath } "` ;
1561+ lines = ChildProcess
1562+ . execSync ( command , { cwd : memapRoot } )
1563+ . toString ( ) . split ( / \r \n | \n / ) ;
1564+ }
1565+ }
1566+ // use built-in tools
1567+ else {
1568+
1569+ const toolchain = ToolchainManager . getInstance ( ) . getToolchainByName ( < ToolchainName > vInfo . toolchainId ) ;
1570+ if ( ! toolchain ) {
1571+ throw new Error ( `not have this toolchain: '${ vInfo . toolchainId } '` ) ;
1572+ }
1573+
1574+ if ( toolchain . parseMapFile ) {
1575+ let ret = toolchain . parseMapFile ( vInfo . mapPath ) ;
1576+ if ( ret instanceof Error )
1577+ throw ret ;
1578+ else
1579+ lines = ret ;
1580+ }
15251581 }
15261582
15271583 // append color
0 commit comments