当前位置:网站首页>Three techniques for reducing debugging time of embedded software
Three techniques for reducing debugging time of embedded software
2022-06-30 21:16:00 【Software test network】
Engineers like to solve problems . Of course , This is what we do . But it's not what people want , One of the biggest problems of embedded software engineers is that we have created many problems ourselves , Then spend a lot of time to solve these problems , Finally make yourself a hero ( On debugging !). There are many embedded software engineers in the company 20 - 40% Time spent debugging . thankfully , There are many potential changes that can be made from a team perspective , To reduce the time they spend debugging , And compress the time percentage to single digits . In this paper , We'll look at some techniques to reduce debugging time .
skill 1- Test-driven development (TDD)
Test driven development is a kind of software that allows developers to build their product incrementally , And rely on tests to dictate the techniques they use to write code . for example , The developer first writes a test case , If the test fails , Then write new code for the purpose of passing the test . Then repeat the process .
Traditionally speaking , Embedded software developers will write the entire software code module before testing . You might write thousands of lines of code in a few weeks . When it's time to test the code , If it doesn't work , What's the problem ? Only God knows ! Developers must painstakingly review the code and find the problem and fix it . The time required to perform this operation can be quite long .
On the other hand , For the use of TDD For developers , If an error occurs and the code is injected with bug, The test case will immediately tell the developer ! Because it is a step-by-step code writing process , So it's more likely to know exactly what part of the program has changed , And can fix the problem immediately .TDD It seems that more time is needed to verify , But by creating a series of test cases , You can run these use cases in regression tests , To make sure everything works as expected .TDD The function achieves the goal of killing two birds with one stone : Reduce debugging and automated testing time .
skill 2- Development without machine dependencies as much as possible
When a project starts , The first reaction of almost every embedded software developer is to get a development board and start writing code . But it's not what people want , In many cases, embedded software code is not a product differentiator with competitors , The difference is in the application code . Although many application code ultimately needs to interact with hardware , But many modules can be developed without relying on the host machine environment .
Implement code development without machine dependencies , There are many opportunities for developers to reduce the time spent on each debugging cycle . for example , You usually write and test code for the target microcontroller , Developers must do the following :
1. Cross compile code
2. Start debugging session
3. adopt SWD Program the device
4. Run the code on the target machine
5. Verify that the code is valid by running on the target machine ( The same must have all Low-Level Code )
If the code is developed on the host , The developer must compile the code on the host , Then use the unit test tool 、 Emulators or custom programs to run the code being developed . If problems are found , It will be repaired more quickly 、 Recompile and restart the test .
On the embedded board , Programming only the target program will increase each cycle by tens of seconds , Not to mention stepping through the code .
Development without machine dependencies / Debugging may produce specific errors . I have written about... Since now 75% From the example of related code , It will be faster 、 More efficient effects . I can quickly locate problems in the code , Determine the cause and fix it , Then continue debugging , Instead of just tracking problems on the embedded board . Of course , Some problems will appear in the board environment that will not appear on the host .
skill 3- Master the debugging strategy
The least efficient debugging method we know is to step through the code . But don't get me wrong , There are specific program running time and location , It often wastes a lot of time . Unfortunately , Embedded software developers usually use breakpoints and step-by-step debugging by default . For better debugging , Developers also need to master other debugging strategies available on modern microcontrollers .
There are at least eight different debugging techniques available to developers . The order of these technologies from the simplest to the most complex is as follows :
- Watch / Expressions: Provide checks for developers CPU And peripheral registers . They are often used to monitor variables 、 Perform calculations or stop when changes are made CPU.
- The breakpoint : Provides developers with the ability to stop on a specific line of code CPU Ability to execute , The advanced breakpoint function can be used to set conditional statements .
- Print : Provide developers with the ability to print character data to mapped serial interfaces , There is a certain probability that it will affect real-time performance .
- Assertion : A conditional statement used to verify a specific point assumption in a program . Assertion failure usually stops CPU And provide the file and line location of the failed assertion .
- Statistical analysis : Periodically sample various registers in the running application . It usually doesn't affect real-time performance . for example , You may want to program counters (PC) Sample to see which code modules are executing .
- Data analysis : Periodically sample various memory locations that contain variable data . When used with real-time visualization tools to monitor system status 、 The variable of interest changes isochronously , Data analysis can be very useful .
- Task and data tracking : Enables developers to track events in real-time operating system applications . therefore , Developers can gain insight into application performance 、 Task delay 、 Running time and so on .
- Command tracking : Enables developers to record every instruction executed on the processor . This can be used to understand code coverage during testing 、 Debugging compiler problems, etc .
Master all these technologies and know when to use them , It can greatly reduce the time for debugging when an exception occurs and enters the system .
Conclusion
We may spend a lot of time debugging embedded software code during the development phase . Sometimes debugging time is unavoidable ; But in many cases , Developers may spend more time than expected . We have explored several areas that you can further investigate , To reduce the time you and your team spend debugging . If you spend more than the overall software cycle on debugging 20% Time , So please take an hour this week to determine which of the above areas you can immediately adjust and optimize , To control the time spent on debugging .
边栏推荐
- The 16th Heilongjiang Provincial Collegiate Programming Contest
- What does grade evaluation mean? What is included in the workflow?
- 文本识别-SVTR论文解读
- Electronic scheme development - Intelligent rope skipping scheme
- Double solid histogram / double y-axis
- 时空数据挖掘:综述
- 两个skyline
- 防范未授权访问攻击的十项安全措施
- vncserver: Failed command ‘/etc/X11/Xvnc-session‘: 256!
- Flutter 嵌套地狱?不存在的,ConstraintLayout 来解救!
猜你喜欢
测试媒资缓存问题

CentOS - enable / disable Oracle

Binary search tree (1) - concept and C language implementation

qiao-npms:搜索npm包

RP原型资源分享-购物类App

Vite2兼容低版本chrome(如搜狗80),通过polyfills处理部分需求高版本的语法

《ClickHouse原理解析与应用实践》读书笔记(1)

Markdown notes concise tutorial

网络营销之四大误解

Apply for vector bus protocol color picture wallpaper hanging picture, very good!
随机推荐
Metauniverse may become a new direction of Internet development
Four Misunderstandings of Internet Marketing
的撒啊苏丹看老司机
一文读懂什么是MySQL索引下推(ICP)
Coefficient of variation method matlab code [easy to understand]
《ClickHouse原理解析与应用实践》读书笔记(1)
修改已经上线的小程序名称
uniapp-生命周期/路由跳转
ncat详细介绍(转载)
我想知道股票开户要认识谁?另外,手机开户安全么?
学习总结
1.微信小程序页面跳转方法总结;2. navigateTo堆栈到十层不跳转问题
A small step in code change and a big leap in thinking
Understanding polymorphism
CentOS - enable / disable Oracle
go搭建服务器基础
防范未授权访问攻击的十项安全措施
大学生研究生毕业找工作,该选择哪个方向?
uniapp-路由uni-simple-router
ca i啊几次哦啊句iu家哦