Software Debugging Using the Debugger SAM4E Xplained Pro
Total Page:16
File Type:pdf, Size:1020Kb
Faculty of Technology and Society Computer Engineering Bachelor’s thesis 15 credits Software debugging using the debugger SAM4E Xplained Pro Mjukvarufelsökning med användning av felsökningsverktyget SAM4E Xplained Pro Hamoud Abdullah Nadia Manoh Exam: Bachelor of Science in Engineering Examiner: Ulrik Ekedahl Area: Computer Engineering Supervisor: Magnus Krampell Date of final seminar: 2018-08-21 Abstract Embedded systems are found in almost every device used in our daily lives, including cell phones, refrigerators, and cars. Some devices may be significantly more sensitive than others, meaning a bug appearing in a system could cause harm, even loss of human lives or cause no harm at all. To reduce bugs in a system, software testing and software debugging are performed. The Computer Science program at Malmö University does not focus on teaching software debugging using a debugger. Thus, this thesis presents a debugging lab created for Computer Science students, considered to help them gain knowledge in how to use the debugger SAM4E Xplained Pro to locate bugs. As a result, four students performed the debugging lab of which 75 percent of the bugs were found and remedied. Keywords: embedded system, software testing, software debugging, software failure, software bugs debugging techniques Sammanfattning Inbyggda system finns i nästan alla enheter som används i vårt dagliga liv, som exempelvis mobiltelefoner, kylskåp och bilar. En del enheter kan vara betydligt känsligare än andra, vilket innebär att en bugg som existerar i ett system kan orsaka skada, till och med förlust av människoliv, eller orsakar ingen skada alls. Mjukvarutestning och mjukvarufelsökning genomförs för att reducera buggar i ett system. Utbildningsprogrammet Datateknik och Mobil IT på Malmö universitet fokuserar inte på att undervisa mjukvarufelsökning med hjälp av felsökningsverktyg. Således presenterar denna forskning en felsökningslaboration skapat för studenter som går Datateknik och Mobil IT, som anses hjälpa studenterna att få kunskap i hur man använder felsökningsverktyget SAM4E Xplained Pro för att lokalisera buggar. Som ett resultat, utfördes felsökningslaborationen av fyra studenter varav 75 procent av buggarna hittades och åtgärdades. Acknowledgements We would like to express our gratitude to our supervisor Magnus Krampell for all the feedback, support and patience during the work of this thesis. We would also like to thank all the students who participated in the lab assignment. Last, but not least, we thank our examiner Ulrik Ekedahl for his valuable feedback. Contents 1 Introduction ................................................................................................................................................................. 1 1.1 Background .......................................................................................................................................................... 1 1.2 Problem domain ................................................................................................................................................... 2 1.3 Research questions ............................................................................................................................................. 2 1.4 Limitations............................................................................................................................................................ 3 2 Theoretical Background .............................................................................................................................................. 4 2.1 Embedded systems ............................................................................................................................................. 4 2.1.1 Real-time systems ........................................................................................................................................ 4 2.1.1.1 Hard real-time system ........................................................................................................................... 4 2.1.1.2 Soft real-time system ............................................................................................................................ 4 2.1.2 Architecture .................................................................................................................................................. 4 2.1.2.1 Single-unit system ................................................................................................................................. 4 2.1.2.2 Distributed systems ............................................................................................................................... 4 2.2 Error, fault and failure .......................................................................................................................................... 4 2.2.1 Computation ................................................................................................................................................. 6 2.2.1.1 Operator precedence ............................................................................................................................ 6 2.2.1.2 Divide by zero ....................................................................................................................................... 6 2.2.2.2 Off-by-one ............................................................................................................................................. 6 2.2.2 Data reference (pointers) .............................................................................................................................. 7 2.2.2.1 Uninitialized pointer ............................................................................................................................... 7 2.2.2.2 Null pointer ............................................................................................................................................ 7 2.2.3 Redundant code ........................................................................................................................................... 7 2.2.4 Control flow .................................................................................................................................................. 8 2.2.4.1 Infinite loop ............................................................................................................................................ 8 2.3 Software testing ................................................................................................................................................... 8 2.3.1 Verification and validation ............................................................................................................................. 8 2.3.2 Static and dynamic testing ............................................................................................................................ 9 2.3.2.1 Black-box testing ................................................................................................................................... 9 2.3.2.2 White-box testing .................................................................................................................................. 9 2.3.3 Testing levels ............................................................................................................................................. 10 2.3.3.1 Unit testing .......................................................................................................................................... 10 2.3.3.2 Integration testing ................................................................................................................................ 10 2.3.3.3 System testing..................................................................................................................................... 10 2.4 Debugging procedure ........................................................................................................................................ 10 2.5 Debugging techniques ....................................................................................................................................... 11 2.5.1 Print statements ......................................................................................................................................... 11 2.5.2 Logfile debugging ....................................................................................................................................... 11 2.5.3 Assertions ................................................................................................................................................... 11 2.5.4 Dry run debugging ...................................................................................................................................... 11 2.6 Debugger ........................................................................................................................................................... 12 2.6.1 Atmel SAM4E Xplained Pro ........................................................................................................................ 12 2.6.2 Code stepping ............................................................................................................................................ 12 2.6.3 Breakpoints ...............................................................................................................................................