Embedded software debugging technology Reading Notes

Source: Internet
Author: User
Tags gdb debugger

Chapter 1 software debugging Overview

Chapter 2 border Scan Testing Technology (JTAG)

Chapter 3 use the gdb debugger

Chapter 4 GDB remote debugging technology

Chapter 5 network application debugging

Chapter 6 multi-process and multi-thread debugging

Chapter 7 static library and dynamic library debugging

Chapter VIII design and debugging of MPEG-4 Video Player

Chapter 9 GPS-based mobile positioning Terminal

References

Border Scan Testing Technology

TIPS:

1. Why is trst an optional signal?

Because the test logic can be reset through TMS

2. Why do I add a pulling resistor to the TMS signal?

IEEE 1149.1 stipulates that, without input signal driving on TMS, the test logic should be the same as that when it is sent to a high-power system on TMS, in this way, the TAP controller will be forced to enter the test-logic-Reset state.

3. Where does tdi tms sample along the rising edge and TDO sample along the falling edge?

In order to avoid competition conditions during testing.

4. The JTAG debugging interface consists of the TAP controller, instruction register, and data register group. The TAP controller controls the test logic to operate the instruction (data) Register.

5. No matter what the original status of the TAP controller is, as long as the TMS maintains a high level of at least five TCK rising edges, the TAP controller enters the test-logic-Reset state. If TMS is high, the Controller will remain in this state.

6. Each Chip Supporting JTAG debugging must contain at least one instruction register. For a specific chip, chip manufacturers generally expand some private instruction registers and data registers on the basis of the ieee1149.1 standard, to facilitate functional testing and diagnosis debugging during the development process.

7. The JTAG Standard allows different commands to share the same binary code. The current status of the TAP controller is used to differentiate the behavior of commands. They are different commands with the same opcode, such as sample and preload.

8. JTAG Public and Private commands)

Ability to test components through self-check

Ability to test board-level interconnection by using the Boundary Scan register

9. Common commands that must be included:

Bypass

Sample

Preload

Extest

Idcode (with a device ID register)

10. Bypass: all bits of binary encoding are 1.

The purpose of its command is to link the bypass register to the TDI and TDO of the component, so that the test data can pass through the scan chain quickly.

11. sample:

Concatenates the Boundary Scan register to the between TDI and TDO.

12. preload: similar to sample, but the direction of the data stream is reversed. S is to load the Signal status on the core logic or external pins of the component into the boundary scan chain, while the preload command is to send the data values in the boundary scan chain to the core logic or external pins.

13. extest: used for board-level interoperability testing.

14. The device ID Register consists of three parts:

Manufacturer ID, 11bits compression code

Part No. 16bits Encoding

Version 4 bits

Its core is the internal Finite State Machine of Test Access Port Controller (Test Access Port Controller). See:

Multi-process and multi-thread debugging

TIPS:

1. in Unix systems, almost all processes are created through fork () system calls.

2. The fork child process inherits most of the content of the parent process, such as the program segment, data segment, stack segment, user ID, group ID, control terminal, and environment variable.

3. After the fork function is called once, it returns two times. In the parent process, the returned value is the ID of the child process, and the returned value is 0 in the child process.

4. After fork is complete, the parent process or child process is scheduled first. This order is not determined.

5. in Linux, fork uses the copy-on-write technology. Fork does not copy the resources of the parent process immediately after the child process is output, instead, the kernel completes the real replication only when the sub-process tries to write data to these spaces. Here I think of a problem (2.4.25 kernel), 64mbytes system memory, excluding the 10 MB occupied by the system, the main process uses 30 mb of memory, when the system is called, it will fail. erro no indicates that the memory application fails. The reason is that although fork adopts the copy-on-write technology, it still checks whether the remaining memory is sufficient for the main process during process creation. Because he thought you might modify it, but you didn't actually do it. Finally, the solution is to configure a Kernel Parameter through the proc interface. When the memory application is judged, when the memory is insufficient, success is also returned.

6. GDB does not provide too much support for multi-process programs. Generally, the Child processes from fork are out of GDB's control.

7.Follow-fork-Mode[Mode]

The mode can be parent or child. It is P, fork, and GDB debugs the parent process. If it is C, the child process is debugged.

Corresponding command:Set follow-fork-Mode[Mode];Show follow-fork-Mode;

8.Detach-on-Fork[Mode] mode: On/Off

Processes that are on (by default) not controlled by GDB (refer to the Follow-fork-mode configuration) will run independently from GDB and are off, processes that are not controlled by GDB will be suspended.

Corresponding command:Set detach-on-Fork[Mode];Show detach-on-Fork

9.Info forks.

10.Fork[Fork-id]. This command sets the process corresponding to fork-ID to the current process.

11.Detach-Fork[Fork-id], disallowing the process corresponding to fork-id from GDB Control

12.Delete fork[Fork-id]: deletes the process corresponding to fork-ID in the info forks list.

13. A thread can be seen as a lightweight process (previously called a Lightweight Process in textbooks). The advantage of a thread is that it consumes less resources, has a high execution efficiency, and has fast context switching, however, it is difficult to include and manage resources.

14. Linux's two sets of thread APIs: linuxthread and pthreads (POSIX). I remember that 2.6 was supported and 2.4 was not used.

15. GDB supports multi-thread debugging: automatically notifies new threads, switches between multiple threads, queries information about the current thread, and applies commands to a group of threads; thread-specific breakpoint

16.Info threadsUsed to obtain the summary of all threads in the current process.

17.Thread[Threadno] switch the current thread to the thread corresponding to threadno.

18.Thread apply[Threadno | all] command, which will be applied to the thread represented by threadno.

19.Break linespec threadThreadno

Break linespec threadThreadnoIfCond

These two commands can be used to set thread-specific breakpoints.

20.Set scheduler-lockingMode

This command can choose whether to lock the kernel thread scheduling. The mode can be off, on, or step.

Off does not lock the kernel thread scheduling, so the thread can be scheduled at any time

On completely locks kernel thread scheduling, only the current thread can run

The step command does not cause other threads to run. Other commands such as C can run other threads.

Debugging of static and dynamic libraries

1. the archive tool AR of the target file. Compared with the archive tool tar of the file, ar creates an index for the symbol table in the archive target file, you can also append, modify, or delete an archive file.

2. the archive command we usually use is:Ar RCS libxxx. A obj1.o... Objx. o

R: insert the member (objx. O) to archive. If archive has a member with the same name, replace the existing member. By default, members inserted into archive are added to the end of archive.

C: Create an archive

S: Write the index of the target file to archive.

Note: The ar s command is equivalent to the ranlib Command Used for archiving files.

V: this parameter displays details.

T: displays members in archive.

3. Is the file generated by Ar compressed? Or is it not compressed like tar Without J and Z parameters?

I don't think it will be compressed (It was found that the data is not compressed.)

4. What are the output results of archiving the same target file using the AR tool on the cross compiler and the AR tool on the host?

I used AR and MIPS-Linux-AR for comparison, and found that the generated file has different timestamps, and the rest is the same.

For more information about AR file headers, see http://en.wikipedia.org/wiki/Ar_ (UNIX)

Global Header

The global header is a single field containing the magic ASCII string "! "Followed by a single LF Control Character

File Header

The common format is as follows.

Field offset from

Field offset

Field name

Field Format

0

15

File Name

ASCII

16

27

File Modification Timestamp

Decimal

28

33

Owner ID

Decimal

34

39

Group ID

Decimal

40

47

File Mode

Octal

48

57

File Size in bytes

Decimal

58

59

File magic

0x60 0x0a

Due to the limitations of File Name Length and format, both the GNU and BSD variants devised different methods of storing long filenames.

5. nm is a very useful tool for obtaining the symbolic information in the OBJ file in archive.

6. For GDB debugging of the static library, as long as the target file of the generated library file contains debugging information, the file is generated with the-G parameter.

7. When an executable file is generated for a static link, the connector copies the static Link Library to the final executable code. So will the functions not used in the library be copied?

The experiment proves that it will be copied even if it is not used (GCC environment)

8. Advantages and Disadvantages of dynamic libraries

Advantages

A> memory saving: if multiple applications use the same dynamic link library, only one copy of the dynamic shared library exists in the memory.

B> hard disks are saved. If multiple applications use the same dynamic library, only one copy is available on the storage medium.

C> it facilitates software repair and upgrade. Because the dynamic library and application are independent files, separate maintenance can be implemented to reduce the compilation and software upgrade time.

D> improve performance. When an application using the dynamic library is already running, it will not load the dynamic library when another application is started, which can save some time.

Disadvantages

E> complexity. First, the API interface of the dynamic library cannot be changed easily, and secondly, the function of the dynamic library must be reentrant. The complex dependency of the dynamic library is unfavorable for software migration.

F> compatibility. Because dynamic libraries and applications are published separately, the dependency of their versions must be ensured.

G> debugging is difficult. It is not easy to debug dynamic libraries in an embedded environment (in fact, I don't think it is much complicated)

9. the dynamic library command (soname = Share Object Name), for example, a libc can be found in the system. so.6 files, actually pointing to the soft connection of the libc-2.3.2.so, who is to establish this soft connection? It is ldconfig. Its job 1 is to establish a soft connection 2 is to update the cache/etc/lD. So. cache of the shared library. How does it work? First, the libc-2.3.2.so contains the soname information, through the commandReadelf-D libc-2.3.2.soYou can see:

0x0000000e (soname) Library soname: [libc. so.6]

Search paths of all dynamic libraries defined in the/etc/lD. So. conf file. ldconfig can search these directories to find all dynamic libraries, generate symbolic links, and update the cache.

10. When connecting to the executable program and specifying the connected library, you only need to write-LC as libc. so.6.

11. Unless the GCC-static option is explicitly used when compiling an application, GCC uses a dynamic shared library to link to the application. The problem is: if the shared library and dynamic library exist in the directory at the same time, is that the shared library preferred?

Experiments show that the database is preferentially shared.,It is unclear how to specify the static library..

-StaticThe options can indeed generate images that use static libraries, but it is worth noting that all libraries use static libraries, including libc, so the generated images will be relatively large.

It is easy to understand that the dynamic library also loads the complete library image to the virtual memory of the application, not just the parts used by those applications, after all, the dynamic library may be used by many people and cannot be processed one by one.

12. The shared library does not require ar to be packaged. You can use GCC directly. Below are the GCC parameters to be used

-SharedTells GCC to generate a shared target file. This option must be used together with options such as-FPIC. (Actually, I do not remember to use this-FPIC parameter. It seems that there is no problem)

-FPICGenerating position-independent code (PIC)

-Wl,-soname, xxxGCC will pass-soname and XXX as a command line option to the linker LD to generate a library like 0x0000000e (soname) soname: [libc. so.6] information, such as the parameter-wl,-soname, libc. so.6

-Fomit-frame-pointerThe compiled program does not use commands to store and recover the function's stack frame register, which can improve the program's execution efficiency, the side effect is that the debugger on some platforms will not work normally (for example, BT may not work normally, as I personally understand)

13. Command for generating dynamic library: gcc-shared-wl, soname, XXX-O libname filelist liblist

14. A major problem during GDB debugging of a dynamic library is that the dynamic library will not be automatically loaded like an application, another major problem for remote debugging is to differentiate the dynamic libraries on the local and target databases.

15. Remote Dynamic library, General debugging process:

A> Start gdbserver. After the client is connected, set the breakpoint where the dynamic library is loaded (usually on main)

B> find the address for loading the dynamic library on the virtual memory of the application, for example:

CAT/proc/758/maps

4001d000-4001e000 R-XP 00000000 1f: 03 2921/usr/local/lib/libfoobar. so.0.0

Here, we only need the 0x4001d000 address.

C> Find the offset address of the text segment in the dynamic library file, for example:

Arm-Linux-objdump-H libfoobar. so.0.0

Idx name size vma lma file off algn

9. Text 000001bc 0000073c 0000073c0000073c2 ** 2

Here, we need the address 0000073c.

D> load the gdb debugging symbol on the superimposed address, for example:

(GDB)Add-symbol-file libfoobar. so.0.0 0x4001d000 + 0x0000073c

16.Add-symbol-FileFile ADDR [-S -S …]

Load symbols from File

17.Set auto-solib-addMode

Mode = on, all symbols in the dynamic library will be automatically loaded, the time of automatic loading:

A> when the program to be debugged starts to run

B> when GDB is connected to the program being debugged (attach)

C> when the dynamic linker of the operating system notifies GDB that a new dynamic library is loaded

The default value is off.

18.Show auto-solib-add

19.SharedlibraryRegEx

Load symbols from the dynamic library specified by the regular expression RegEx

20.Nosharedlibrary

All symbolic information loaded from the dynamic library will be discarded

21.Info sharedlibrary

Print the names of all currently loaded dynamic libraries

22.Set solib-absolute-PrefixPath

Show solib-absolute-Prefix

The path is used as the prefix of the path in the dynamic shared library. This is for remote debugging, for example:

/Opt/ARM-Linux/Usr/lib

23.Set solib-search-PathPath

PATH is a list of directories separated by colons. GDB searches for dynamic shared libraries in these directories. This search operation will be performed inSolib-absolute-PrefixAfter searching

Later I will introduce the AVI part, mainly riff and some related specifications. Later I will introduce a c Protocol to implement libavi, which will cover a lot of data structure definition and code implementation, only five pages are involved in debugging. This part is currently unavailable, skip, and skip.

References

1. Andrew S. Tanenbaum, Albert S. Woodhull. Operating System: design and implementation. Version 2. Yu jinyuan, et Yi. Beijing: Electronics Industry Press, 2003

2. Bill blunden. Virtual Machine Design and Implementation ------ C/C ++. Yang Tao, et al. Beijing: Machinery Industry Press, 2003

3. Mao decao, Hu Ximing. Liux kernel source code scenario analysis. . Zhejiang: Zhejiang University Press, 2001.

4. Zhao Mindong. The Design and Implementation of the debugger in the embedded software integrated development environment. Xi'an: Master's degree thesis from Northwestern University of Technology, 2004

5. Norman Matloff, P. J. salzmann. The art of debugging with GDB and DDD. No starch Press, 2006

6. Richard Stallman, and so on. Debugging with GDB. Free Software base, 2006

7. Jonathan B. Rosenberg. How debugger work: algorithms, data structures, and architecture. John Wiley & Sons. Inc, 1996.

8. IA-32 intel architecture software developer's Manual Volume 3B: System Programming Guide Part 2. Intel Co., 2006.

9. Mao decao, Hu Ximing. Embedded Systems: open source code and strongarm/XScale processors. Zhejiang: Zhejiang University Press, 2003.

10. Huang Hongyan. Analysis and design of embedded system debugging technology. Zhejiang: Master's degree thesis from Zhejiang University, 2006.

11. Test Technology Standards Committee of the IEEE Computer Society. IEEE Standard Test Access Port and boundary-Scan Architecture. 2001

12. John F. wakerly. Digital Design-principles and practices. License plate. The third edition. Beijing: Higher Education Press, 2003

13. twentyone. Debugging principle of arm JTAG. Http: // twentyone, blogchina.com/index.html.

14. ARM7TDMI Technical Reference Manual. Arm limited. 2001

15. W. Richard Steven S. Advanced Programming in UNIX environment. You Jin Yuan, et al. Beijing: Machinery Industry Press, 2005

16. Jeffrey E. F. Friedl. proficient in regular expressions. English version. Version 2. Nanjing: Southeast University Press, 2005

17. Yan Weimin and Wu Weimin. Data structure. C language. Beijing: Tsinghua University Press, 2002

18. Raytheon, Wang Qian. Modern microprocessor and bus technology. Beijing: National Defense Industry Press, 2006

19. anany Levitin. algorithm design and analysis basics. License plate. Beijing: Tsinghua University Press, 2003.

20. Samuel P. Harbison, and so on. C Language Reference Manual. English version. Fifth Edition. Beijing: People's post and telecommunications Press, 2003

21. Kurt wall, etc. GNU/Linux programming guide. Translated by Zhang Hui. Beijing: Tsinghua University Press, 2005.

22. Geert uytterhoeven. The frame buffer device. 2001

23. Alex Buell. framebuffer howto. 2000

24. Linux 2.2 framebuffer device Programming Tutorial. www.linuxsir.org

25. [us] Gonzalez, and so on. Digital image processing. Version 2. Qi qiuqi, et al. Beijing: Electronics Industry Press, 2005

26. Thomas G. Lane. Using the ijg jpge library. 1994-1998

27. Sitang-PXA255 Evaluation Platform user Guild. Intel Inc, 2003

28. Sitang-PXA255 Evaluation Platform Linux User Guild. Intel Inc, 2003

29. John Shapley gray. UNIX process student. Version 2. Translated by Zhang Yu. Beijing: Electronics Industry Press, 2001

30. Zhao Yu. Linux developing history. www.plinux.org

31. Lin Rui. High-quality C ++/C Programming Guide. Shanghai: Shanghai Bell, 2001

32. Tang Kai. OSS --- Introduction to cross-platform audio interfaces. Http://www-128ibm.com/developerworks/cn/linux/l-ossaip/

33. Xiao wenpeng. Linux audio programming guide. Http://www-128ibm.com/developerworks/cn/linux/l-audio/

34. Open Sound System Programmer's Guild. www.opensound.com

35. W. Richard Steven S. TCP/IP details. Fan Jianhua. Beijing: Machinery Industry Press, 2000

36. W. Richard Steven S. UNIX network programming. Version 2, Shi Zhenchuan, and other translations. Beijing: Tsinghua University Press, 2001

37. Marshall Kirk mckusick, etc. 4.4bsd operating system design and implementation. English audio/video version. Beijing: People's post and telecommunications Press, 2001

38. Michael R. Sweet. Serial programming guide for POSIX operating system. 5th edition. http://digilander.libero.it/robang/serial.htm#CONTENTS. 1994-1999

39. cdma at commands interface specification v1.78. 2003

40. http://www.unicode.org

41. W. Richard Steven S. UNIX network programming. Version 2. Yang jizhang, translated. Beijing: Beijing kehai electronics Publishing House, 2000

42. Bil Lewis, Daniel J. Berg. pthreads primers: A Guide to multithreaded programming. Prentice Hall PTR, 1995

43. David R. butenhof. POSIX multi-threaded program design. Yu Lei, Zeng gang, translated. Beijing: China Power Press, 2003

44. portable applications Standards Committee of the IEEE Computer Society and the Open Group. Standard for information technology ---- Portable Operating System Interface (POSIX) system intefaces. 2004

45. Embedded Linux debugging: Use gdbserver to debug shared libraries. Http://blog.csdn.net/absurd/archive/2006/06/18/804810.aspx 2006

46. Avi riff file reference. http://msdn2.microsoft.com/en-us/library/ms779636.aspx

47. matrox Electronic System Ltd .. opendml AVI file format extensions (version 1.02). 1997

48. Iain e. g. Richard. H.264 and MPEG-4 video compression ---- video coding for next-genertaion multimedia. John Wiley & Sons Inc., 264

49. http://www.xvid.org

50. SDL library documentation. http://www.libsdl.org

51 http://www.nmea.org

52. Garmin Inc.. GPS 15 technical specifications. 2002

53. Beijing feiman Software Technology Co., Ltd. MiniGUI programming guide for MiniGUI ver 1.3.x. 2003

54. Beijing feiman Software Technology Co., Ltd. MiniGUI user manual for MiniGUI ver 1.3.x. 2003

55. Beijing feiman Software Technology Co., Ltd. MiniGUI api reference documentation for MiniGUI ver 1.3.x. 2003

56. Tan haoqiang. C program design. Version 2. Beijing: Tsinghua University Press, 2005

57. http://www.tcpdump.org

58. Li Tiao. GPS principle and application. Beijing: Science Press, 2004.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.