Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University."— Presentation transcript:

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

2 SILICON VALLEY UNIVERSITY CONFIDENTIAL 2 Spring 2014 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.

3 SILICON VALLEY UNIVERSITY CONFIDENTIAL 3 Spring 2014 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 [...]

4 SILICON VALLEY UNIVERSITY CONFIDENTIAL 4 Spring 2014 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 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

5 SILICON VALLEY UNIVERSITY CONFIDENTIAL 5 Spring 2014 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 http://www.gnu.org/manual  ftp://ftp.gnu.org/gnu/gdb

6 SILICON VALLEY UNIVERSITY CONFIDENTIAL 6 Spring 2014 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.

7 SILICON VALLEY UNIVERSITY CONFIDENTIAL 7 Spring 2014 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.

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

9 SILICON VALLEY UNIVERSITY CONFIDENTIAL 9 Spring 2014 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.

10 SILICON VALLEY UNIVERSITY CONFIDENTIAL 10 Spring 2014 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.

11 SILICON VALLEY UNIVERSITY CONFIDENTIAL 11 Spring 2014 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 3 rd 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).

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

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

14 SILICON VALLEY UNIVERSITY CONFIDENTIAL 14 Spring 2014 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.

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

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


Download ppt "Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University."

Similar presentations


Ads by Google