#----------------------------------------------------------------------------#
# Notes : to run this script, you need to the following command in gdb:
#  gdb-multiarch -x variable_extractor.py

# Caveat : Configure the binary file path and name before running the script
# We assume that the binary file is in the same directory as the script
# The binary file name is demo.elf

# Usage:
# $ gdb -x run_gdb.py

# Created by : Ugur Kebir
# Date : 26.02.2026
# Version : 1.0
#----------------------------------------------------------------------------#

import gdb

# Dictionary to store variable values
variable_values = {}

# Run gdb-multiarch
gdb.execute("target remote localhost:5555")

# Start gdb and run the program
gdb.execute("file ./build/demo.elf")

# Set a breakpoint at main
gdb.execute("break main")
gdb.execute("break EXTI15_10_IRQHandler")
gdb.execute("break USART1_IRQHandler")
gdb.execute("break TIM2_IRQHandler")

# Run load command in gdb
gdb.execute("load")

# Continue execution
gdb.execute("continue")