CN109902001A - To the detection method and terminal device of uninitialized variable - Google Patents

To the detection method and terminal device of uninitialized variable Download PDF

Info

Publication number
CN109902001A
CN109902001A CN201910111480.1A CN201910111480A CN109902001A CN 109902001 A CN109902001 A CN 109902001A CN 201910111480 A CN201910111480 A CN 201910111480A CN 109902001 A CN109902001 A CN 109902001A
Authority
CN
China
Prior art keywords
global variable
variable
sum
sut
title
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.)
Granted
Application number
CN201910111480.1A
Other languages
Chinese (zh)
Other versions
CN109902001B (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
Zhangzhou Kehua Technology Co Ltd
Kehua Hengsheng 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 Zhangzhou Kehua Technology Co Ltd, Kehua Hengsheng Co Ltd filed Critical Zhangzhou Kehua Technology 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

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The present invention is suitable for embedded software detection technique field, provides the detection method and terminal device of a kind of pair of uninitialized variable, this method comprises: resetting system under test (SUT), pointer is made to be directed toward the system under test (SUT) principal function;It is stored in the system under test (SUT) and fills specified data in the application heap of global variable;So that pointer is run to the function position that initialization of variable finishes, read the memory segment data, obtains the corresponding internal storage location sum of title of the global variable and the unit sum of the specified data;When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, it is determined that the global variable is the global variable of no initializtion.This method can realize the global variable of no initializtion in quickly detection embedded software by the method for script automatic detection.

Description

To the detection method and terminal device of uninitialized variable
Technical field
The invention belongs to embedded unit the field of test technology more particularly to the detection methods of a kind of pair of uninitialized variable And terminal device.
Background technique
Before embedded software system operation need that the global variable of reference is stated and initialized.If variable reference Preceding not initialize to global variable, then its initial value is unfixed.When being quoted to global variable, operation knot Fruit is not expectable, and each run phenomenon is different, not only possible in this way to bring economic loss, and to software developer couple Positioning problems bring difficulty, and software vulnerability is caused not search all, increase the time investment of software developer's debugging routine.
Summary of the invention
In view of this, the embodiment of the invention provides the detection method and terminal device of a kind of pair of uninitialized variable, it can Method to pass through script automatic detection realizes the global variable of no initializtion in quickly detection embedded software.
The first aspect of the embodiment of the present invention provides the detection method of a kind of pair of uninitialized variable, comprising:
System under test (SUT) is resetted, pointer is made to be directed toward the principal function of the system under test (SUT);
It is stored in the system under test (SUT) and fills specified data in the application heap of global variable;
So that pointer is run to the function position that initialization of variable finishes, reads the memory segment data, obtain the overall situation The corresponding internal storage location sum of the title of variable and the unit of specified data sum;
When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, Then determine that the global variable is the global variable of no initializtion.
In one embodiment, in the reset system under test (SUT), it is directed toward pointer before the principal function of the system under test (SUT), also Include:
The Integrated Development Environment IDE of embeded processor has debugging server script DSS kit;
It calls and executes the DSS kit;
The reset system under test (SUT), makes pointer be directed toward the principal function of the system under test (SUT), comprising:
Script debugging reset instruction is called, system under test (SUT) is resetted, pointer is made to be directed toward the principal function of the system under test (SUT).
In one embodiment, it is stored in the system under test (SUT) and fills specified data in the application heap of global variable, comprising:
The filling instruction of script debugging memory is called, in the system under test (SUT) in .ebss sections of random access memory ram All internal storage locations fill specified data.
In one embodiment, it fills and instructs in the calling script debugging memory .ebss sections in the system under test (SUT) In random access memory ram after all specified data of internal storage locations filling, further includes:
Script debugging break-poing instruction is called, initialization function the latter sentence setting in the tested software system is disconnected Point;
Call script debugging full speed running instruction, tested software system described in full speed running to breakpoint sentence.
In one embodiment, described to read the application heap, obtain the corresponding internal storage location of title of the global variable The unit sum of the total and described specified data, comprising:
Script debugging memory read instruction is called, all specified data of the .ebss sections of memory ram unit are read;
It calls script debugging variable to read instruction, reads the title of the corresponding global variable of the .ebss sector address;
When getting the title of the global variable, the title pair of the accumulative global variable of the first counter is obtained The internal storage location sum answered, and obtain the unit sum of the accumulative specified data of the second counter.
In one embodiment, described when the corresponding internal storage location sum of the title of the global variable and the specified data Unit sum it is identical when, it is determined that the global variable be no initializtion global variable, comprising:
Detect whether to read the title of next global variable;
When reading the title of next global variable, then the corresponding internal storage location of title of the global variable is detected Whether the unit sum of the total and described specified data is identical;
When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, Determine that the corresponding global variable in the memory field of current detection is the global variable of no initializtion.
In one embodiment, the method also includes:
It, will be described when the corresponding global variable in the memory field for determining current detection is the global variable of no initializtion The global variable of no initializtion is sent to the corresponding control unit of control window, and first counter and described second are counted Number device is assigned a value of 0;
When the unread title to next global variable, or when the corresponding interior deposit receipt of the title of the global variable When first total not identical with the unit sum of the specified data, or first counter and second counter are assigned After value is 0, detect whether .ebss sections of the address is the last one unit;
When .ebss sections of the address is the last one unit, script debugging reset instruction is called, to the tested system System is resetted.
The second aspect of the embodiment of the present invention provides the detection device of a kind of pair of uninitialized variable, comprising:
Reseting module makes pointer be directed toward the principal function of the system under test (SUT) for resetting system under test (SUT);
Module is filled, specified data are filled in the application heap for storing global variable in the system under test (SUT);
Read module reads the memory segment data for making pointer run to the function position that initialization of variable finishes, Obtain the corresponding internal storage location sum of title of the global variable and the unit sum of the specified data;
Determining module, the list for title corresponding internal storage location sum and the specified data when the global variable When first total identical, it is determined that the global variable is the global variable of no initializtion.
The third aspect of the embodiment of the present invention provides a kind of terminal device, including memory, processor and is stored in In the memory and the computer program that can run on the processor, when the processor executes the computer program Realize provided in above-described embodiment to the detection method of uninitialized variable the step of.
The fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage Media storage has a computer program, the computer program realized when being executed by processor provided in above-described embodiment to not just The step of detection method of beginningization variable.
Existing beneficial effect is the embodiment of the present invention compared with prior art: the embodiment of the present invention is by resetting tested system System, makes pointer be directed toward the principal function of the system under test (SUT);It stores in the system under test (SUT) and is filled in the application heap of global variable Specified data;So that pointer is run to the function position that initialization of variable finishes, reads the memory segment data, obtain the overall situation The corresponding internal storage location sum of the title of variable and the unit of specified data sum;When the title of the global variable is corresponding Internal storage location sum and the specified data unit sum it is identical when, it is determined that the global variable be no initializtion it is complete The global variable for quickly detecting no initializtion in embedded software may be implemented in office's variable.And entire detection process, is not required to volume Outer occupancy resources of chip, testing result is accurate and fireballing feature.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only of the invention some Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these Attached drawing obtains other attached drawings.
Fig. 1 is the implementation process schematic diagram of the detection method of a kind of pair of uninitialized variable provided in an embodiment of the present invention;
Fig. 2 is that the implementation process of another detection method to uninitialized variable provided in an embodiment of the present invention is illustrated Figure;
Fig. 3 is the exemplary diagram of the detection device provided in an embodiment of the present invention to uninitialized variable;
Fig. 4 is the schematic diagram of terminal device provided in an embodiment of the present invention.
Specific embodiment
In being described below, for illustration and not for limitation, the tool of such as particular system structure, technology etc is proposed Body details, to understand thoroughly the embodiment of the present invention.However, it will be clear to one skilled in the art that there is no these specific The present invention also may be implemented in the other embodiments of details.In other situations, it omits to well-known system, device, electricity The detailed description of road and method, in case unnecessary details interferes description of the invention.
In order to illustrate technical solutions according to the invention, the following is a description of specific embodiments.
The embodiment of the present invention provides the detection method of a kind of pair of uninitialized variable, as shown in Figure 1, this method includes following Step:
Step 101, system under test (SUT) is resetted, pointer is made to be directed toward the principal function of the system under test (SUT).
Optionally, before resetting system under test (SUT), importing debugging server script (Debug Server Scripting, DSS) kit creates script environment object, obtains debugging server and starts debugging server dialogue.It is automatic to call script tune Reset instruction is tried, system under test (SUT) is resetted, pointer is made to be directed toward system under test (SUT) main principal function.
The executing subject of this method can be computer terminal, can be computer readable storage medium, and this method is simultaneously unlimited It is set to above-mentioned executing subject, the above is only illustrate.
Optionally, the test carrier that this method requires is the integrated of embedded chip minimum system plate and embeded processor It develops environment (Integrated development environment, IDE), the two uses emulator (Joint Test Action Group, JTAG) it connects and carries out in-circuit emulation.Software development environment has DSS functional interface, and scripting language is general Support the high-level languages such as Java or Javasript, Perl, Python, TCL.DSS kit, can be in software development environment Replaced using directive script and be manually operated, such as software reset, setting breakpoint, full speed running, single step run, memory filling, memory It reads and memory address is to functions such as the readings of dependent variable.Therefore, shell script is write by certain logical order, it can be most Automatic test is realized under mini system plate simulated environment.For example, calling script debugging reset instruction in this step automatically, quilt is resetted Examining system makes pointer be directed toward system under test (SUT) main principal function.
Step 102, it is stored in the system under test (SUT) and fills specified data in the application heap of global variable.
It is automatic to call the filling instruction of script debugging memory .ebss sections of the random access memory in the system under test (SUT) All internal storage locations fill specified data in (random access memory, RAM).
Optionally, specified data can be the data such as 0x55AA..ebss section in embedded software is for global variable Storage.
It optionally, further include automatic calling script debugging break-poing instruction after this step, in the tested software system In initialization function the latter sentence be arranged breakpoint;
It is automatic to call script debugging full speed running instruction, tested software system described in full speed running to breakpoint sentence.
Step 103, so that pointer is run to the function position that initialization of variable finishes, read the memory segment data, obtain The corresponding internal storage location sum of the title of the global variable and the unit of specified data sum.
Optionally, this step includes: automatic calling script debugging memory read instruction, and it is all to read the .ebss sections of RAM The corresponding all specified data of internal storage location;It is automatic that script debugging variable is called to read instruction, read the .ebss sector address pair The title for the global variable answered;
When getting the title of the global variable, the title pair of the accumulative global variable of the first counter is obtained The internal storage location sum answered, and the unit sum of the accumulative specified data of the second counter is obtained, optionally, it can use Var_Cnt indicates the corresponding internal storage location sum of the title of global variable, and the specified data of filling can be indicated with Fill_Cnt Unit sum;
Step 104, when the unit of the corresponding internal storage location sum of the title of the global variable and the specified data is total When number is identical, it is determined that the global variable is the global variable of no initializtion.
Optionally, as Fill_Cnt=Var_Cnt, it is determined that the corresponding global variable in the memory field of current detection For the global variable of no initializtion, it is single that the global variable of the no initializtion is sent to the corresponding control of control window later Member, and first counter and second counter are assigned a value of preset value, optionally, preset value can be 0.Thus The global variable of all no initializtions can be obtained in control window, and global variable can be accurately positioned.
The detection method of a kind of pair of uninitialized variable provided in an embodiment of the present invention, by being detected software systems All internal storage locations of .ebss section RAM carry out the filling of specified data (0x55AA), obtain global variable title it is corresponding in Memory cell sum and the unit of the specified data of filling sum then can determine the overall situation of current detection when the two sum is identical Variable is the global variable of no initializtion.Entire detection process, have it is easy to operate, be not required to additional temporary resources of chip, detect As a result the features such as accurate and speed is fast.
The embodiment of the present invention provides another detection method to uninitialized variable, as shown in Fig. 2, this method comprises:
Step 201, the Integrated Development Environment IDE of embeded processor has debugging server script DSS kit.
Optionally, the test carrier that this method requires is the integrated of embedded chip minimum system plate and embeded processor Environment ID E is developed, the two is connected using emulator JTAG and carries out in-circuit emulation.The Integrated Development Environment of embeded processor IDE has DSS functional interface, and scripting language generally supports the high-level languages such as Java or Javasript, Perl, Python, TCL. DSS kit can use directive script and replace manual operation in software development environment, and such as software reset is arranged breakpoint, is complete Fast operation, single step run, memory filling, memory is read and memory address is to functions such as the readings of dependent variable.Therefore, by certain Logical order writes shell script, can realize automatic test under minimum system plate simulated environment.For example, in this step certainly It is dynamic to call script debugging reset instruction, system under test (SUT) is resetted, pointer is made to be directed toward system under test (SUT) main principal function.
Optionally, DSS kit is imported, script environment object is created.
Step 202, it calls and executes the DSS kit.
Optionally, debugging server script is obtained, debugging server dialogue is started.
Step 203, script debugging reset instruction is called, system under test (SUT) is resetted, pointer is made to be directed toward the master of the system under test (SUT) Function.
When running DSS kit in this step, script debugging reset instruction can be called automatically.
Step 204, the filling instruction of script debugging memory is called .ebss sections of arbitrary access is deposited in the system under test (SUT) All internal storage locations fill specified data in reservoir RAM.
Optionally, the filling instruction of script debugging memory is called automatically, to all memories of .ebss sections in system under test (SUT) of RAM Unit carries out the filling of specified data.Optionally, specified data can be 0x55AA..ebss sections of embedded software are used for The storage of global variable.
Step 205, script debugging break-poing instruction, initialization function the latter language in the tested software system are called Sentence setting breakpoint.
The effect of breakpoint is set to terminate test program.
Step 206, script debugging full speed running instruction, tested software system described in full speed running to breakpoint sentence are called.
Step 207, script debugging memory read instruction is called, all specified of the .ebss sections of memory ram unit is read Data.
This step is to read all specified data being filled in .ebss sections of RAM.
Step 208, it calls script debugging variable to read instruction, reads the corresponding global change of the .ebss sector address The title of amount.
Step 209, when getting the title of the global variable, the accumulative global variable of the first counter is obtained Title corresponding internal storage location sum, and obtain the unit sum of the accumulative specified data of the second counter.
It should be noted that here the first counter and the second counter merely to distinguish counter carry out name, It is not that function ranking is carried out to counter.
Step 210, detect whether to read the title of next global variable.
Step 211, when reading the title of next global variable, then the title for detecting the global variable is corresponding Whether internal storage location sum and the unit sum of the specified data are identical.
Optionally, judge whether Fill_Cnt is equal with Var_Cnt.
Step 212, when the unit of the corresponding internal storage location sum of the title of the global variable and the specified data is total When number is identical, determine that the corresponding global variable in the memory field of current detection is the global variable of no initializtion.
Step 213, the global variable of the no initializtion is sent to the corresponding control unit of control window.
Optionally, this step is to show the global variable of the no initializtion determined in control window, so as to each complete Office's variable is positioned, then by two counter O resets.
Step 214, first counter and second counter are assigned a value of 0.
It should be noted that after executing step 211, when the corresponding internal storage location sum of the title of the global variable and institute State specified data unit sum it is not identical when, execute step 214.
Step 215 .ebss sections of the next address is read.
Optionally, execute step 210 after, when it is unread arrive next global variable title when, execution step 215, i.e., .ebss sections of the next address is read, and then continues to execute step 216.
Step 216, detect whether .ebss sections of the address is the last one unit.
Step 217, when .ebss sections of the address is the last one unit, script debugging reset instruction is called, to institute System under test (SUT) is stated to be resetted.
When .ebss sections of addresses are not the last one units, step 208 is executed.
The embodiment of the invention provides the detection methods of a kind of pair of uninitialized variable, carry out by using DSS kit The global variable position of no initializtion in quickly positioning embedded software is realized in automatic detection, so as to reduce software leakage Hole, and save the debug time of software developer.
The embodiment of the present invention provides the detection device of a kind of pair of uninitialized variable, as shown in figure 3, the device includes: multiple Position module 301, fills module 302, read module 303, determining module 304.
Reseting module 301 makes pointer be directed toward the principal function of the system under test (SUT) for resetting system under test (SUT).
Optionally, described device further includes processing module, for receiving simultaneously installation and debugging server script DSS kit, And execute the DSS kit.
The reseting module 301 resets system under test (SUT), makes pointer pointing system for calling script debugging reset instruction Principal function.
Module 302 is filled, specified data are filled in the application heap for storing global variable in the system under test (SUT).
Optionally, the filling module 302, for calling the filling instruction of script debugging memory, in the system under test (SUT) .ebss all internal storage locations fill specified data in the random access memory ram of section.
It can also include calling module, for calling script debugging disconnected between filling module 302 and read module 303 Breakpoint is arranged in point instruction, initialization function the latter sentence in the tested software system;Script debugging is called to transport at full speed Row instructs, tested software system described in full speed running to breakpoint sentence.
Read module 303 reads the memory number of segment for making pointer run to the function position that initialization of variable finishes According to the unit of the corresponding internal storage location sum of title and the specified data that obtain the global variable is total.
Optionally, when pointer runs to the function position that initialization of variable finishes, the read module 303, for calling Script debugging memory read instruction reads all specified data of the .ebss sections of memory ram unit;Script debugging is called to become Amount reads instruction, reads the title of the corresponding global variable of the .ebss sector address;When getting the global variable When title, the corresponding internal storage location sum of title of the accumulative global variable of the first counter is obtained, and obtains the second meter The unit sum of the accumulative specified data of number device.
When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, Determining module 304 is used to then determine the global variable that the global variable is no initializtion.
Optionally, the determining module 304, for detecting whether reading the title of next global variable;
When reading the title of next global variable, then the corresponding internal storage location of title of the global variable is detected Whether the unit sum of the total and described specified data is identical;
When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, Determine that the corresponding global variable in the memory field of current detection is the global variable of no initializtion.
Further, described device is also used to: when the corresponding global variable in the memory field for determining current detection is not When the global variable of initialization, the global variable of the no initializtion is sent to the corresponding control unit of control window, and will First counter and second counter are assigned a value of 0;
When the unread title to next global variable, or when the corresponding interior deposit receipt of the title of the global variable When first total not identical with the unit sum of the specified data, or first counter and second counter are assigned After value is 0, detect whether .ebss sections of the address is the last one unit, when .ebss sections of the address is last When a unit, script debugging reset instruction is called, the system under test (SUT) is resetted.
The detection device of a kind of pair of uninitialized variable provided in an embodiment of the present invention, by filling module be detected it is soft All internal storage locations of .ebss section RAM in part system carry out the filling of specified data (0x55AA), and read module obtains global become The corresponding internal storage location sum of the title of amount and the unit of the specified data of filling sum, when the two sum is identical, it is determined that Module can determine that the global variable of current detection is the global variable of no initializtion.Entire detection process, have it is easy to operate, no The features such as additional temporary resources of chip of need, testing result is accurate and speed is fast.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit It is fixed.
Fig. 4 is the schematic diagram for the terminal device that one embodiment of the invention provides.As shown in figure 4, the terminal of the embodiment is set Standby 4 include: processor 401, memory 402 and are stored in the memory 402 and can run on the processor 401 Computer program 403, such as the detection program to uninitialized variable.The processor 401 executes the computer program The step in the detection method embodiment of above-mentioned each pair of uninitialized variable, such as step 101 shown in FIG. 1 are realized when 403 To 104 or step 201 shown in Fig. 2 to step 217, the realization when processor 401 executes the computer program 403 The function of each module in above-mentioned each Installation practice, such as the function of module 301 to 304 shown in Fig. 3.
Illustratively, the computer program 403 can be divided into one or more modules, one or more of Module is stored in the memory 402, and is executed by the processor 401, to complete the present invention.It is one or more of Module can be the series of computation machine program instruction section that can complete specific function, and the instruction segment is for describing the computer Implementation procedure of the program 403 in the detection device to uninitialized variable or terminal device 4.For example, the calculating Machine program 403 can be divided into reseting module 301, fill module 302, read module 303, determining module 304, each module tool Body function is as shown in figure 3, this is no longer going to repeat them.
The terminal device 4 can be the calculating such as desktop PC, notebook, palm PC and cloud server and set It is standby.The terminal device may include, but be not limited only to, processor 401, memory 402.It will be understood by those skilled in the art that Fig. 4 is only the example of terminal device 4, does not constitute the restriction to terminal device 4, may include more more or fewer than illustrating Component, perhaps combines certain components or different components, for example, the terminal device can also include input-output equipment, Network access equipment, bus etc..
Alleged processor 401 can be central processing unit (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor Deng.
The memory 402 can be the internal storage unit of the terminal device 4, for example, terminal device 4 hard disk or Memory.The memory 402 is also possible to the External memory equipment of the terminal device 4, such as is equipped on the terminal device 4 Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, Flash card (Flash Card) etc..Further, the memory 402 can also have been deposited both the inside including the terminal device 4 Storage unit also includes External memory equipment.The memory 402 is for storing the computer program and the terminal device 4 Other required programs and data.The memory 402, which can be also used for temporarily storing, have been exported or will export Data.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different Functional unit, module are completed, i.e., the internal structure of described device is divided into different functional unit or module, more than completing The all or part of function of description.Each functional unit in embodiment, module can integrate in one processing unit, can also To be that each unit physically exists alone, can also be integrated in one unit with two or more units, it is above-mentioned integrated Unit both can take the form of hardware realization, can also realize in the form of software functional units.In addition, each function list Member, the specific name of module are also only for convenience of distinguishing each other, the protection scope being not intended to limit this application.Above system The specific work process of middle unit, module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed The scope of the present invention.
In embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method, it can be with It realizes by another way.For example, device described above/terminal device embodiment is only schematical, for example, institute The division of module or unit is stated, only a kind of logical function partition, there may be another division manner in actual implementation, such as Multiple units or components can be combined or can be integrated into another system, or some features can be ignored or not executed.Separately A bit, shown or discussed mutual coupling or direct-coupling or communication connection can be through some interfaces, device Or the INDIRECT COUPLING or communication connection of unit, it can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme 's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated module/unit be realized in the form of SFU software functional unit and as independent product sale or In use, can store in a computer readable storage medium.Based on this understanding, the present invention realizes above-mentioned implementation All or part of the process in example method, can also instruct relevant hardware to complete, the meter by computer program Calculation machine program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that on The step of stating each embodiment of the method.Wherein, the computer program includes computer program code, the computer program Code can be source code form, object identification code form, executable file or certain intermediate forms etc..Computer-readable Jie Matter may include: can carry the computer program code any entity or device, recording medium, USB flash disk, mobile hard disk, Magnetic disk, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described The content that computer-readable medium includes can carry out increasing appropriate according to the requirement made laws in jurisdiction with patent practice Subtract, such as does not include electric carrier signal and electricity according to legislation and patent practice, computer-readable medium in certain jurisdictions Believe signal.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality Applying example, invention is explained in detail, those skilled in the art should understand that: it still can be to aforementioned each Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution should all It is included within protection scope of the present invention.

Claims (10)

1. the detection method of a kind of pair of uninitialized variable characterized by comprising
System under test (SUT) is resetted, pointer is made to be directed toward the principal function of the system under test (SUT);
It is stored in the system under test (SUT) and fills specified data in the application heap of global variable;
So that pointer is run to the function position that initialization of variable finishes, reads the memory segment data, obtain the global variable The corresponding internal storage location sum of title and the specified data unit sum;
When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, then really The fixed global variable is the global variable of no initializtion.
2. as described in claim 1 to the detection method of uninitialized variable, which is characterized in that reset tested system described System, is directed toward pointer before the principal function of the system under test (SUT), further includes:
The Integrated Development Environment IDE of embeded processor has debugging server script DSS kit;
It calls and executes the DSS kit;
The reset system under test (SUT), makes pointer be directed toward the principal function of the system under test (SUT), comprising:
Script debugging reset instruction is called, system under test (SUT) is resetted, pointer is made to be directed toward the principal function of the system under test (SUT).
3. as claimed in claim 2 to the detection method of uninitialized variable, which is characterized in that deposited in the system under test (SUT) It puts and fills specified data in the application heap of global variable, comprising:
The filling instruction of script debugging memory is called, is owned in .ebss sections of random access memory ram in the system under test (SUT) Internal storage location fills specified data.
4. as claimed in claim 3 to the detection method of uninitialized variable, which is characterized in that in the calling script debugging Memory filling instruction, all internal storage location fillings are specified in .ebss sections of random access memory ram in the system under test (SUT) After data, further includes:
Script debugging break-poing instruction is called, breakpoint is arranged in initialization function the latter sentence in the tested software system;
Call script debugging full speed running instruction, tested software system described in full speed running to breakpoint sentence.
5. the detection method to uninitialized variable as described in claim 3 or 4, which is characterized in that described to read in described Section is deposited, the corresponding internal storage location sum of title of the global variable and the unit sum of the specified data are obtained, comprising:
Script debugging memory read instruction is called, all specified data of the .ebss sections of memory ram unit are read;
It calls script debugging variable to read instruction, reads the title of the corresponding global variable of the .ebss sector address;
When getting the title of the global variable, the title for obtaining the accumulative global variable of the first counter is corresponding Internal storage location sum, and obtain the unit sum of the accumulative specified data of the second counter.
6. as claimed in claim 5 to the detection method of uninitialized variable, which is characterized in that described to work as the global variable The corresponding internal storage location sum of title and the specified data unit sum it is identical when, it is determined that the global variable be not The global variable of initialization, comprising:
Detect whether to read the title of next global variable;
When reading the title of next global variable, then the corresponding internal storage location sum of title of the global variable is detected It is whether identical with the unit sum of the specified data;
When the corresponding internal storage location sum of the title of the global variable and the identical unit of specified data sum, determine The corresponding global variable in the memory field of current detection is the global variable of no initializtion.
7. as claimed in claim 6 to the detection method of uninitialized variable, which is characterized in that the method also includes:
It, will be described not first when the corresponding global variable in the memory field for determining current detection is the global variable of no initializtion The global variable of beginningization is sent to the corresponding control unit of control window, and by first counter and second counter It is assigned a value of 0;
When the unread title to next global variable, or when the corresponding internal storage location of the title of the global variable is total When several not identical with the unit sum of the specified data, or first counter and second counter are assigned a value of After 0, detect whether .ebss sections of the address is the last one unit;
When .ebss sections of the address be the last one unit when, call script debugging reset instruction, to the system under test (SUT) into Row resets.
8. the detection device of a kind of pair of uninitialized variable characterized by comprising
Reseting module makes pointer be directed toward the principal function of the system under test (SUT) for resetting system under test (SUT);
Module is filled, specified data are filled in the application heap for storing global variable in the system under test (SUT);
Read module reads the memory segment data, obtains for making pointer run to the function position that initialization of variable finishes The corresponding internal storage location sum of the title of the global variable and the unit of specified data sum;
Determining module, for when the global variable the corresponding internal storage location sum of title and the specified data unit it is total When number is identical, it is determined that the global variable is the global variable of no initializtion.
9. a kind of terminal device, including memory, processor and storage are in the memory and can be on the processor The computer program of operation, which is characterized in that the processor realizes such as claim 1 to 7 when executing the computer program The step of any one the method.
10. a kind of computer readable storage medium, the computer-readable recording medium storage has computer program, and feature exists In when the computer program is executed by processor the step of any one of such as claim 1 to 7 of realization the method.
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 true CN109902001A (en) 2019-06-18
CN109902001B 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)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688320A (en) * 2019-09-30 2020-01-14 潍柴动力股份有限公司 Global variable detection method and device and terminal equipment
CN112527660A (en) * 2020-12-17 2021-03-19 展讯通信(上海)有限公司 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
CLEARBUG: "JavaScript之函数作用域", 《博客园 HTTPS://WWW.CNBLOGS.COM/CRAFTSMAN-GAO/P/4720635.HTML》 *
LIUQIAOYU080512: "未初始化全局变量", 《CSDN博客 HTTPS://BLOG.CSDN.NET/LIUQIAOYU080512/ARTICLE/DETAILS/8455652》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688320A (en) * 2019-09-30 2020-01-14 潍柴动力股份有限公司 Global variable detection method and device and terminal equipment
CN112527660A (en) * 2020-12-17 2021-03-19 展讯通信(上海)有限公司 Static detection method and device for codes
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
CN116107644B (en) * 2022-12-08 2026-03-31 中船凌久电子(武汉)有限责任公司 A method for optimizing the startup time of a DSP-based real-time operating system

Also Published As

Publication number Publication date
CN109902001B (en) 2022-06-07

Similar Documents

Publication Publication Date Title
CN111858296B (en) Interface testing method, device, equipment and storage medium
CN108427644A (en) Service test method, service testing system and service testing device
CN108563575B (en) application program testing method and device, terminal 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
CN108984403A (en) The verification method and device of FPGA logical code
CN114064208A (en) Method and device for detecting application service state, electronic equipment and storage medium
CN113238940A (en) Interface test result comparison method, device, equipment and storage medium
CN102841837A (en) Software and hardware co-verification method based on simulator and system thereof
CN109902001A (en) To the detection method and terminal device of uninitialized variable
CN109407655B (en) Method and device for debugging chip
CN107038120A (en) A kind of method for testing software and equipment
CN120493825B (en) Chip verification method, test equipment and chip verification system
CN113254290A (en) Memory particle multidimensional test method, device and system and readable storage medium
US20140019939A1 (en) Iterative Generation of Symbolic Test Drivers for Object-Oriented Languages
CN110609786A (en) Software testing method and device, computer equipment and storage medium
CN117076337B (en) Data transmission method and device, electronic equipment and readable storage medium
CN117743145A (en) Test script generation method and device based on coding template and processing equipment
US8479169B1 (en) Code analysis via ranged values
CN117061564A (en) Verification method, device, equipment and medium for vehicle signal transmission state
CN114548027B (en) Method, electronic device and storage medium for tracking signals in verification system
CN117667658A (en) Test program generation method and test program generation device
CN113868030A (en) CPU test tool adaptive matching method, system, terminal and storage medium
CN116306413B (en) FPGA simulation verification method and device, electronic equipment and storage medium
CN109582334B (en) Upgrading method and device for programmable logic device

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

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.

CP03 Change of name, title or address
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.

TR01 Transfer of patent right