@@ -75,6 +75,14 @@ export enum ConsoleTypes {
7575 newExternalWindow = 'newExternalWindow'
7676}
7777
78+ /**
79+ * Creates a GDB debug configuration for VSCode.
80+ *
81+ * @param debuggerPath - The path to the GDB debugger executable.
82+ * @param target - The executable target to be debugged.
83+ * @returns A promise that resolves to a VSCode debug configuration object.
84+ * @throws An error if GDB is not found in the provided path or the default search path.
85+ */
7886async function createGDBDebugConfiguration ( debuggerPath : string , target : ExecutableTarget ) : Promise < VSCodeDebugConfiguration > {
7987 if ( ! await checkDebugger ( debuggerPath ) ) {
8088 debuggerPath = 'gdb' ;
@@ -102,6 +110,14 @@ async function createGDBDebugConfiguration(debuggerPath: string, target: Executa
102110 } ;
103111}
104112
113+ /**
114+ * Creates a LLDB debug configuration for VSCode.
115+ *
116+ * @param debuggerPath - The path to the LLDB debugger executable.
117+ * @param target - The executable target to be debugged.
118+ * @returns A promise that resolves to a VSCode debug configuration object.
119+ * @throws An error if the debugger is not found in the specified path.
120+ */
105121async function createLLDBDebugConfiguration ( debuggerPath : string , target : ExecutableTarget ) : Promise < VSCodeDebugConfiguration > {
106122 if ( ! await checkDebugger ( debuggerPath ) ) {
107123 throw new Error ( localize ( 'gdb.not.found' , 'Unable to find GDB in default search path and {0}.' , debuggerPath ) ) ;
@@ -119,6 +135,12 @@ async function createLLDBDebugConfiguration(debuggerPath: string, target: Execut
119135 } ;
120136}
121137
138+ /**
139+ * Creates a Visual Studio Code debug configuration for an MSVC (Microsoft Visual C++) executable target.
140+ *
141+ * @param target - The executable target for which to create the debug configuration.
142+ * @returns A `VSCodeDebugConfiguration` object configured for debugging the specified target.
143+ */
122144function createMsvcDebugConfiguration ( target : ExecutableTarget ) : VSCodeDebugConfiguration {
123145 return {
124146 type : 'cppvsdbg' ,
@@ -150,6 +172,17 @@ const debuggerGenerators: DebuggerGenerators = {
150172 }
151173} ;
152174
175+ /**
176+ * Searches for the compiler path in the provided CMake cache.
177+ *
178+ * This function iterates over a predefined list of programming languages
179+ * (CXX, C, CUDA) and checks if the corresponding compiler path is present
180+ * in the cache. If found, it returns the compiler path as a string.
181+ * If no compiler path is found for any of the languages, it returns null.
182+ *
183+ * @param cache - The CMake cache to search for the compiler path.
184+ * @returns The compiler path as a string if found, otherwise null.
185+ */
153186function searchForCompilerPathInCache ( cache : CMakeCache ) : string | null {
154187 const languages = [ 'CXX' , 'C' , 'CUDA' ] ;
155188 for ( const lang of languages ) {
@@ -162,6 +195,16 @@ function searchForCompilerPathInCache(cache: CMakeCache): string | null {
162195 return null ;
163196}
164197
198+ /**
199+ * Retrieves the debug configuration from the CMake cache for a given target and platform.
200+ * @param cache - The CMake cache containing build configuration information.
201+ * @param target - The executable target for which the debug configuration is being retrieved.
202+ * @param platform - The platform for which the debug configuration is being retrieved (e.g., 'darwin', 'win32').
203+ * @param modeOverride - Optional override for the MI mode (e.g., 'gdb', 'lldb').
204+ * @param debuggerPathOverride - Optional override for the debugger path.
205+ * @returns A promise that resolves to a VSCode debug configuration or null if no suitable configuration is found.
206+ * @throws An error if no compiler is found in the cache.
207+ */
165208export async function getDebugConfigurationFromCache ( cache : CMakeCache , target : ExecutableTarget , platform : string , modeOverride ?: MIModes , debuggerPathOverride ?: string ) : Promise < VSCodeDebugConfiguration | null > {
166209 const entry = cache . get ( 'CMAKE_LINKER' ) ;
167210 if ( entry !== null && ! modeOverride && ! debuggerPathOverride ) {
0 commit comments