.131 10-15 Flashcards
Bugs may occur during…
compilation time or run time
Why may a bug occur during compilation time?
- code has incorrect syntax
- program violates common programming conventions
- issues may appear as warnings
- static analysis of code detects program is invalid
Why may a bug occur during run time?
logical error
works but not as expected
2 common (but semi-impractical) ways to debug:
divide + conquer - remove/add code till you find the bug (comment it out/back in)
printf - outputs to help follow program flow
What are the problems with debugging using printf statements?
- statements may change the behaviour of the program
- takes a lot of printf statements (timely)
- cannot examine program flow in detail
What does uBit.serial. do?
allows you to call printf + scanf functions (uBit.serial.printf/uBit.serial.scanf)
What do you need to debug a running microbit?
DAPLink
on-chip debugger (OCD) allows remote debugging
integration with VS code = powerful debugging environment
Benefits of using a debugger:
- less invasive than printf
+
allows you to… - step through program 1 instruc. at a time
- set breakpoints
- investigate machine state (memory + registers)
- investigate crashes
Debuggers tend to be…
language dependent
(though some can handle multiple)
What kind of hardware support may a debugger need?
in-system programming of logic devices
hardware support for code/data breakpoints
What different interfaces can debuggers provide?
GUI or command line
What is GDB?
GNU DeBugger - open source debugger developed by the GNU project that also created gcc
designed for C
command line interface but can be used w/ IDEs
What does (gdb) x/40xb &s do?
asks the debugger to display 40 bytes of memory starting from the address s
What is a problem when using the (gdb) x/… command?
need to consider if the system is using little/big endian when displaying data that takes up >1 byte
What does (gdb) run do?
runs the debugger
What does (gdb) break 4 do?
adds a breakpoint at line no. 4
What allows for m:b wireless communication?
2.4GHz radio module primarily designed to run BLE but also supports standard for wireless personal networks
What does simpler proprietary mode mean for m:b radio communication?
allows m:b to broadcast general purpose data packets to other m:bs
for privacy all devices appear identical
What is the m:b radio mode bandwidth used for?
split into 256 frequency channels for users to communicate on
Explain what dBm is:
used to express transmission range
received signal strength = dB
received power = W
ratio of P/1milliW = how much stronger P is than 1mW
P(dBm) = 10 x log10 (P(W)/1mW)
P(W) = 1mW x 10 x P(dBm)/10
a minus dBm indicates it’s less than 1mW
What is a datagram?
transmitted by microbits
a packet (sequence of bytes) that can be >= 32 bytes
What ways can a datagram be represented?
- an array of bytes (uint8_t array[10])
- a sequence of chars (ManagedString s(“string))
- a packet buffer - PacketBuffer b(int)
generally best to use packet buffers in latest CODAL ver
What is a managed type?
automatically reserves + releases memory as needed
e.g. PacketBuffer + ManagedString
while PacketBuffers can be read/written to anytime
ManagedStrings are immutable (cannot be changed once created unless comparing/joining to other strings)
What does packetBufferName.getRSSI() do?
retrieves received signal strength indicator measured in dBm of the most recently received datagram