Skip to content
Tech Interview Prep
Technical interview guide

Embedded Debugging & Toolchains

How embedded engineers actually find bugs when there's no stdout, no OS, and sometimes no working UART to print through.

Read
60 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: Current GDB remote debugging and GCC debug guidance; current OpenOCD user guide; CMSIS 6 SVD/DAP/CoreDebug reviewed 2026-09-04.

Curated: · Written: · Reviewed:

25 questions

MCQ-1A Cortex-M4 device in the field faults at PC 0x08004a2c. The build server holds three ELFs: `fw-9f3c1d.elf` (debug, commit 9f3c1d, build ID 0x8a3f21c4), `fw-4b81aa.elf` (debug, commit 4b81aa, build ID 0x4b81aa07), and `fw-release.elf` (stripped, commit 9f3c1d). The device's firmware reports build ID 0x8a3f21c4. Running addr2line with `fw-4b81aa.elf` resolves the PC to `sensor_read+0x2c` at `sensor.c:212`, but `sensor.c` in that build is 180 lines long. What should the engineer do next?
MCQ-2A C++ service crashes in production. The core dump's backtrace shows the fault at `0x00007f3a2c1b4d20`, which the build server's symbol map resolves to `OrderBook::applyDelta`. An engineer rebuilds the same commit on their laptop with GCC 13.2 and `-O2`, then runs `addr2line` on the new binary: the same address resolves to `MarketData::parse`. The build server's manifest records GCC 12.3, `-O2 -fno-omit-frame-pointer -flto`, and probe v4.2; the laptop has probe v4.1. What should the engineer conclude?
MCQ-3A service is built with gcc -O2 -g and the binary is rebuilt from the same sources right before the debugging session. In GDB, a breakpoint on the first statement of a small static helper stops inside the caller that calls it, step-next then moves the cursor to an earlier line of the caller, and a local the source assigns prints as <optimized out>. Why does the source view disagree with what the program is doing?
MCQ-6A board's reset-init script programs the PLL and the external SDRAM controller. An engineer runs `reset halt`, then `mww 0xC0001000 0x5A5A5A5A` and `mdw 0xC0001000 1`; the read returns 0x00000000. After `reset init`, the same two commands return 0x5A5A5A5A. What explains the difference?
MCQ-5A CI job runs 200 firmware test cases on a Cortex-M board through OpenOCD's gdbserver on localhost:3333, and each case must start the program from scratch. The script currently launches OpenOCD, runs `target remote localhost:3333`, `load`, `continue`, waits for the program to exit, then kills OpenOCD and repeats; the launch-and-connect step costs about 6 s, so the job spends roughly 20 minutes reconnecting. The team wants one OpenOCD instance and one GDB session for all 200 cases. Which change achieves that, and why?
MCQ-8An OpenOCD production script programs 400 boards a day with `flash write_image erase app.bin 0x08000000` then `flash write_image erase cal.bin 0x08040000`, then runs `reset run`. The flash driver reports success on every unit, but 3% come back from the field running default calibration values. The application version reported over UART is correct on all of them. What should the script do before `reset run`?
MCQ-25A Cortex-M board halts reliably if you attach with halt-on-connect while nRESET is asserted, but if you let the application run for five seconds first, OpenOCD reads the expected DP IDR and then fails to halt the core. The same probe, cable, host and OpenOCD config halt an identical board running a different image. Which check does that pattern point to?
MCQ-9A Cortex-M4 target executes code in place from on-chip flash: 2 KB erase sectors, 10,000 erase cycles per sector. The debug probe's FPB unit provides 2 instruction comparators. During a session an engineer sets and clears a breakpoint on a hot function 500 times; that function shares its 2 KB sector with a calibration table the debugger must preserve. Which outcome makes the software-breakpoint approach the wrong choice here?
MCQ-10A Cortex-M4 target's DWT provides four watchpoint comparators. In a debug session the engineer has set watchpoints on five RAM variables (`g_rx_head`, `g_rx_tail`, `g_tx_head`, `g_tx_tail` and `g_dma_count`) all 4-byte aligned, and the IDE lists all five as active. Writes to `g_dma_count` never halt the target; writes to the other four do. Reconnecting the debugger changes nothing. What explains the missing trigger?
MCQ-22A driver's SPI status register reports transfer complete with no error bits set, yet the attached sensor intermittently returns wrong readings. The team attaches a logic analyzer to SCLK, MOSI, MISO and CS and triggers on the CS falling edge of a failing transaction. What does the capture establish that the controller's own status flags cannot?
MCQ-13A team generates a peripheral driver from the vendor's CMSIS SVD pack. The SVD lists the interrupt status register as read-only with one flag bit at bit 0. The handler reads the register and writes 0 back to clear the flag. On the bench the handler re-enters 47,000 times in a 10 s window while the event line shows 47 pulses. In the debugger, writing 1 to bit 0 clears the flag; writing 0 leaves it set. Which conclusion about the SVD is correct?
MCQ-12An interrupt-driven UART receiver reads RDR whenever the receive FIFO is non-empty, and reading RDR pops one byte. With the debugger detached the firmware loses nothing. An engineer attaches a debugger and adds RDR to its live watch, which reads the register about every 200 ms. The application now loses roughly 5 bytes/s, evenly spread across the run, and the overrun (ORE) flag is never set. The line runs at 115200 baud (about 87 us per byte), the RX FIFO is 8 bytes deep, and the debugger's timing log puts each polled read at about 1 us. Which explanation fits these numbers?
MCQ-14A Cortex-M4 board (STM32F407, FreeRTOS) hard-faults in a task. The handler is: ```c void HardFault_Handler(void) { uint32_t *frame = (uint32_t *)__get_MSP(); crash.pc = frame[6]; crash.lr = frame[5]; crash.psr = frame[7]; NVIC_SystemReset(); } ``` Every unit reports the same crash.pc (0x20001A44, a RAM address) whatever task faulted. The faulting task was running on PSP. What is the correct fix?
MCQ-15A Cortex-M4 firmware built with -O2 (no frame pointers) hard-faults. The handler reads the exception frame: PC = 0x0800_2A4E, SP = 0x2000_06C0, with the stack region 0x2000_0000–0x2000_0800. It then scans upward from SP and prints every 4-byte word that falls in the flash text range 0x0800_0000–0x0803_FFFF, producing: parse_frame+0x12, sensor_task+0x40, main+0x8C. Disassembly shows parse_frame+0x12 is `add sp, #8`; the symbol table maps 0x0800_2A4E to crc_update+0x1A, a symbol whose range does not overlap parse_frame's. What should the engineer conclude?
MCQ-16A Cortex-M board runs an RTOS whose task-control-block layout changed between the kernel release the team's GDB thread-awareness plugin was built against and the release in the shipped firmware. On halt the plugin lists 9 tasks and shows `sensor_poll` in RUNNING; the kernel's own scheduler trace shows 6 tasks, with `sensor_poll` blocked on a semaphore for the last 4 s. What should the engineer conclude before trusting any task state?
MCQ-21A C service on x86-64 Linux allocates from one 1 MiB arena with a bump allocator: objects sit back-to-back with no headers, and nothing is ever freed. Each connection is a 128-byte `struct conn` whose bytes 0-3 are `uint32_t magic` (written as 0xC0FFEE01 at allocation), bytes 4-7 are `uint32_t fd`, and bytes 8-127 are the receive buffer. Immediately before one connection's block sits a 120-byte `char hdr[120]` filled by `memcpy(hdr, pkt, pkt->len)`, where `pkt->len` is a `uint32_t` read from the wire and `pkt` is a 128-byte buffer whose last 8 bytes are zero. A worker aborts: `conn_send()` reads `magic == 0x00000000` and `fd == 0x00000000`, while bytes 8-127 of the block are unchanged. Which explanation fits the evidence?
MCQ-20A Cortex-M4 product is built with `--specs=rdimon.specs`, so `printf` output goes to the debugger over semihosting; the board has no UART wired. On the bench with a J-Link attached, units run for hours. In the field with no probe attached, every unit resets after about 2 s: the watchdog fires, and the fault dump shows the stacked PC inside `_write`. Which mechanism explains the field resets?
MCQ-19A Cortex-M4 board runs a motor-control ISR every 100 µs. Each ISR calls a synchronous UART log helper that clocks out a 60-byte line at 115200 baud, and the watchdog resets the board during transients. Which change makes the log usable for post-mortem diagnosis?
MCQ-7A 3.3 V battery node runs firmware that reads the MCU's reset-cause register once at startup and branches on it: the sensor self-test runs only when the power-on (POR) bit is set; otherwise the code takes a fast warm path that prints 'warm'. Six of 400 field units hang inside that self-test. On the bench the same board never fails: the engineer presses NRST and presses Reset in the ST-Link debugger (system reset) 30 times each, the app restarts and prints 'warm' every time, and a scope on VDD stays at 3.29 V through every reset. Removing the battery and refitting it hangs the unit on the first attempt, with VDD falling to about 0.1 V before rising again. Which explanation fits this evidence?
MCQ-4A C++20 order gateway on x86-64 is compiled with clang 17.0.1 as -O2 -flto. In production it discards about 1 order in 5,000, roughly 25 per minute, somewhere between the NIC-polling thread and the matching thread, which pass orders through a lock-free ring buffer. Local reproduction fails, so an engineer rebuilds the same commit at -O0 -fsanitize=thread, pins it to the same core and replays 3,000,000 recorded production orders: zero drops, zero TSan reports. Which next step is most likely to reproduce the loss?
MCQ-11A Cortex-M7 at 480 MHz runs a motor-control loop. A hardware data watchpoint on the shared buffer's write address halts the core on the third write; the debugger resumes after the operator inspects state. In that run the ISR-entry GPIO toggle appears 12 µs later than in 100 normal runs. The team needs to know whether the suspected race exists in the original system. What should they do next?
MCQ-18A Cortex-M7 board runs a current-control ISR every 50 µs. A fault that corrupts the PWM duty registers appears about once every 20 minutes, and only when a CAN RX interrupt lands inside the ISR. The motor driver's watchdog resets the board 2 ms after the core stops executing. Attaching a debugger and setting a breakpoint in the ISR never reproduces the fault. What should the team do next?
MCQ-17A quad-core ARMv8-A SoC is attached to a debugger in non-stop mode. Core 1 is halted at a breakpoint inside a critical section while holding spinlock L, with interrupts disabled. Core 2 runs a worker that calls spin_lock(L) in a loop with interrupts disabled. Core 0 takes a 10 ms timer interrupt every 50 ms; its ISR also calls spin_lock(L) with interrupts disabled. Core 3 runs the only watchdog kicker: it kicks a 400 ms hardware watchdog every 100 ms, its kicker does not use L, and its last kick was 30 ms before core 1 halted. An Ethernet DMA engine is midway through a 2048-byte write into a non-cacheable buffer that core 1 was updating; the DMA engine does not check core ownership. Which set of observations should the engineer expect 500 ms after the halt?
MCQ-23A fleet of 4,000 ARM Linux gateways ships with secure boot, a dm-verity-protected read-only root filesystem, and a signed application. A penetration test finds `gdbserver :3333` listening on the management VLAN on every unit, running as uid 0 with no authentication. The vendor calls the finding low risk, arguing that secure boot and dm-verity prevent any persistent change. Which assessment is correct?
MCQ-24A payments team runs a game day: they inject a fault that kills the payments service process for 10 minutes. That process also hosts the metrics exporter. Their paging rule is `sum(rate(charges_success_total[5m])) == 0` sustained for 5 minutes. No page fires during the 10 minutes. What does this run establish?