get asm symbolic source debugging working with gnu assembler and gdb psyq builds

This commit is contained in:
2025-08-06 14:18:11 -04:00
parent b9494d219f
commit 8b252c4e68
6 changed files with 21 additions and 15 deletions
+1 -1
View File
@@ -85,4 +85,4 @@ typedef def_struct(gp_Vec2) {
U16 y; U16 y;
}; };
extern void gp_screen_init(); void gp_screen_init();
@@ -1,11 +1,9 @@
.include "./toolchain/pcsx-redux/src/mips/common/crt0/crt0.s" // .include "./toolchain/pcsx-redux/src/mips/common/crt0/crt0.s"
.include "./asmdd/dsl.asm" .include "./asmdd/dsl.s"
.include "./asmdd/io.asm" .include "./asmdd/io.s"
.include "./asmdd/gp.asm" .include "./asmdd/gp.s"
#.section .text.gp, "ax, @progbits"
#.align 2
.global gp_screen_init .global gp_screen_init
.type gp_screen_init, @function .type gp_screen_init, @function
gp_screen_init: gp_screen_init:
@@ -15,7 +13,6 @@ gp_screen_init:
#define gp1 gpio_port1(rio_offset) #define gp1 gpio_port1(rio_offset)
gcmd_push gp1, rtmp_1, gp_Reset gcmd_push gp1, rtmp_1, gp_Reset
nop; nop;
gcmd_push gp1, rtmp_1, gp_DisplayEnabled gcmd_push gp1, rtmp_1, gp_DisplayEnabled
jump_reg rret_addr; nop jump_reg rret_addr; nop
+15 -6
View File
@@ -17,7 +17,7 @@ if ((test-path $path_build) -eq $false) {
# Assumes 'mipsel-none-elf' toolchain is in your system's PATH. # Assumes 'mipsel-none-elf' toolchain is in your system's PATH.
$Prefix = "mipsel-none-elf" $Prefix = "mipsel-none-elf"
$Compiler = "$($Prefix)-gcc" $Compiler = "$($Prefix)-gcc"
$Assembler = $Compiler $Assembler = "$($Prefix)-as"
$Objcopy = "$($Prefix)-objcopy" $Objcopy = "$($Prefix)-objcopy"
# --- GCC/MIPS Flags --- # --- GCC/MIPS Flags ---
@@ -78,7 +78,7 @@ $f_objcopy_format = "-O"
$path_pcsx_redux = join-path $path_toolchain 'pcsx-redux' $path_pcsx_redux = join-path $path_toolchain 'pcsx-redux'
$path_nugget = join-path $path_pcsx_redux 'src/mips' $path_nugget = join-path $path_pcsx_redux 'src/mips'
# $path_nugget_common = join-path $path_nugget 'common' $path_nugget_common = join-path $path_nugget 'common'
$path_psyq = join-path $path_toolchain 'psyq-4_7' $path_psyq = join-path $path_toolchain 'psyq-4_7'
$path_psyq_iwyu = join-path $path_toolchain 'psyq_iwyu' $path_psyq_iwyu = join-path $path_toolchain 'psyq_iwyu'
$path_psyq_imyu_inc = join-path $path_psyq_iwyu 'include' $path_psyq_imyu_inc = join-path $path_psyq_iwyu 'include'
@@ -111,7 +111,7 @@ function assemble-unit { param(
write-host "Assembling '$unit' -> '$link_module'" -ForegroundColor Cyan write-host "Assembling '$unit' -> '$link_module'" -ForegroundColor Cyan
$assemble_args | ForEach-Object { Write-Host "`t$_" -ForegroundColor Green } $assemble_args | ForEach-Object { Write-Host "`t$_" -ForegroundColor Green }
& $Assembler $assemble_args & $Compiler $assemble_args
if ($LASTEXITCODE -ne 0) { write-error "Compilation failed for $unit. Aborting."; exit 1 } if ($LASTEXITCODE -ne 0) { write-error "Compilation failed for $unit. Aborting."; exit 1 }
} }
function compile-unit { param( function compile-unit { param(
@@ -147,7 +147,8 @@ function compile-unit { param(
$compile_args += $user_compile_args $compile_args += $user_compile_args
$compile_args += $f_compile, $unit, ($f_output + $link_module) $compile_args += $f_compile
$compile_args += $unit, ($f_output + $link_module)
write-host "Compiling '$unit' -> '$link_module'" -ForegroundColor Cyan write-host "Compiling '$unit' -> '$link_module'" -ForegroundColor Cyan
$compile_args | ForEach-Object { Write-Host "`t$_" -ForegroundColor Green } $compile_args | ForEach-Object { Write-Host "`t$_" -ForegroundColor Green }
@@ -216,10 +217,14 @@ function link-modules { param(
$final_link_args = @($link_args) + ($f_output + $elf) $final_link_args = @($link_args) + ($f_output + $elf)
$base_name = [System.IO.Path]::GetFileNameWithoutExtension($elf)
$dasm = "$(join-path $path_build $base_name).dasm"
write-host "Linking modules into '$elf'" -ForegroundColor Cyan write-host "Linking modules into '$elf'" -ForegroundColor Cyan
$final_link_args += ($f_link_pass_through_prefix + $f_link_end_group) $final_link_args += ($f_link_pass_through_prefix + $f_link_end_group)
$final_link_args | foreach-object { write-host $_ } $final_link_args | foreach-object { write-host $_ }
& $Compiler $final_link_args & $Compiler $final_link_args
& mipsel-none-elf-objdump.exe -W $elf >> $dasm
if ($LASTEXITCODE -ne 0) { write-error "Linking failed. Aborting."; exit 1 } if ($LASTEXITCODE -ne 0) { write-error "Linking failed. Aborting."; exit 1 }
} }
function make-binary { param( function make-binary { param(
@@ -270,13 +275,17 @@ function build-graphis_hello {
$path_module = join-path $path_code 'graphics_hello_psyq' $path_module = join-path $path_code 'graphics_hello_psyq'
$src_asm = join-path $path_module 'hello_gpu.asm' $src_asm_crt = join-path $path_nugget_common 'crt0/crt0.s'
$module_asm_crt = join-path $path_build 'crt0.o'
$src_asm = join-path $path_module 'hello_gpu.s'
$module_asm = join-path $path_build 'hello_gpu.o' $module_asm = join-path $path_build 'hello_gpu.o'
$assemble_args = @() $assemble_args = @()
$assemble_args += $f_debug $assemble_args += $f_debug
$assemble_args += $f_optimize_none $assemble_args += $f_optimize_none
$assemble_args += ($f_include + $path_code) $assemble_args += ($f_include + $path_code)
assemble-unit $src_asm_crt $module_asm_crt $includes $assemble_args
assemble-unit $src_asm $module_asm $includes $assemble_args assemble-unit $src_asm $module_asm $includes $assemble_args
$src_c = join-path $path_module 'hello_gpu.c' $src_c = join-path $path_module 'hello_gpu.c'
@@ -295,7 +304,7 @@ function build-graphis_hello {
$link_args = @() $link_args = @()
$link_args += $f_debug $link_args += $f_debug
# $link_args += $f_optimize_size # $link_args += $f_optimize_size
link-modules @($module_asm, $module_c) $elf $link_args link-modules @($module_asm_crt, $module_asm, $module_c) $elf $link_args
make-binary $elf $exe make-binary $elf $exe
} }
build-graphis_hello build-graphis_hello