CN109902001B - Method for detecting uninitialized variable and terminal equipment - Google Patents

Method for detecting uninitialized variable and terminal equipment Download PDF

Info

Publication number
CN109902001B
CN109902001B CN201910111480.1A CN201910111480A CN109902001B CN 109902001 B CN109902001 B CN 109902001B CN 201910111480 A CN201910111480 A CN 201910111480A CN 109902001 B CN109902001 B CN 109902001B
Authority
CN
China
Prior art keywords
memory
global variable
total number
variable
specified data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910111480.1A
Other languages
Chinese (zh)
Other versions
CN109902001A (en
Inventor
张蓬勃
胡欣
洪开慧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kehua Data Co Ltd
Original Assignee
Xiamen Kehua Hengsheng Co Ltd
Zhangzhou Kehua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Kehua Hengsheng Co Ltd, Zhangzhou Kehua Technology Co Ltd filed Critical Xiamen Kehua Hengsheng Co Ltd
Priority to CN201910111480.1A priority Critical patent/CN109902001B/en
Publication of CN109902001A publication Critical patent/CN109902001A/en
Application granted granted Critical
Publication of CN109902001B publication Critical patent/CN109902001B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

本发明适用于嵌入式软件检测技术领域,提供了一种对未初始化变量的检测方法及终端设备,该方法包括:复位被测系统,使指针指向所述被测系统主函数;在所述被测系统中存放全局变量的内存段内填充指定数据;使指针运行到变量初始化完毕的函数位置,读取所述内存段数据,获取所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数;当所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数相同时,则确定所述全局变量为未初始化的全局变量。本方法可以通过脚本自动化检测的方法,实现快速检测嵌入式软件中未初始化的全局变量。

Figure 201910111480

The invention is applicable to the technical field of embedded software detection, and provides a detection method for uninitialized variables and a terminal device. The method includes: resetting the system under test, so that the pointer points to the main function of the system under test; Fill the memory segment storing the global variable in the measurement system with the specified data; make the pointer run to the function position where the variable initialization is completed, read the memory segment data, and obtain the total number of memory cells and the specified data corresponding to the name of the global variable When the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data, it is determined that the global variable is an uninitialized global variable. The method can quickly detect uninitialized global variables in embedded software by means of automatic script detection.

Figure 201910111480

Description

Method for detecting uninitialized variable and terminal equipment
Technical Field
The invention belongs to the technical field of embedded unit testing, and particularly relates to a method for detecting uninitialized variables and terminal equipment.
Background
Before the embedded software system runs, the referenced global variable needs to be declared and initialized. If the global variable is not initialized before the variable is referenced, its initial value is not fixed. When the global variable is referred, the operation result is unpredictable, and the operation phenomena are different every time, so that economic loss is possibly brought, difficulty is brought to problem positioning for software developers, software bugs cannot be searched completely, and the time investment of the software developers for debugging programs is increased.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method for detecting an uninitialized variable and a terminal device, which can implement rapid detection of an uninitialized global variable in embedded software by using a script automatic detection method.
A first aspect of an embodiment of the present invention provides a method for detecting an uninitialized variable, including:
resetting the tested system to enable a pointer to point to a main function of the tested system;
filling specified data in a memory segment for storing global variables in the tested system;
enabling a pointer to run to a function position where variable initialization is finished, reading the memory segment data, and obtaining the total number of memory units corresponding to the name of the global variable and the total number of units of the specified data;
and when the total number of the memory units corresponding to the names of the global variables is the same as the total number of the units of the designated data, determining that the global variables are uninitialized global variables.
In an embodiment, before the resetting the system under test and pointing a pointer to the main function of the system under test, the method further includes:
the integrated development environment IDE of the embedded processor is provided with a debugging server script DSS toolkit;
invoking execution of the DSS toolkit;
the resetting the system under test to make the pointer point to the main function of the system under test includes:
and calling a script debugging reset instruction, resetting the tested system and enabling the pointer to point to the main function of the tested system.
In an embodiment, filling specified data in a memory segment storing a global variable in the system under test includes:
and calling a script debugging memory filling instruction, and filling specified data in all memory units in the RAM of the ebss section in the system to be tested.
In an embodiment, after the invoking script debugs the memory filling instruction, in the system under test, after all the memory units in the RAM of the ebss section are filled with the specified data, the method further includes:
calling a script debugging breakpoint instruction, and setting a breakpoint in a statement behind an initialization function in the tested software system;
and calling a script debugging full-speed running instruction, and running the tested software system to a breakpoint statement at full speed.
In an embodiment, the reading the memory segment, and obtaining the total number of memory cells corresponding to the name of the global variable and the total number of cells of the specified data includes:
calling a script debugging memory reading instruction, and reading all specified data of the memory unit of the ebss section RAM;
calling a script debugging variable reading instruction, and reading the name of the global variable corresponding to the ebss section address;
and when the name of the global variable is acquired, acquiring the total number of memory units corresponding to the name of the global variable accumulated by a first counter, and acquiring the total number of units of the specified data accumulated by a second counter.
In an embodiment, when the total number of memory cells corresponding to the name of the global variable is the same as the total number of cells of the designated data, determining that the global variable is an uninitialized global variable includes:
detecting whether the name of the next global variable is read or not;
when the name of the next global variable is read, detecting whether the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data or not;
and when the total number of the memory units corresponding to the names of the global variables is the same as the total number of the units of the specified data, determining that the global variables corresponding to the currently detected memory area are uninitialized global variables.
In an embodiment, the method further comprises:
when the global variable corresponding to the currently detected memory area is determined to be an uninitialized global variable, sending the uninitialized global variable to a control unit corresponding to a control window, and assigning the first counter and the second counter to be 0;
when the name of the next global variable is not read, or when the total number of memory units corresponding to the name of the global variable is different from the total number of units of the specified data, or after the first counter and the second counter are assigned to be 0, whether the address of the ebss section is the last unit is detected;
and when the address of the ebss section is the last unit, calling a script debugging reset instruction to reset the tested system.
A second aspect of an embodiment of the present invention provides an apparatus for detecting an uninitialized variable, including:
the reset module is used for resetting the tested system to enable the pointer to point to the main function of the tested system;
the filling module is used for filling specified data in a memory segment for storing the global variable in the tested system;
the reading module is used for enabling the pointer to run to a function position where the variable initialization is finished, reading the memory segment data, and acquiring the total number of memory units corresponding to the name of the global variable and the total number of units of the specified data;
and the determining module is used for determining the global variable as the uninitialized global variable when the total number of the memory units corresponding to the names of the global variable is the same as the total number of the units of the specified data.
A third aspect of the embodiments of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method for detecting uninitialized variables provided in the above embodiments when executing the computer program.
A fourth aspect of embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of the method for detecting uninitialized variables provided in the above-described embodiments.
Compared with the prior art, the embodiment of the invention has the following beneficial effects: the embodiment of the invention leads the pointer to point to the main function of the system to be tested by resetting the system to be tested; filling specified data in a memory segment for storing global variables in the tested system; enabling a pointer to run to a function position where the variable initialization is finished, reading the data of the memory segment, and acquiring the total number of memory units corresponding to the name of the global variable and the total number of units of the specified data; when the total number of the memory units corresponding to the names of the global variables is the same as the total number of the units of the designated data, the global variables are determined to be uninitialized global variables, and the uninitialized global variables in the embedded software can be quickly detected. And the whole detection process does not need to additionally occupy chip resources, and the detection result is accurate and fast.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic flow chart of an implementation of a method for detecting an uninitialized variable according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of another implementation of a method for detecting uninitialized variables according to an embodiment of the present invention;
FIG. 3 is an exemplary diagram of a detection apparatus for uninitialized variables provided by an embodiment of the present invention;
fig. 4 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
An embodiment of the present invention provides a method for detecting an uninitialized variable, as shown in fig. 1, where the method includes the following steps:
step 101, resetting the system to be tested, and enabling a pointer to point to a main function of the system to be tested.
Optionally, before resetting the system under test, a Debug Server Script (DSS) toolkit is introduced, a script environment object is created, the Debug Server is acquired, and a Debug Server session is started. And automatically calling a script debugging reset instruction, and resetting the tested system to enable the pointer to point to the main function of the tested system.
The execution subject of the method may be a computer terminal, and may be a computer-readable storage medium, and the method is not limited to the execution subject, and is described above only as an example.
Optionally, the Test carrier required by the method is an Integrated Development Environment (IDE) of an embedded chip minimum system board and an embedded processor, and the two are connected by using a Joint Test Action Group (JTAG) and perform online simulation. The software development environment has a DSS functional interface, and the script language generally supports high-level languages such as Java or JavaScript, Perl, Python, TCL and the like. In a software development environment, the DSS toolkit can replace manual operation by using script instructions, such as functions of software resetting, breakpoint setting, full-speed operation, single-step operation, memory filling, memory reading, reading of variables corresponding to memory addresses and the like. Therefore, the automatic test can be realized in the minimal system board simulation environment by compiling the script program in a certain logic sequence. For example, in this step, a script debugging reset instruction is automatically called to reset the system under test, so that the pointer points to the main function of the system under test.
And 102, filling specified data in a memory segment storing the global variable in the tested system.
And automatically calling a script debugging memory filling instruction, and filling specified data in all memory units in a Random Access Memory (RAM) of the ebss section in the tested system.
Alternatively, the specified data may be 0x55AA or the like. Ebss segments in embedded software are used for storing global variables.
Optionally, the method further includes automatically calling a script debugging breakpoint instruction after the step, and setting a breakpoint in a statement after an initialization function in the tested software system;
and automatically calling a script to debug the full-speed running instruction, and running the tested software system to the breakpoint statement at full speed.
And 103, operating the pointer to a function position where the variable initialization is completed, reading the memory segment data, and acquiring the total number of memory units corresponding to the name of the global variable and the total number of units of the specified data.
Optionally, the present step includes: automatically calling a script to debug a memory reading instruction, and reading all specified data corresponding to all memory units of the ebss section RAM; automatically calling a script debugging variable reading instruction, and reading the name of the global variable corresponding to the ebss section address;
when the name of the global variable is obtained, obtaining the total number of memory cells corresponding to the name of the global variable accumulated by a first counter, and obtaining the total number of cells of the specified data accumulated by a second counter, optionally, Var _ Cnt may be used to represent the total number of memory cells corresponding to the name of the global variable, and Fill _ Cnt may be used to represent the total number of cells of the specified data;
and step 104, when the total number of the memory units corresponding to the names of the global variables is the same as the total number of the units of the designated data, determining that the global variables are uninitialized global variables.
Optionally, when Fill _ Cnt is equal to Var _ Cnt, it is determined that the global variable corresponding to the currently detected memory area is an uninitialized global variable, then the uninitialized global variable is sent to the control unit corresponding to the control window, and the first counter and the second counter are assigned as preset values, where the preset value may be 0. Thus, all uninitialized global variables can be obtained in the control window, and the global variables can be accurately positioned.
According to the method for detecting the uninitialized variables, all memory units of the ebss section RAM in the detected software system are filled with the specified data (0x55AA), the total number of the memory units corresponding to the names of the global variables and the total number of the filled specified data units are obtained, and when the total numbers of the memory units and the filled specified data units are the same, the currently detected global variables can be determined to be the uninitialized global variables. The whole detection process has the characteristics of simple operation, no need of additional temporary chip resources, accurate detection result, high speed and the like.
An embodiment of the present invention provides another method for detecting an uninitialized variable, as shown in fig. 2, the method includes:
step 201, an integrated development environment IDE of an embedded processor is provided with a debug server script DSS toolkit.
Optionally, the test carrier required by the method is an embedded chip minimum system board and an integrated development environment IDE of the embedded processor, and the embedded chip minimum system board and the embedded processor are connected by using a simulator JTAG and are subjected to online simulation. The integrated development environment IDE of the embedded processor has a DSS functional interface, and the script language generally supports high-level languages such as Java or JavaScript, Perl, Python, TCL and the like. In a software development environment, the DSS toolkit can replace manual operation by using script instructions, such as functions of software resetting, breakpoint setting, full-speed operation, single-step operation, memory filling, memory reading, reading of variables corresponding to memory addresses and the like. Therefore, the automatic test can be realized in the minimal system board simulation environment by compiling the script program in a certain logic sequence. For example, in this step, a script debugging reset instruction is automatically called to reset the system under test, so that the pointer points to the main function of the system under test.
Optionally, a DSS toolkit is imported, and a script environment object is created.
Step 202, invoking execution of the DSS toolkit.
Optionally, a script of the debugging server is obtained, and a dialogue of the debugging server is started.
Step 203, calling a script debugging reset instruction, and resetting the tested system to enable the pointer to point to the main function of the tested system.
When the DSS toolkit is operated in the step, a script debugging reset instruction can be automatically called.
And step 204, calling a script debugging memory filling instruction, and filling specified data in all memory units in the RAM of the ebss section in the system to be tested.
Optionally, the script is automatically called to debug the memory filling instruction, and all memory units of the RAM of the ebss section in the system to be tested are filled with the specified data. Alternatively, the specified data may be 0x55 AA. For embedded software, the ebss segment is used for storing global variables.
Step 205, a script debugging breakpoint instruction is called, and a breakpoint is set in a statement behind an initialization function in the tested software system.
The breakpoint is set to terminate the test program.
And step 206, calling a script debugging full-speed running instruction, and running the tested software system to a breakpoint statement at full speed.
And step 207, calling a script debugging memory reading instruction, and reading all specified data of the memory unit of the ebss section RAM.
This step is to read all the specified data filled in the ebss section RAM.
And 208, calling a script debugging variable reading instruction, and reading the name of the global variable corresponding to the ebss section address.
Step 209, when the name of the global variable is obtained, obtaining the total number of the memory cells corresponding to the name of the global variable accumulated by the first counter, and obtaining the total number of the cells of the specified data accumulated by the second counter.
It should be noted that the first counter and the second counter are only named for distinguishing the counters, and the counters are not functionally ranked.
Step 210, detecting whether the name of the next global variable is read.
In step 211, when the name of the next global variable is read, it is detected whether the total number of the memory cells corresponding to the name of the global variable is the same as the total number of the cells of the specified data.
Optionally, it is determined whether Fill _ Cnt is equal to Var _ Cnt.
Step 212, when the total number of memory cells corresponding to the names of the global variables is the same as the total number of cells of the specified data, determining that the global variables corresponding to the currently detected memory area are uninitialized global variables.
And step 213, sending the uninitialized global variable to a control unit corresponding to the control window.
Optionally, in this step, the determined uninitialized global variables are displayed in a control window so as to locate each global variable, and then the two counters are cleared.
Step 214, assigning the first counter and the second counter to 0.
It should be noted that, after the step 211 is executed, when the total number of the memory cells corresponding to the name of the global variable is different from the total number of the cells of the designated data, the step 214 is executed.
Step 215, read the next address of the ebss segment.
Optionally, after step 210 is executed, when the name of the next global variable is not read, step 215 is executed, that is, the next address of the ebss segment is read, and step 216 is further executed.
Step 216, detecting whether the address of the ebss segment is the last unit.
And step 217, when the address of the ebss section is the last unit, calling a script debugging reset instruction to reset the tested system.
When the address of the ebss segment is not the last element, step 208 is performed.
The embodiment of the invention provides a method for detecting uninitialized variables, which can realize the rapid positioning of uninitialized global variable positions in embedded software by adopting a DSS kit for automatic detection, thereby reducing software bugs and saving the debugging time of software developers.
An embodiment of the present invention provides a device for detecting an uninitialized variable, as shown in fig. 3, the device includes: the device comprises a reset module 301, a filling module 302, a reading module 303 and a determining module 304.
The resetting module 301 is configured to reset the system under test, so that the pointer points to the main function of the system under test.
Optionally, the apparatus further includes a processing module, configured to receive and install a debugging server script DSS toolkit, and execute the DSS toolkit.
The reset module 301 is configured to call a script debugging reset instruction, and reset the system under test, so that the pointer points to the system main function.
A filling module 302, configured to fill the specified data in the memory segment storing the global variable in the system under test.
Optionally, the filling module 302 is configured to invoke a script debug memory filling instruction, and fill the specified data in all memory units in the RAM of the ebss segment in the system under test.
Between the filling module 302 and the reading module 303, a calling module may be further included, configured to call a script debugging breakpoint instruction, and set a breakpoint in a statement following an initialization function in the software system under test; and calling a script debugging full-speed running instruction, and running the tested software system to a breakpoint statement at full speed.
A reading module 303, configured to enable a pointer to run to a function position where variable initialization is completed, read the memory segment data, and obtain a total number of memory cells corresponding to the name of the global variable and a total number of cells of the specified data.
Optionally, when the pointer is operated to the function position where the variable initialization is completed, the reading module 303 is configured to call a script debugging memory reading instruction, and read all specified data of the ebss-segment RAM memory unit; calling a script debugging variable reading instruction, and reading the name of the global variable corresponding to the ebss section address; and when the name of the global variable is acquired, acquiring the total number of memory units corresponding to the name of the global variable accumulated by a first counter, and acquiring the total number of units of the specified data accumulated by a second counter.
When the total number of memory cells corresponding to the name of the global variable is the same as the total number of cells of the designated data, the determining module 304 is configured to determine that the global variable is an uninitialized global variable.
Optionally, the determining module 304 is configured to detect whether a name of a next global variable is read;
when the name of the next global variable is read, detecting whether the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data or not;
and when the total number of the memory units corresponding to the names of the global variables is the same as the total number of the units of the specified data, determining that the global variables corresponding to the currently detected memory area are uninitialized global variables.
Further, the apparatus is further configured to: when the global variable corresponding to the currently detected memory area is determined to be an uninitialized global variable, sending the uninitialized global variable to a control unit corresponding to a control window, and assigning the first counter and the second counter to be 0;
when the name of the next global variable is not read, or when the total number of memory units corresponding to the name of the global variable is different from the total number of units of the specified data, or after the first counter and the second counter are assigned to be 0, whether the address of the ebss section is the last unit is detected, and when the address of the ebss section is the last unit, a script debugging reset instruction is called to reset the tested system.
According to the device for detecting the uninitialized variables, all memory units of the ebss section RAM in the detected software system are filled with the specified data (0x55AA) through the filling module, the reading module obtains the total number of the memory units corresponding to the names of the global variables and the total number of the filled specified data units, and when the total numbers of the memory units and the filled specified data units are the same, the determining module can determine that the currently detected global variables are the uninitialized global variables. The whole detection process has the characteristics of simple operation, no need of additional temporary chip resources, accurate detection result, high speed and the like.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 4 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 4, the terminal device 4 of this embodiment includes: a processor 401, a memory 402 and a computer program 403, such as a detection program for uninitialized variables, stored in said memory 402 and operable on said processor 401. The processor 401 implements the steps in the above-mentioned embodiments of the method for detecting an uninitialized variable, such as steps 101 to 104 shown in fig. 1 or steps 201 to 217 shown in fig. 2, when executing the computer program 403, and the processor 401 implements the functions of the modules in the above-mentioned embodiments of the apparatus, such as the functions of the modules 301 to 304 shown in fig. 3, when executing the computer program 403.
Illustratively, the computer program 403 may be partitioned into one or more modules that are stored in the memory 402 and executed by the processor 401 to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 403 in the detection device for uninitialized variables or terminal equipment 4. For example, the computer program 403 may be divided into a reset module 301, a fill module 302, a read module 303, and a determination module 304, and specific functions of the modules are shown in fig. 3, which is not described herein again.
The terminal device 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 401, a memory 402. Those skilled in the art will appreciate that fig. 4 is merely an example of a terminal device 4 and does not constitute a limitation of terminal device 4 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 401 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 402 may be an internal storage unit of the terminal device 4, such as a hard disk or a memory of the terminal device 4. The memory 402 may also be an external storage device of the terminal device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 4. Further, the memory 402 may also include both an internal storage unit and an external storage device of the terminal device 4. The memory 402 is used for storing the computer programs and other programs and data required by the terminal device 4. The memory 402 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1.一种对未初始化变量的检测方法,其特征在于,包括:1. a detection method to uninitialized variable, is characterized in that, comprises: 复位被测系统,使指针指向所述被测系统的主函数;Reset the system under test so that the pointer points to the main function of the system under test; 在所述被测系统中存放全局变量的内存段内的RAM中所有内存单元填充指定数据;All memory cells in the RAM in the memory segment storing the global variable in the system under test are filled with the specified data; 使指针运行到变量初始化完毕的函数位置,读取所述内存段数据,获取所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数;Make the pointer run to the function position where the variable initialization is completed, read the memory segment data, and obtain the total number of memory units corresponding to the name of the global variable and the total number of units of the specified data; 当所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数相同时,则确定所述全局变量为未初始化的全局变量。When the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data, it is determined that the global variable is an uninitialized global variable. 2.如权利要求1所述的对未初始化变量的检测方法,其特征在于,在所述复位被测系统,使指针指向所述被测系统的主函数之前,还包括:2. The method for detecting an uninitialized variable as claimed in claim 1, wherein before the system under test is reset and the pointer is made to point to the main function of the system under test, the method further comprises: 嵌入式处理器的集成开发环境IDE具备调试服务器脚本DSS工具包;The integrated development environment IDE for embedded processors has a debug server script DSS toolkit; 调用执行所述DSS工具包;Invoke and execute the DSS toolkit; 所述复位被测系统,使指针指向所述被测系统的主函数,包括:The reset system under test makes the pointer point to the main function of the system under test, including: 调用脚本调试复位指令,复位被测系统,使指针指向所述被测系统的主函数。The script debugging reset instruction is called to reset the system under test, so that the pointer points to the main function of the system under test. 3.如权利要求2所述的对未初始化变量的检测方法,其特征在于,在所述被测系统中存放全局变量的内存段内填充指定数据,包括:3. the detection method to uninitialized variable as claimed in claim 2, is characterized in that, in described system under test, the memory segment that stores global variable is filled with specified data, comprising: 调用脚本调试内存填充指令,在所述被测系统中.ebss段的随机存取存储器RAM中所有内存单元填充指定数据。The script is called to debug the memory filling instruction, and all memory cells in the random access memory RAM of the .ebss segment in the system under test are filled with the specified data. 4.如权利要求3所述的对未初始化变量的检测方法,其特征在于,在所述调用脚本调试内存填充指令,在所述被测系统中.ebss段的随机存取存储器RAM中所有内存单元填充指定数据之后,还包括:4. The detection method for uninitialized variables as claimed in claim 3, characterized in that, in said calling script debugging memory filling instruction, all memory in the random access memory RAM of the .ebss segment in the system under test After the cell is filled with the specified data, it also includes: 调用脚本调试断点指令,在所述被测系统中的初始化函数后一个语句设置断点;Call the script to debug the breakpoint instruction, and set a breakpoint in a statement after the initialization function in the system under test; 调用脚本调试全速运行指令,全速运行所述被测系统到断点语句。The script is called to debug the full-speed running instruction, and the system-under-test is run at full speed to the breakpoint statement. 5.如权利要求3或4所述的对未初始化变量的检测方法,其特征在于,所述读取所述内存段,获取所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数,包括:5. The method for detecting an uninitialized variable according to claim 3 or 4, wherein the reading of the memory segment obtains the total number of memory cells corresponding to the name of the global variable and the total number of the specified data. Total number of units, including: 调用脚本调试内存读取指令,读取所述.ebss段RAM内存单元的所有指定数据;Call the script to debug the memory reading instruction, and read all the specified data of the .ebss segment RAM memory unit; 调用脚本调试变量读取指令,读取所述.ebss段地址对应的所述全局变量的名称;Call the script to debug the variable reading instruction, and read the name of the global variable corresponding to the .ebss segment address; 当获取到所述全局变量的名称时,获取第一计数器累计的所述全局变量的名称对应的内存单元总数,并获取第二计数器累计的所述指定数据的单元总数。When the name of the global variable is acquired, the total number of memory units corresponding to the name of the global variable accumulated by the first counter is acquired, and the total number of units of the specified data accumulated by the second counter is acquired. 6.如权利要求5所述的对未初始化变量的检测方法,其特征在于,所述当所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数相同时,则确定所述全局变量为未初始化的全局变量,包括:6. The method for detecting an uninitialized variable according to claim 5, wherein when the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data, it is determined that the Global variables are uninitialized global variables, including: 检测是否读取到下一个全局变量的名称;Check if the name of the next global variable is read; 当读取到下一个全局变量的名称时,则检测所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数是否相同;When the name of the next global variable is read, then detect whether the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data; 当所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数相同时,确定当前检测的内存区对应的所述全局变量为未初始化的全局变量。When the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data, it is determined that the global variable corresponding to the currently detected memory area is an uninitialized global variable. 7.如权利要求6所述的对未初始化变量的检测方法,其特征在于,所述方法还包括:7. The detection method for uninitialized variables as claimed in claim 6, wherein the method further comprises: 当确定当前检测的内存区对应的所述全局变量为未初始化的全局变量时,将所述未初始化的全局变量发送给控制窗口对应的控制单元,并将所述第一计数器和所述第二计数器赋值为0;When it is determined that the global variable corresponding to the currently detected memory area is an uninitialized global variable, the uninitialized global variable is sent to the control unit corresponding to the control window, and the first counter and the second The counter is assigned a value of 0; 当未读取到下一个全局变量的名称时,或者当所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数不相同时,或者将所述第一计数器和所述第二计数器赋值为0之后,检测所述.ebss段的地址是否为最后一个单元;When the name of the next global variable is not read, or when the total number of memory units corresponding to the name of the global variable is not the same as the total number of units of the specified data, or the first counter and the second After the counter is assigned a value of 0, it is detected whether the address of the .ebss segment is the last unit; 当所述.ebss段的地址为最后一个单元时,调用脚本调试复位指令,对所述被测系统进行复位。When the address of the .ebss segment is the last unit, a script debugging reset instruction is invoked to reset the system under test. 8.一种对未初始化变量的检测装置,其特征在于,包括:8. A detection device for uninitialized variables, comprising: 复位模块,用于复位被测系统,使指针指向所述被测系统的主函数;The reset module is used to reset the system under test, so that the pointer points to the main function of the system under test; 填充模块,用于在所述被测系统中存放全局变量的内存段内的RAM中所有内存单元填充指定数据;Filling module, used for storing all memory cells in the RAM in the memory segment of the global variable in the system under test to fill the specified data; 读取模块,用于使指针运行到变量初始化完毕的函数位置,读取所述内存段数据,获取所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数;A reading module is used to make the pointer run to the function position where the variable initialization is completed, read the memory segment data, and obtain the total number of memory units corresponding to the name of the global variable and the total number of units of the specified data; 确定模块,用于当所述全局变量的名称对应的内存单元总数和所述指定数据的单元总数相同时,则确定所述全局变量为未初始化的全局变量。The determining module is configured to determine that the global variable is an uninitialized global variable when the total number of memory units corresponding to the name of the global variable is the same as the total number of units of the specified data. 9.一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至7任一项所述方法的步骤。9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the computer program as claimed in the claims when executing the computer program The steps of any one of 1 to 7 of the method. 10.一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述方法的步骤。10. A computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented .
CN201910111480.1A 2019-02-12 2019-02-12 Method for detecting uninitialized variable and terminal equipment Active CN109902001B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910111480.1A CN109902001B (en) 2019-02-12 2019-02-12 Method for detecting uninitialized variable and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910111480.1A CN109902001B (en) 2019-02-12 2019-02-12 Method for detecting uninitialized variable and terminal equipment

Publications (2)

Publication Number Publication Date
CN109902001A CN109902001A (en) 2019-06-18
CN109902001B true CN109902001B (en) 2022-06-07

Family

ID=66944780

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910111480.1A Active CN109902001B (en) 2019-02-12 2019-02-12 Method for detecting uninitialized variable and terminal equipment

Country Status (1)

Country Link
CN (1) CN109902001B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688320B (en) * 2019-09-30 2023-05-23 潍柴动力股份有限公司 Detection method, device and terminal equipment of global variables
CN112527660B (en) * 2020-12-17 2022-11-22 展讯通信(上海)有限公司 Static detection method and device for codes
CN116107644A (en) * 2022-12-08 2023-05-12 中船重工(武汉)凌久电子有限责任公司 A DSP-Based RTOS Boot Time Optimization Method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927187A (en) * 2014-05-09 2014-07-16 成都凯智科技有限公司 Program execution method of embedded system
CN105677559A (en) * 2015-12-31 2016-06-15 杭州华为数字技术有限公司 Detection method and device
CN106294170A (en) * 2016-08-17 2017-01-04 厦门科灿信息技术有限公司 The method of testing of embedded control system initialization of variable
JP2017059009A (en) * 2015-09-17 2017-03-23 横河電機株式会社 Control device
CN107391191A (en) * 2017-07-18 2017-11-24 杭州中天微系统有限公司 A kind of program module method for dynamically loading

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927187A (en) * 2014-05-09 2014-07-16 成都凯智科技有限公司 Program execution method of embedded system
JP2017059009A (en) * 2015-09-17 2017-03-23 横河電機株式会社 Control device
CN105677559A (en) * 2015-12-31 2016-06-15 杭州华为数字技术有限公司 Detection method and device
CN106294170A (en) * 2016-08-17 2017-01-04 厦门科灿信息技术有限公司 The method of testing of embedded control system initialization of variable
CN107391191A (en) * 2017-07-18 2017-11-24 杭州中天微系统有限公司 A kind of program module method for dynamically loading

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JavaScript之函数作用域;clearbug;《博客园 https://www.cnblogs.com/craftsman-gao/p/4720635.html》;20150811;全文 *
未初始化全局变量;liuqiaoyu080512;《CSDN博客 https://blog.csdn.net/liuqiaoyu080512/article/details/8455652》;20121231;全文 *

Also Published As

Publication number Publication date
CN109902001A (en) 2019-06-18

Similar Documents

Publication Publication Date Title
US8386851B2 (en) Functional coverage using combinatorial test design
US8990622B2 (en) Post-silicon validation using a partial reference model
US8769504B2 (en) Method and apparatus for dynamically instrumenting a program
US20080244536A1 (en) Evaluating static analysis results using code instrumentation
CN110532185B (en) Test method, test device, electronic equipment and computer readable storage medium
CN112631926A (en) Code test coverage rate display method and device, computer equipment and storage medium
CN110543420B (en) A software testing method, system, terminal and storage medium
CN109902001B (en) Method for detecting uninitialized variable and terminal equipment
CN110209520B (en) Method and device for improving SSD (solid State disk) testing efficiency, computer equipment and storage medium
CN110704303B (en) Method and device for acquiring test coverage information
CN114139479A (en) Simulation verification method, device and computing device
US8117499B2 (en) Generation of a stimuli based on a test template
US20140019939A1 (en) Iterative Generation of Symbolic Test Drivers for Object-Oriented Languages
US9946624B1 (en) Systems and methods to capture data signals from a dynamic circuit
CN109189671B (en) Layer-by-layer approximation type variable positioning method and system and terminal equipment
CN115732025A (en) Method and device for verifying RAM access conflict
CN115373929A (en) Test method, device, equipment, readable storage medium and program product
US10803219B1 (en) Method and system for combined formal static analysis of a design code
CN113220586A (en) Automatic interface pressure test execution method, device and system
CN119476150A (en) Method, device, equipment and medium for verifying chip functional coverage
CN114077538A (en) Program debugging method and device and readable storage medium
CN118760603A (en) A simulation verification method, device, computer equipment and storage medium
CN115964237A (en) Method and device for testing functions and performance of Central Processing Unit (CPU)
CN118427094A (en) Fuzzy test method, system, equipment and storage medium for embedded system
CN112506806B (en) Method for debugging program, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 361101 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Fujian Province

Patentee after: Kehua Data Co.,Ltd.

Country or region after: China

Patentee after: ZHANGZHOU KEHUA TECHNOLOGY Co.,Ltd.

Address before: 361101 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Fujian Province

Patentee before: XIAMEN KEHUAHENGSHENG LIMITED BY SHARE Ltd.

Country or region before: China

Patentee before: ZHANGZHOU KEHUA TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20260104

Address after: 361000 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Xiamen City, Fujian Province

Patentee after: Kehua Data Co.,Ltd.

Country or region after: China

Address before: 361000 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Xiamen City, Fujian Province

Patentee before: Kehua Data Co.,Ltd.

Country or region before: China

Patentee before: ZHANGZHOU KEHUA TECHNOLOGY Co.,Ltd.