Skip to content

Instantly share code, notes, and snippets.

@monkbroc monkbroc/particle-gdb.sh
Last active Sep 30, 2015

Embed
What would you like to do?
Start GDB for the Photon with symbols for all 3 parts
#!/bin/bash
READELF=arm-none-eabi-readelf
GDB=arm-none-eabi-gdb
COMMON_BUILD=~/Programming/Photon/build
PLATFORM_ID=6
LTO=
function elf {
echo $COMMON_BUILD/target/$1/platform-$PLATFORM_ID-m$LTO/$1.elf
}
SYSTEM_PART1_ELF=$(elf system-part1)
SYSTEM_PART2_ELF=$(elf system-part2)
USER_PART_ELF=$(elf user-part)
function text_section_address {
$READELF $1 --headers | grep .text | head -n 1 | sed "s/.*PROGBITS *\\([^ ]*\\).*/0x\\1/"
}
SYSTEM_PART1_ADDRESS=$(text_section_address $SYSTEM_PART1_ELF)
SYSTEM_PART2_ADDRESS=$(text_section_address $SYSTEM_PART2_ELF)
USER_PART_ADDRESS=$(text_section_address $USER_PART_ELF)
$GDB \
-ex "target remote localhost:3333" \
-ex "set confirm off" \
-ex "add-symbol-file $SYSTEM_PART1_ELF $SYSTEM_PART1_ADDRESS" \
-ex "add-symbol-file $SYSTEM_PART2_ELF $SYSTEM_PART2_ADDRESS" \
-ex "add-symbol-file $USER_PART_ELF $USER_PART_ADDRESS" \
-ex "set confirm on"
@monkbroc

This comment has been minimized.

Copy link
Owner Author

commented Aug 18, 2015

Comments on simplifying this script would be appreciated. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.