@@ -18,6 +18,7 @@ import * as vscode from 'vscode';
1818import { ExtendedGDBTargetConfiguration , GDBTargetConfiguration } from '../gdbtarget-configuration' ;
1919import { CbuildRunReader } from '../../cbuild-run' ;
2020import { logger } from '../../logger' ;
21+ import { extractPname } from '../../utils' ;
2122
2223export abstract class BaseConfigurationProvider implements vscode . DebugConfigurationProvider {
2324 protected _cbuildRunReader ?: CbuildRunReader ;
@@ -75,22 +76,12 @@ export abstract class BaseConfigurationProvider implements vscode.DebugConfigura
7576 extDebugConfig . definitionPath = svdFilePaths [ 0 ] ;
7677 }
7778
78- protected extractPname ( debugConfiguration : GDBTargetConfiguration ) : string | undefined {
79+ protected extractPnameFromDebugConfig ( debugConfiguration : GDBTargetConfiguration ) : string | undefined {
7980 const pnames = this . cbuildRunReader . getPnames ( ) ;
8081 if ( ! pnames . length ) {
8182 return undefined ;
8283 }
83- // Config names in debugger templates are pretty free-form. Hence, can't do a lot
84- // of format validation without reading debugger templates. Only check if name
85- // begins with valid pname string, and if string is part of processor list.
86- const configName = debugConfiguration . name . trim ( ) ;
87- const pnameRegexp = / [ - _ A - Z a - z 0 - 9 ] + \s + .+ / ;
88- if ( ! pnameRegexp . test ( configName ) ) {
89- // Not the right format, Pname is 'RestrictedString' in PDSC format.
90- return undefined ;
91- }
92- const pname = configName . slice ( 0 , configName . indexOf ( ' ' ) ) ;
93- return pnames . includes ( pname ) ? pname : undefined ;
84+ return extractPname ( debugConfiguration . name , pnames ) ;
9485 }
9586
9687 protected abstract resolveServerParameters ( debugConfiguration : GDBTargetConfiguration ) : Promise < GDBTargetConfiguration > ;
@@ -101,7 +92,7 @@ export abstract class BaseConfigurationProvider implements vscode.DebugConfigura
10192 _token ?: vscode . CancellationToken
10293 ) : Promise < vscode . DebugConfiguration | null | undefined > {
10394 await this . parseCbuildRunFile ( debugConfiguration ) ;
104- this . resolveSvdFile ( debugConfiguration , this . extractPname ( debugConfiguration ) ) ;
95+ this . resolveSvdFile ( debugConfiguration , this . extractPnameFromDebugConfig ( debugConfiguration ) ) ;
10596 return this . resolveServerParameters ( debugConfiguration ) ;
10697 }
10798
0 commit comments