From 734a337d071c185a1c4c33f569e20ad4ee4ce767 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:18:33 +0100 Subject: [PATCH 1/7] assemble with debug information --- agb/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/agb/build.rs b/agb/build.rs index b46c17aa..360dfae0 100644 --- a/agb/build.rs +++ b/agb/build.rs @@ -12,6 +12,7 @@ fn main() { let out = std::process::Command::new("arm-none-eabi-as") .arg("-mthumb-interwork") .arg("-mthumb") + .arg("-g") .args(&["-o", out_file_path.as_str()]) .arg("crt0.s") .output() From 94a0f8720974fbe13e1fdc73967b97e7b11576cb Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:18:54 +0100 Subject: [PATCH 2/7] build with debug information and zero optimisation --- agb/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agb/Cargo.toml b/agb/Cargo.toml index 580036b6..b0e7c590 100644 --- a/agb/Cargo.toml +++ b/agb/Cargo.toml @@ -7,7 +7,8 @@ description = "Library for Game Boy Advance Development" license = "MPL-2.0" [profile.dev] -opt-level = 2 +opt-level = 0 +debug = true [profile.release] panic = "abort" From 0ba57ea6d0f749f50fda47ec93be1e07968f6078 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:19:38 +0100 Subject: [PATCH 3/7] include debug information in elf --- agb/gba.ld | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/agb/gba.ld b/agb/gba.ld index f2c67ffd..3569c174 100644 --- a/agb/gba.ld +++ b/agb/gba.ld @@ -69,6 +69,38 @@ SECTIONS { __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; + /* debugging sections */ + /* Stabs */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* discard anything not already mentioned */ /DISCARD/ : { *(*) } } \ No newline at end of file From f00e9e58caed37eaa6273689489fa8f21671bffa Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:20:00 +0100 Subject: [PATCH 4/7] add chicken debugger launch.json --- agb/.vscode/launch.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 agb/.vscode/launch.json diff --git a/agb/.vscode/launch.json b/agb/.vscode/launch.json new file mode 100644 index 00000000..014e67ff --- /dev/null +++ b/agb/.vscode/launch.json @@ -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": [ + { + "type": "gdb", + "request": "attach", + "name": "Attach to gdbserver", + "executable": "target/thumbv4t-none-eabi/debug/examples/chicken", + "target": "127.0.0.1:2345", + "remote": true, + "cwd": "${workspaceRoot}", + "gdbpath": "arm-none-eabi-gdb", + } + ] +} \ No newline at end of file From 6508885193e790c5291f0e315c7f3cb9e852a4dc Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:20:29 +0100 Subject: [PATCH 5/7] fix object in opt-level 0 not sure why it didn't work before --- agb/src/display/object.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 439bd7a7..2ae631c1 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -1,6 +1,8 @@ use super::DISPLAY_CONTROL; +use crate::memory_mapped::MemoryMapped1DArray; -const OBJECT_MEMORY_STANDARD: *mut [ObjectAttributeStandard; 128] = 0x0700_0000 as *mut [_; 128]; +const OBJECT_MEMORY_STANDARD: MemoryMapped1DArray = + unsafe { MemoryMapped1DArray::new(0x0700_0000) }; #[non_exhaustive] pub struct ObjectControl {} @@ -37,8 +39,6 @@ impl ObjectStandard { } } -#[repr(packed)] -#[derive(Clone, Copy)] pub struct ObjectAttributeStandard { low: u32, high: u32, @@ -46,8 +46,8 @@ pub struct ObjectAttributeStandard { impl ObjectAttributeStandard { unsafe fn commit(&self, index: usize) { - (&mut (*OBJECT_MEMORY_STANDARD)[index] as *mut ObjectAttributeStandard) - .write_volatile(*self) + OBJECT_MEMORY_STANDARD.set(index * 2, self.low); + OBJECT_MEMORY_STANDARD.set(index * 2 + 1, self.high); } pub fn set_hflip(&mut self, hflip: bool) { @@ -108,7 +108,7 @@ impl ObjectControl { pub unsafe fn clear_objects(&mut self) { let mut o = ObjectAttributeStandard::new(); o.set_mode(Mode::Hidden); - for index in 0..(*OBJECT_MEMORY_STANDARD).len() { + for index in 0..128 { o.commit(index); } } From efd89d2bde59b0b1e26bd2563b0e57bdd38cb810 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:25:38 +0100 Subject: [PATCH 6/7] remove .vscode from .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 15aac9f2..5ccfbda5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ target /out -/.vscode From 5bf6635153d4300370873355c6daede8dd548e46 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Thu, 20 May 2021 07:25:51 +0100 Subject: [PATCH 7/7] move launch.json to parent --- {agb/.vscode => .vscode}/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {agb/.vscode => .vscode}/launch.json (86%) diff --git a/agb/.vscode/launch.json b/.vscode/launch.json similarity index 86% rename from agb/.vscode/launch.json rename to .vscode/launch.json index 014e67ff..0b12af7d 100644 --- a/agb/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "type": "gdb", "request": "attach", "name": "Attach to gdbserver", - "executable": "target/thumbv4t-none-eabi/debug/examples/chicken", + "executable": "agb/target/thumbv4t-none-eabi/debug/examples/chicken", "target": "127.0.0.1:2345", "remote": true, "cwd": "${workspaceRoot}",