1 / 16

Introduction to Embedded Systems

Introduction to Embedded Systems. Dr. Jerry Shiao, Silicon Valley University. Section 9 Linux Debugging Tools. Trace Code Debugging printf Inserted at strategic points in the executing code to show the value of local or global variables. Real-time flow of application.

shaman
Download Presentation

Introduction to Embedded Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University SILICON VALLEY UNIVERSITY CONFIDENTIAL

  2. Section 9 Linux Debugging Tools Trace Code Debugging printf Inserted at strategic points in the executing code to show the value of local or global variables. Real-time flow of application. Compile time macros to remove printfs in production code. #ifdef UNIT_TESTING #define TRACE(flag, format) if(global_debug & flag) printf format #else #define TRACE(flag, format) #endif Many printfs or macros intermixed in code, can document code or confuse code flow. Add debug printfs means rebuild application. Slow execution time, affect timing. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 2

  3. Section 9 Linux Debugging Tools System Tracing Monitor User Application and Kernel. Interprocess synchronization problems or time-sensitive issues. strace: Tracing single process ptrace() system call intercepts all system calls. Monitoring system or library calls affects performance of process. Option “-c”: Count all calls and signals and create a summary report. Option “-T”: Print time spent in each system call. tux@mercury:~> strace -c find /etc -name xorg.conf /etc/X11/xorg.conf % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 32.38 0.000181 81 1 execve 22.00 0.000123 0 576 getdents64 19.50 0.000109 0 917 31 open 19.14 0.000107 0 888 close 4.11 0.000023 2 10 mprotect 0.00 0.000000 0 1 write [...] Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 3

  4. Section 9 Linux Debugging Tools Performance Analysis Maximize performance on Operating System. Process Profiling Compiler Option “ –gp”: Profiling data written to gmon.out upon exit. Makefile: $(CC) $(LDFLAGS) -pg -o $@ $(OBJS) Execute object file (i.e. $(OBJS)) gmon.out: Cross-platform readable. gprof Utility runs on host Operating System. gprof < options > < executable file > gmon.out Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 33.34 0.02 0.02 7208 0.00 0.00 open 16.67 0.03 0.01 244 0.04 0.12 offtime 16.67 0.04 0.01 8 1.25 1.25 memccpy 16.67 0.05 0.01 7 1.43 1.43 write 0.00 0.06 0.00 47 0.00 0.00 strlen 0.00 0.06 0.00 45 0.00 0.00 strchr 0.00 0.06 0.00 1 0.00 50.00 main 0.00 0.06 0.00 1 0.00 0.00 memcpy 0.00 0.06 0.00 1 0.00 10.11 print 0.00 0.06 0.00 1 0.00 0.00 profil 0.00 0.06 0.00 1 0.00 50.00 report Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 4

  5. Section 9 Linux Debugging Tools GDB – GNU DeBugger Symbolic debugger, Richard Stallman, 1986. GDB package needs: gdb debugger: Runs on the host. gdbserver: Runs on the target. Executes the commands received from the gdb debugger. Debugging capabilities: Initialize environment before running application. Stop program execution (breakpoint). Examine memory when program has stopped. Change memory to alter running environment. GNU General Public License. http://www.gnu.org/manual ftp://ftp.gnu.org/gnu/gdb Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 5

  6. Section 9 Linux Debugging Tools GDB – GNU DeBugger Enhanced symbol table. Debugging information for: Associates address of symbol to the source code. Assocates address of machine code to line of source code. gcc compiler –g option (Symbol Table). gcc –g –o filename filename.c gcc compiler –o option (Optimization). gcc –g –o0 … or gcc –g –o … Debugging information does not get loaded into memory unless gdb loads the executable. gdb –q filename NOTE: Performance affected ONLY running within gdb. .gdbinit file executed by GDB ($HOME, current dir). Contains any GDB commands. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 6

  7. Section 9 Linux Debugging Tools GDB – GNU DeBugger Host gdb –q filename filename is executable object with enhanced symbol table. target remote 192.168.1.100:9004 target remote /dev/ttyUSB0 Target gdbserver localhost:9004 filename filename is executable object stripped of enhanced symbol table. gdbserver /dev/tty filename filename is executable object stripped of enhanced symbol table. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 7

  8. Section 9 Linux Debugging Tools GDB – GNU DeBugger Ethernet Port Switch Serial Port Host System Target System 1) Image test4 with enhanced symbol table. 2) minicom gdb –q test4 target remote 192.168.1.101:9004 or target remote /dev/ttyUSB0 1) Image test4 stripped of enhanced symbol table. 2) gdbserver localhost:9004 test4 or gdbserver /dev/tty test4 192.168.1.100 192.168.1.101 Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 8

  9. Section 9 Linux Debugging Tools GDB – Software Based Debuggers Standard interface to target (serial line or Ethernet). Active program code on the target (i.e. gdbserver) waits for debugging requests and executes the action. Debug only one process, kernel and other processes in target continues. Inter-process debugging difficult. Debugger executes as part of the target program, all software restrictions apply. Only view address space of the current running process. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 9

  10. Section 9 Linux Debugging Tools GDB – Hardware Based Debuggers Uses special hardware to access target, processor and memory (i.e. JTAG interface). No active target software (i.e. no gdbserver on target). Allows debugging of system startup. Hardware breakpoint. Whole target system (i.e. processor) halts. Debug interrupts or inter-process communications. Debugger access memory physically without restrictions. Access any process data. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 10

  11. Section 9 Linux Debugging Tools GDB – JTAG Direct control over hardware for debugging. Rely on special on-chip debug JTAG functionality embedded in the CPU. Sometimes, specially modified GDB debugger. Require special hardware and software. CPU pins used for communication between on-chip debug system and 3rd party tools. Read/write memory. Read/write CPU register. Single step and realtime execution. Hardware breakpoints. Less expensive and complicated than In-Circuit Emulators (ICE). Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 11

  12. Section 9 Linux Debugging Tools GDB – GNU JTAG DeBugger • gdb Target System HostSystem minicom gdb Serial Port OpenOCD JTAG Probe USB Port JTAG Port • gdbserver.Emulation • OpenOCD • JTAG Probe JTAG Cable • Connecting JTAG debugger to the JTAG pins of the CPU. Control CPU behavior. • Require special JTAG hardware and software. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 12

  13. Section 9 Linux Debugging Tools GDB – GNU JTAG DeBugger • Connecting JTAG debugger to the JTAG pins of the CPU. Control CPU behavior. • Require special JTAG hardware and software. • gdbserver Emulation • gdb Serial Port Target System Host System JTAG Probe 192.168.1.100 192.168.1.101 JTAG Port JTAG Cable Ethernet Port Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 13

  14. Section 9 Linux Debugging Tools In-Circuit Debugger (ICD) Direct control over hardware for debugging. Rely on special on-chip debug JTAG functionality embedded in the CPU. ICD software installed on host. Configure ICD environment on the host and target configuration. Require special hardware and software. CPU pins used for communication between on-chip debug system. Read/write memory. Read/write CPU register. Single step and realtime execution. Hardware breakpoints. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 14

  15. Section 9 Linux Debugging Tools In-Circuit Debugger Set-up Debug Environment Select the target CPU. • ICD Software Establish the communcation between the debugger and the target CPU. • Connecting JTAG debugger to the JTAG pins of the CPU. Control CPU behavior. • Require special JTAG hardware and software. Load application for debugging. Host PC USB Cable JTAG Probe Target JTAG Cable Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 15

  16. Section 9 Linux Debugging Tools In-Circuit Debugger (ICD) Trace32 ICD: Host CPU configuring target CPU. Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 16

More Related