Add gdb debugging capability
This commit is contained in:
parent
9983e298a0
commit
740a0c46f4
5 changed files with 63 additions and 23 deletions
18
.vscode/launch.json
vendored
Normal file
18
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Nim Debug",
|
||||
"type": "gdb",
|
||||
"request": "launch",
|
||||
"target": "${workspaceFolder}\\build\\demo\\demo_glfw_debug.exe",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"gdbpath": "${workspaceFolder}\\nim-gdb.bat",
|
||||
"valuesFormatting": "parseText"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
source C:/Users/jyapa/.choosenim/toolchains/nim-#devel/tools/nim-gdb.py
|
||||
|
|
@ -17,11 +17,10 @@ requires "nim >= 1.0.0",
|
|||
|
||||
import os
|
||||
|
||||
task buildSDL2Example, "Build SDL2 example":
|
||||
let buildDir = "build/demosdl2"
|
||||
proc setupBuildDir(buildDir: string, prefixes: openArray[string]) =
|
||||
var arch = ""
|
||||
if system.existsDir(buildDir):
|
||||
rmDir buildDir
|
||||
var arch = ""
|
||||
if defined(amd64):
|
||||
arch = "64bit"
|
||||
else:
|
||||
|
|
@ -30,24 +29,33 @@ task buildSDL2Example, "Build SDL2 example":
|
|||
var files = listFiles "lib/" & arch & "/"
|
||||
for fpath in files:
|
||||
let fname = fpath.extractFileName()
|
||||
if fname.startsWith("lib") or fname.startsWith("SDL2") or fname.startsWith("glew"):
|
||||
cpFile fpath, buildDir & "/" & fname
|
||||
for prefix in prefixes:
|
||||
if fname.startsWith(prefix):
|
||||
cpFile fpath, buildDir & "/" & fname
|
||||
|
||||
proc setupGLFW(): string =
|
||||
switch("define", "useGlfw")
|
||||
let buildDir = "build/demo"
|
||||
setupBuildDir(buildDir, ["gl"])
|
||||
return buildDir
|
||||
|
||||
proc setupSDL2(): string =
|
||||
let buildDir = "build/demosdl2"
|
||||
setupBuildDir(buildDir, ["lib", "SDL2", "glew"])
|
||||
return buildDir
|
||||
|
||||
task buildSDL2Example, "Build SDL2 example":
|
||||
let buildDir = setupSDL2()
|
||||
exec "nim c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_sdl2".toExe & " -r examples/demo_sdl2.nim"
|
||||
|
||||
task buildSDL2ExampleDebug, "Build SDL2 example debug":
|
||||
let buildDir = setupSDL2()
|
||||
exec "nim c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_sdl2_debug".toExe & " -r examples/demo_sdl2.nim"
|
||||
|
||||
task buildGLFWExample, "Build GLFW example":
|
||||
switch("define", "useGlfw")
|
||||
var arch = ""
|
||||
let buildDir = "build/demo"
|
||||
if system.existsDir(buildDir):
|
||||
rmDir buildDir
|
||||
if defined(amd64):
|
||||
arch = "64bit"
|
||||
else:
|
||||
arch = "32bit"
|
||||
mkDir buildDir
|
||||
var files = listFiles "lib/" & arch & "/"
|
||||
for fpath in files:
|
||||
let fname = fpath.extractFileName()
|
||||
if fname.startsWith("gl"):
|
||||
cpFile fpath, buildDir & "/" & fname
|
||||
exec "nim c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_glfw".toExe & " -r examples/demo.nim"
|
||||
let buildDir = setupGLFW()
|
||||
exec "nim c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_glfw".toExe & " -r examples/demo.nim"
|
||||
|
||||
task buildGLFWExampleDebug, "Build GLFW example debug":
|
||||
let buildDir = setupGLFW()
|
||||
exec "nim c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_glfw_debug".toExe & " -r examples/demo.nim"
|
||||
3
nim-gdb
3
nim-gdb
|
|
@ -13,7 +13,8 @@ GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py"
|
|||
# Run GDB with the additional arguments that load the pretty printers
|
||||
# Set the environment variable `NIM_GDB` to overwrite the call to a
|
||||
# different/specific command (defaults to `gdb`).
|
||||
NIM_GDB="${NIM_GDB:-gdb.exe}"
|
||||
NIM_GDB="${NIM_GDB:-gdb}"
|
||||
echo "source $GDB_PYTHON_MODULE_PATH" > gdbcommands.txt
|
||||
# exec replaces the new process of bash with gdb. It is always good to
|
||||
# have fewer processes.
|
||||
exec ${NIM_GDB} --command="gdbcommands.txt" "$@"
|
||||
14
nim-gdb.bat
Normal file
14
nim-gdb.bat
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
for %%i in (nim.exe) do (set NIM_BIN=%%~dp$PATH:i)
|
||||
|
||||
for %%i in ("%NIM_BIN%\..\") do (set NIM_ROOT=%%~fi)
|
||||
|
||||
set @GDB_PYTHON_MODULE_PATH=%NIM_ROOT%\tools\nim-gdb.py
|
||||
set @NIM_GDB=gdb.exe
|
||||
|
||||
@echo source %@GDB_PYTHON_MODULE_PATH%> wingdbcommand.txt
|
||||
|
||||
%@NIM_GDB% --command="wingdbcommand.txt" %*
|
||||
|
||||
EXIT /B %ERRORLEVEL%
|
||||
@echo on
|
||||
Loading…
Add table
Add a link
Reference in a new issue