WO2008058473A1 - Mapping method in the program testing system and program testing system - Google Patents

Mapping method in the program testing system and program testing system Download PDF

Info

Publication number
WO2008058473A1
WO2008058473A1 PCT/CN2007/003244 CN2007003244W WO2008058473A1 WO 2008058473 A1 WO2008058473 A1 WO 2008058473A1 CN 2007003244 W CN2007003244 W CN 2007003244W WO 2008058473 A1 WO2008058473 A1 WO 2008058473A1
Authority
WO
WIPO (PCT)
Prior art keywords
mapping
variable
entity
host
script
Prior art date
Application number
PCT/CN2007/003244
Other languages
French (fr)
Chinese (zh)
Inventor
Xueming Zeng
Original Assignee
Shenzhen Lingce 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 Shenzhen Lingce Technology Co., Ltd. filed Critical Shenzhen Lingce Technology Co., Ltd.
Priority to CN2007800016987A priority Critical patent/CN101401075B/en
Publication of WO2008058473A1 publication Critical patent/WO2008058473A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Definitions

  • the invention relates to the field of software debugging and testing, and particularly relates to a debugging system and method for software debugging and testing of a C/C++ language development environment. ' Background technique
  • Tornado programming environment supporting VxWorks real-time operating system development is one of the best programming environments for debugging performance in many embedded programming languages.
  • the Tornado test command interpretation module tool supports scripted variable read and write and function call calls, and is more powerful.
  • Tornado User's Guide Windows Version
  • V2.0 Edition V2.0 Edition 1 by Wind River Systems, Inc.
  • Tornado test command interpretation module is powerful, it uses two interpreters, the C interpreter and the TCL interpreter, and because it only has a symbol table that resides in the target server, there is no type table, so its debugging capability. Subject to many restrictions, mainly including:
  • the C interpreter and TCL interpreter used for the commissioning control reside on the test host, which causes the commissioning control to be unable to support the commissioning when it is tightly coupled with the code under test;
  • the C interpreter and the TCL interpreter are two sets of systems, which are difficult to integrate at the grammar and semantic levels, which increases the user's learning burden and is not conducive to the expansion of the debugging function.
  • the 4th generation white box test method combines the best practices of software white box testing, reflecting the development direction of today's white box testing. In order to meet the requirements of the 4th generation white box test method, the following adjustments to the Tornado technology-based commissioning system are required:
  • test control and the code under test should be in the same body.
  • the invention aims to improve the problem of insufficient commissioning capability and poor test efficiency which are prevalent in current software development, and meets the requirements of the fourth generation white box test method, and applies the relevant test methodology to the field of C/C++ language development.
  • a set of programming language mapping techniques is proposed, namely: mapping the variable operations and correspondence operations of the C/C++ language to a scripting language system, and the scripting language system resides in the system under test, so that the scripting languages are both scripted.
  • the test description and can directly manipulate the variables, functions, etc. in the system under test, and make this test description as consistent as possible with the C/C++ grammar rules.
  • mapping technique of the present invention can also be as close as possible to the grammar rules (approx. Python, or Ruby, or TCL), describes the functional interface provided by this scripting language, which is called directly in the commissioning.
  • the present invention also introduces a system that supports real-time debugging, so that the test control and the code to be tested are in the same execution body.
  • the present invention uses a scripting language to describe both the control of variables and functions for the C/C++ language being tested, as well as the test control, and to keep both types of descriptions of the same style.
  • a program commissioning system comprising a test host and a target machine, the test host commissioning a program of the target machine.
  • the target machine includes a mapping support module, and the mapping support module includes a variable container; the variable container is a class object of the script's TContainer class, and the debugged C/C++ target program system
  • the variable and the function 'number are mapped into a mapping variable and a mapping function in the variable container, and when the operation of the mapping variable or the mapping function is described in the host scripting language, the mapping variable and the mapping function and the variable of the program under test And a function having a similar expression; by means of the variable container, the operation of the mapping variable using the host script language is diverted to the operation of a corresponding variable in the C/C++ target program system being debugged, the host The operation of the mapping language by the scripting language is directed to the operation of the corresponding function in the C/C++ target program system being debugged.
  • a mapping method applied to a program commissioning system includes a test host and a target machine, and the test host performs debugging on a program in the target machine, and includes a mapping support module in the target machine, the method includes: 1) The mapping support module generates a symbol table and a type table of the tested program according to the debug database compiled by the commissioning program; 2) the mapping support module sets the variables and functions in the type table and the symbol table Mapping to a variable container, generating a mapping variable and a mapping function operable by the host script system, wherein the variable container is a class object of the script TContainer class.
  • arithmetic processing of software commissioning can be assigned to the test host and the target machine.
  • the scripting of the test case of the test program is processed by the test host, the script is issued (the host script system that is delivered to the target machine), and the output information is displayed during the test. Residing in the destination
  • the scripting system of the standard machine completes the mapping and control of the C/C++ language variables and functions of the tested terminal, that is, mapping the variable operations and functions of the C/C++ language to a scripting language system (ie, the host scripting system).
  • This scripting language which resides in the system under test, not only implements scripted test descriptions, but also directly manipulates variables, functions, etc. in the system under test.
  • the mapping technique of the present invention effectively improves the debugging capability of the software product and the white box testing capability.
  • the present invention includes the commissioning module and the mapping module in the scripting system of the testing agent, so that both the test control and the tested code are in one system.
  • the commissioning control is more closely coupled to the code under test. Tightly coupled interactions do not have the latency of the two systems due to communication connections, and the complexity of the test control process is also reduced.
  • the advantages of the present invention are: By using a mapping technique, the commissioning script can directly control the behavior of the system under test. Due to the online definition of the script and the online execution characteristics, the development efficiency of the commissioning script is greatly improved, which effectively guarantees the instrumentation implementation of the online test and gray box debugging required by the 4th generation white box test method. Compared to the Tornado test command interpretation module, the commissioning efficiency is improved. In addition, test scripts do not have to be frequently switched between the two scripting languages, and data transfer and control transfer are more free. As mentioned above, the C interpreter and the TCL interpreter in the Tornado system are difficult to integrate at the syntax and semantic level.
  • the method of the present invention can also ensure that the test description is as consistent as possible with the C/C++ language regulations.
  • a powerful scripting language such as Python, Ruby, TCL, etc.
  • the method of the present invention also describes this as much as possible with approximate grammar rules (approx. Python, or Ruby, or TCL).
  • approximate grammar rules approximately. Python, or Ruby, or TCL.
  • the function interface provided by the scripting language is called directly in the commissioning.
  • the invention can improve the debugging capability of the embedded software, reduce the learning threshold of the test expression, and greatly improve the development efficiency of the commissioning script.
  • Figure 1 shows the logical structure of the existing Tornado technology
  • Figure 2 shows the logical structure of the program commissioning system of the present invention
  • Figure 3 shows the composition of the program commissioning system of the present invention
  • Figure 4 is a hierarchical structure of the test agent in the present invention.
  • Figure 5 is an initialization process of the mapping support module
  • Figure 6 is a mapping instance generation process
  • Fig. 7 exemplarily shows a TData correspondence with a TType of a mapping instance
  • Fig. 8 exemplarily shows attributes of a mapping instance according to the present invention.
  • the mapped scripting language is referred to as "heterogeneous scripting language", and the mapped mapping variable and the scripting language in which the mapping function is located are referred to as "host scripting language”. That is, the host script language is the main scripting language used for normal debugging in this system environment. Any scripting language that is different from the current host script language and resides in the system under test for debugging is a heterogeneous scripting language. Because of heterogeneity, there is a need to implement operational mapping across languages.
  • the mapping host script interpreter in the present invention is equivalent to the C interpreter in Tornado, and the script interpreter (such as Python, or Ruby, or TCL) providing the debugging base library in the present invention is equivalent.
  • the TCL interpreter in Tornado In the Tornado technology system, variable scripting and reading and function scripting calls (ie mapping) for C/C++ are jointly performed by Tornado Shell, Target Server, and Agent in the target machine, but in the present invention. , is to achieve the function of the three in the target machine, so that the test control and the code under test are in an execution body.
  • mapping entities for implementing mapping exist in the host scripting language.
  • the host scripting language can be a CSE language, but is not limited to this.
  • the system debugging capability can be greatly enhanced by the functions of database interface, file operation interface and XML parsing service provided by Python. Because the various modules in the heterogeneous scripting language are mapped and can be directly called by the host scripting language, cross-language monthly service calls can be implemented.
  • mapping support module of the present invention can be applied to a target system generated by the C/C++ language development, and the C/C++ variables and functions in the system are mapped to the host script system to generate a mapping variable having the same name as the C/C++ variable and the function.
  • mapping function and then manipulate the mapping variables in a script mode, you can achieve the following functions:
  • mapping function Converting a type of mapped variable to another type of mapped variable, that is, forcing a type conversion.
  • mapping entities including mapping variables and mapping functions
  • the present invention implements a commissioning mode equivalent to writing C/C++ code using a script.
  • mapping for heterogeneous scripting languages is similar to the above mapping for C/C++. It also includes variables and functions in heterogeneous scripting systems. It maps to the host script system and becomes a mapping variable and mapping function. The same implementation includes reading variables and writing. Mapping operations such as variables and calling functions.
  • variable container is essentially a class object in the host scripting system that exists in the mapping support module in the host scripting system. Define a variable container class in the host script system
  • variable container is the instantiated object of this TContainer class. But unlike regular class objects, the variable container is a class object with special functions. These functions include:
  • Variable containers can be nested in layers. Because the mapped variables (such as struct defined in C/C++) can be layered, a tree structure with a layer-to-layer relationship is formed. This invention uses a variable container tree to describe this tree relationship. Each node on the tree is a variable container. The variable container can contain one or more variable containers of the next level to construct the layer attribution. Tree relationship.
  • the expression of the assignment statement can be compatible with both strong and weak types.
  • a mapping variable with a variable container property has an automatic, implicit steering function depending on the context in which it is used in the host scripting system. For example, a map variable is used as an operator in mathematical operations, and it automatically reads the meaning of the value it represents. As another example, if the mapping variable is printed out, its string representation is taken. For another example, when a mapped variable is called as a function, it is called in a specific format (for example, a function mapped from C/C++, the calling format is cdecl, stdcalK thiscall, etc.).
  • variable container represents an entity (variable or function) in a heterogeneous system (heterogeneous C/C++ system or heterogeneous scripting system) that can be implemented when it is passed in an assignment statement or in a function parameter.
  • heterogeneous system heterogeneous C/C++ system or heterogeneous scripting system
  • variable container is used for mapping expressions. It is expressed in a manner close to the statement of the language being mapped. For example, when mapping C/C++ variables and functions, related mapping operations (such as: reading and writing variables and calling functions) should be similar in expression, C language style, and when the variable container is used to describe the heterogeneous scripting language Python When variables and functions, the read-write mapping variable and the calling mapping function are similarly expressed in Python.
  • mapping variables and mapping functions are represented by TData class instances.
  • TData class inherits from TContainer, so both the map variable and the map function have variable container properties.
  • TData adds several attributes indicating the characteristics of the mapping entity to the TContainer definition, such as who the mapping entity belongs to, that is, the Owner attribute of TData, and the data type of the mapping entity, that is, the DataType attribute of TData.
  • An instance of the TType class is possible.
  • the TType class definition is used to indicate the data type of the mapped entity. For example, create an int variable mapped from a C/C++ system, indicating that its type is a 4-byte integer type.
  • TType also describes class, struct, union, etc. type of data.
  • TType also defines function types, including function prototype definitions for styles such as cdecl and stdcalK thiscall.
  • mapping variable and the mapping function there is also a collection for accommodating mapping variables and mapping functions, which is also a variable container, which is referred to as a "heterogeneous set container" in the present invention.
  • the heterogeneous container is an instance of the TDataSet class, and the TDataSet class inherits from the TContainer class, so the heterogeneous container also has variable container properties.
  • Heterogeneous container is used to describe an abstract collection of mapped heterogeneous systems, including heterogeneous C/C++ systems and heterogeneous scripting systems.
  • the TDataSet inherits all the attributes of the TContainer and attaches several attributes that represent the characteristics of the mapped system, such as what is the system being mapped (for example, C/C++ or Python), and the relevant configuration required to implement the mapping, such as : Whether to generate a mapping entity for a constant, whether the enumeration value is 2 bytes or 4 bytes.
  • heterogeneous system heterogeneous C/C++ system or heterogeneous scripting system
  • the variables and functions in a heterogeneous system are mapped to the host scripting system and become an entity in the scripting system. It is required to use a variable container, a heterogeneous set container, to accommodate all of these mapped entities.
  • mapping from the mapped language ( / ++ 3 ⁇ 4 heterogeneous scripting language)
  • the body mapped variable or mapping function
  • mapping function as well as the dynamically created new mapped variable
  • the assignment style is consistent with the mapped language only if the map variable is assigned as a member of a heterogeneous set container.
  • a heterogeneous set container is used as a root node, and one or more mapping entities are stored under it to form a tree set, which is referred to as a "variable container tree" in the present invention.
  • the variable container tree can have only one layer or multiple layers.
  • a heterogeneous set container only saves the primitive type of mapped entity, there is only one layer; and when the heterogeneous set container holds the mapping variable of the composite data (such as class, struct or union data in C/C++, or heterogeneous There are multiple layers of class objects in the script system.
  • Each node of each layer is an instance of TContainer class, and thus has a TContainer attribute), and the number of child nodes is consistent with the name of each layer of the child node and the mapped composite data, which enables the sub-members of each layer to accurately describe
  • the mapped variables when the sub-members are read and written layer by layer, the number of child nodes of the variable, the sub-members of each layer node, the names of the sub-layer members and the data types are consistent before and after the mapping.
  • variable container tree because the variable container holding the mapped entity must be a heterogeneous set container, the heterogeneous set container can only be in the root node of the variable container tree.
  • Creating an empty heterogeneous container can be packaged into a scripted API (application programming interface) call. For example, define the newVarContainer function in the host script system to create an empty heterogeneous container for a C/C++ system or a Python system. .,
  • Vc newVarContainer("C/C++"); II Create a C/C++ Heterogeneous Container
  • Vc.varl MapCInt(7); II Create a mapping variable of type int, assign initial value 7 print(vc.varl); // value should be 7
  • Vc.var2 MapCString(" Another string”); II Create char[] mapping variable
  • vc is a heterogeneous set container. It is itself a variable container, which contains mapping entities such as iValue, struValue, sum, varl, var2, etc. These mapping entities are all variable containers. Since struValue is a struct structure, there are two sub-members, member 1 and member 2. These two sub-members are both TData objects and variable containers, which are hung under the struValue mapping variable. Here, "hanging” is a kind of retrieval pointing, indicating that a link points to a relationship, and also implies a master-slave derivation relationship. The expression “vc.stmValue.member2,” is the second sub-member. It can be seen that the above tree with vc as the root node is nested by the property support layer of the variable container.
  • the operation of the sub-attributes of the variable container can support the following three kinds of operation steering:
  • Vc.varl 8; II turns to implicit call vc.setValue(,varr,8)
  • the first parameter passed to getValue and setValue above is nil, which means that the mapping variable itself is read or assigned; if it is not nil, it means that the specified member of the mapping variable is read or assigned. For example, in the above example, adding the statement vc.varl .getValue(nil) , the value is 8, which is equivalent to vc.getValue(,varr).
  • Vc.var5->memberl 17; ⁇ turn to call vc.var5.setPoint(,memberr, 17) print( vc . var5 ->member 1 ); ⁇ turn to call vc.var5.getPoint(, member ) due to the above
  • the three operations on the sub-members of the mapping variable can be automatically turned into specific method calls under the mapping entity, which ensures that the mapping operation is expressed as much as possible in the style of the mapped language. Because the same operation (such as reading and writing child members, accessing array members) has different meanings in different languages, and the same operation has a clear meaning when running in the host script system, the native operation method of the host scripting language cannot be directly used for mapping. The data object coming over. However, after the implicit steering, a dedicated implementation can be provided in the steering function.
  • variable assignment in the host scripting language is different from the variable assignment in the C/C++ language.
  • C/C++ variable assignment is described in the host scripting language, and the actual implementation assignment is With the help of the steering function.
  • Assignment is specifically implemented in the steering function for C/C++ language specifications.
  • the steering function is specifically assigned to the specification of the heterogeneous function.
  • C/C++ is a strongly typed style language, but host scripting languages, like regular scripting languages, are a weakly typed style language.
  • the data type of the variable of the former (strongly typed language) is determined when the code is compiled, and the data type of the variable does not change dynamically during dynamic operation.
  • the latter is a dynamic data type, and the data type of the variable changes at any time during the running process. For example, run the following statement in a host scripting language (such as the CSE language):
  • varl is the mapping variable (that is, the TData class instance)
  • varl becomes the int type variable of the host scripting language
  • val is no longer Is a class instance, and is no longer a mapping variable, and the value of the original mapping variable is still 7.
  • varl becomes the float type variable of the host scripting language.
  • the present invention places the mapping variable under the variable container. Because the assignment to the variable container sub-member can be redirected to the setValue method call, it can be assigned in the C language style in the setValue call. E.g:
  • Vc.varl 8; ⁇ Steer to implicit call vc.setValue(,varr,8)
  • mapping variable is placed in the variable container, and the default is assigned in C style, and the variable assignment outside the variable container can still maintain the dynamic data type style of the host scripting language.
  • mapping variable under the variable container maintains the strong type assignment style, it will also bring inconvenience to the commissioning work.
  • a mapping variable named var is temporarily created. This mapping variable is not used when the use case ends.
  • the mapping variable named var exists in the variable container (it is the pointer type variable left after the previous use case is executed). If the assignment still maintains the strong type style, it is easy to cause problems, for example: II Test Case 1 Statement
  • Vc.var MapCInt(3); II At this point, vc.varl is still "int *,, type, pointer value is 3
  • vc.var MapCInt(3)
  • vc.var is an int type variable with a value of 3, but in fact this variable is of type "int *".
  • the host scripting system can provide an API to delete the child members specified under the variable container.
  • the API can be delete VcAttr.
  • mapping entity has different meanings in different usage environments. For example, sum is a cdecl-style mapping function, run the following script:
  • the first line above looks at the description value of the mapped entity (usually used for printouts, allowing the debugger to see what the entity is at a glance), the second line is a function call in C style, and the third line is looking at the mapping entity. Use as a numerical value.
  • the host scripting language kernel is first required to recognize the context in which the current variable container is located. For example, if the mapping entity is used in addition, subtraction, multiplication, and division, the system automatically calls the map entity's getValue method to extract the value it represents.
  • the third line of script in the above example reflects this situation.
  • mapping entity sub-members In addition to the system being able to capture read and write operations for mapping entity sub-members as described above, the present invention requires the host scripting language to recognize the following four contexts and implement implicit steering:
  • mapping entity If the mapping entity is used directly as a function call, then the mapping entity will be interpreted as a mapping ⁇ ) number, the current operation will implicitly redirect to the _call-method call of the object, and the mapped language will be implemented in the -call method.
  • mapping ⁇ mapping ⁇
  • mapping entity If the mapping entity is used to fetch its own description value, for example in a print statement, the current operation will implicitly redirect to the -str-method call of the mapping entity.
  • mapping entity If the mapping entity is used to retrieve its own representation value, for example in the repr function, the current operation will implicitly redirect to the -repr-method call of the mapping entity.
  • the mapping entity is used to transfer to the -call_ method of the entity when the function is called.
  • the call-method implementation should accurately simulate how the function works in the mapped language.
  • the first step is to identify the incoming parameter. If the incoming parameter is a mapped entity, it will automatically take the value it represents to suppress it. In the process of taking its value, it should also check whether the type of the incoming parameter matches against the function prototype. If it does not match, it should report an error. If the called mapping entity is derived from the C++ language, you should also pay attention to the prototype declaration of the polymorphic function. Because of multiple functions with the same name, the number or type of parameters is not the same.
  • the present invention analyzes the incoming parameters one by one, and performs matching analysis with reference to a plurality of prototypes of the same name function. If the match is matched, select the function that matches it to call, if the match does not match Report an exception.
  • the push and pop methods of the simulation call should also be consistent with the style declared by the function (eg cdecl, stdcalK thiscall> fastcall, etc.).
  • mapping functions are mapped from a C/C++ system. After simulating the function call in the call- method, a value is returned, which has an exact meaning in the C/C++ system (for example, an int value). However, this return value cannot be used directly in the host script. According to the same mapping method, the return value is mapped to the host script system and becomes a mapping variable in the host script system before it can be used.
  • the self-description value is different from the expression value.
  • the former takes the description value only for browsing to view the purpose, while the latter takes the representation value to obtain a textual description of the object without loss.
  • This textual description can be generated back to its own data after being calculated by its own scripting language.
  • the Python language run the expression "eval(repr(100)), and get the int data with a value of 100, while running the expression "eval(repr("100")))
  • the descriptive value is consistent with the meaning of the Python inline function "str”.
  • the "representation value” described in the present invention is consistent with the meaning of the Python inline function "repr", and will not be explained in detail herein.
  • mapping entity takes the representation value automatically to the -repr-method call of the entity. This rule is only supported in heterogeneous scripting language mapping. C/C++ mapping is not supported because there is no corresponding "representation value" in C/C++ language. "the concept of.
  • Automatic management of variable life cycle is a feature commonly supported by scripting languages.
  • the principle is to record the number of citations for each managed data.
  • the number of references is set to 1.
  • the number of references is incremented by 1. If an object no longer uses the object, the number of references is decremented by 1. If the reference count for an object drops to 0, the object is no longer used, and the system immediately releases the resources it occupies.
  • the present invention provides two types of mapping support, one is to map variables or functions from a C/C++ system to a host scripting system, and the other is to map variables or functions from a heterogeneous scripting system to a host scripting system.
  • the heterogeneous scripting system itself supports the automatic management of the variable life cycle, and maps to the instance of the host scripting system, the life cycle of the mapping entity is naturally managed automatically according to the conventional programming method.
  • C/C++ does not have the ability to provide automatic lifecycle management for all data types, special mapping support for variables and functions in C/C++ is required. After the mapping is implemented, it is guaranteed to use the host script to read and write C/C++ variables and call C/C++ functions.
  • variable space ie: Spaces corresponding to C/C++ language variables are not automatically managed. If the manual release to each release is undoubtedly cumbersome, the design efficiency of the test case will be greatly reduced, and the code quality of the test case will be lost.
  • the present invention stipulates that the memory block occupied by each mapping variable has its owner, that is, the Owner attribute is set in the TData class.
  • the usage status is recorded by the "reference counting" method.
  • the mapped entity no longer uses the block memory, the resources it occupies are released by itself.
  • the test host 1 includes a test shell 11 for initiating commissioning commands and a platform for development and testing.
  • the test host can use a personal desktop system (such as Windows, Linux, etc.).
  • the test case 11 can be one of the executable programs.
  • the target machine 1 is usually the board being tested, or a simulation program.
  • a Test Agent 21 resides in the target 2.
  • the test agent 21 can be a scripting language system.
  • the type of the script language is not limited as long as the mapping rule defined by the present invention can be satisfied.
  • the symbol table and type table of the program under test are included in the test agent 21 of the target machine 2. The symbol table and type table will be described later.
  • the target machine 2 can share the same device as the test host 1, such as a computer.
  • the program under test is an exe program
  • the test host is also an exe program. Both can run on the operating system of one machine (such as a multi-process platform such as Windows).
  • the test housing 11 of the test host 1 has a communication connection with the test agent 21.
  • the communication method for this connection can be shared memory communication (for the case where the target computer shares the same computer with the test host, TCP/IP communication, or other forms such as serial communication).
  • the test agent 21 includes a script system 211 and a communication unit 212.
  • the communication unit 212 is responsible for processing the above communication connection between the test agent 21 and the test casing 11 of the test host 1.
  • the scripting system 211 includes an inline debugging support module 2111 and a mapping support module 2112.
  • the embedded debug support module 2111 is a collection of conventional commissioning application programming interfaces (APIs) that provide functions such as resetting the target, starting or stopping a task, setting breakpoints, and deleting breakpoints.
  • the mapping support module 2112 is used to implement the function of mapping C/C++ language variables and functions in the system under test to the script system. After the mapping is completed, the script system 21 1 generates mapping variables and mapping functions having the same names as the variables and functions of the C/C++ language.
  • the target machine 2 is subjected to initialization processing.
  • the test host 1 starts the program of the command interpretation module
  • the target machine 2 starts the program under test (S501).
  • the target machine 2 initializes the script system 211 contained therein, including setting the relevant configuration of the test agent 21 (S502).
  • the table generation unit (not shown) of the test agent 21 extracts information related to the mapped variables/functions from the GDB or PDB debug database generated by the software of the target machine 2 after the last compilation thereof. , a symbol table and a type table (to be described later) are generated and recorded in the test agent 21 (S503).
  • the scripting system 21 of the test agent 21 maps the symbol table and the type table to a global variable container (i.e., a heterogeneous set container) (S504).
  • the symbols of the type table and the symbol table are mapped to the variable container according to the predetermined script (S505).
  • This operation describes the variables and functions in the program under test as mapping entities (that is, script TData class objects) in the script system. Since converting all symbols results in wasted CPU and memory resources, in accordance with one embodiment of the present invention, the symbols are not converted all at once, but only for testing purposes. For example, when running a test script, the script contains which mapped variables and functions, dynamically convert those variables or functions, or the user can determine the rules to convert on demand, for example, all externally defined symbols are not mapped.
  • test host 1 the user operates on the transmitted code using a script file similar to the C/C++ language.
  • the command in the test shell 11 causes the interpretation module to interpret the user's input and issue the corresponding test command. It is transmitted to the test target machine 2 and runs in its script system 21 1 to obtain the test run result obtained by encoding the code.
  • the test run result can be fed back to the test host 1 and displayed to the user.
  • the test script can be written online, the measured variable can be visually viewed or modified, and the measured function can be called, the test result can be immediately seen, and the test can be improved immediately, thereby improving the efficiency of the test.
  • the pointer is consistent with the C/C++ language style, including the "->" operator usage, such as “pStmct->Memberl” to describe a structure pointer to a member; also includes rules for pointer movement, such as "pint +2" moves the int pointer backward by 2, and the actual pointer will offset 2 * sizeof(int) bytes.
  • a Struct type defines two child members, Member 1 and Member2. Accessing the type variable, the first child member of StmVar, is described as " StruVar.Member 1 ".
  • the host scripting language should preferably meet the following requirements:
  • Scripting systems that meet the above requirements are available from the prior art, such as Python, Ruby, etc., which support the addition or deletion of variable definitions or function definitions online.
  • the symbol table and data type table of the program under test are resident in the test agent 21 of the target machine 2. These two tables will directly support the implementation of the mapping rules specified by the present invention.
  • the mapping method of the present invention relies on the collection and analysis of various symbols of the target system and their type information. Debugging the database by the compiler during compilation Generated, for example, during Visual C/C++ compilation, the compiler extracts relevant information from the source code to generate a PDB file as intermediate format data. GCC also compiles the GDB debug information of the intermediate format data into the target program at compile time.
  • the mapping support module residing on the target machine will further analyze the intermediate format data (PDB/GDB) to generate a symbol table and a type table.
  • the debug database format generated by different C/C++ compilers is not the same.
  • the invention achieves the unification of different formats by generating the type table and the symbol table.
  • the type table records the various types defined by the system under test. These types must include: primary type information, subtype information, and occupancy. Bytes.
  • Table 1 is an example of a type definition format:
  • the symbol table records the address value of a variable or function and its type ID.
  • the symbol address has two forms, which can be either an absolute address or a relative address. For example, when accessing a local variable or passing in a parameter, the offset value relative to the current top position is used. For another example, a variable exists in another variable space, and its address is also expressed by the address of the other variable plus an offset.
  • mapping entity There are two ways to source symbols, one is from another mapping entity, and the other is from an absolute address.
  • absolute address is a general way of describing variables or functions.
  • the former is often used when the same memory space is treated as multiple types of variables, such as forced type conversion, 'is an array of strings An offset is treated as an integer type variable.
  • the above type table and symbol table are organized according to a specific format and reside in the system under test.
  • Each symbol in the symbol table can be mapped to the host script system and become a mapping entity, that is, an instance of the TData class in the script system.
  • one aspect of the present invention is to map on demand rather than all at once, so that variables and functions are mapped to script objects only when they are used.
  • the TType class object corresponds to the type table
  • the TData class object corresponds to the symbol table.
  • the instantiated data defined in the TType class object contains the following information: The type unique identifier, type main category information, type subcategory information, type size.
  • Each symbol is mapped to the instantiated data defined by the TData class and contains the following information: The type ID of the symbol, the source of the symbol, the offset from the source, whether the memory is automatically freed.
  • the mapping process of the table contents is performed as shown in Fig. 6.
  • the script system 211 finds the required symbol (variable or function) information from the symbol table, such as the symbol name, the type ID of the symbol, and the symbol address (S601).
  • the script system 211 finds whether the corresponding type has the generated TType class object by using the type ID. If not, the TType class object is created first, that is, by defining a TData or TType class object, calling the class definition constructor to create the class object. An instance (S602).
  • a TData class object of the mapped symbol is created according to the source of the symbol, the associated TType object, the address offset, and whether the memory is automatically released (S603).
  • the corresponding TType object When the created mapping entity includes mapping variables and mapping functions, the corresponding TType object must first indicate the type information. When the items in the type table are converted into TType class instances, the original type information table is no longer useful, and the occupied resources can be released, and the newly generated TType class instances form a new table, that is, the TType type table. Both map variables and map functions are instances of the TData class. As shown in Figure 7, each TData class instance uses the type ID ( Data type ) of the symbol to indicate which type in the TType type table it uses.
  • objects of the TType class may be nested references.
  • Some composite types such as stmct/union/pointers contain subtypes, and the same subtype may be referenced by multiple composite types. Therefore, when creating each TType object, other types involved in that type are also created at the same time.
  • mapping data as a script class object also supports the automatic application and release of the resources it involves.
  • the script system 21 creates a mapping variable buff, which is an array of strings of length 24 bytes. At this time, the script system 21 automatically requests the memory occupied by the target machine 2, including the buff variable as an example of the script TData class.
  • the former type of space is referred to as a script instance space
  • the latter type of space is referred to as a C/C++ instance space (referred to as a C instance space in this description).
  • the script instance space and the C instance space are not always applied or released at the same time.
  • the occupied space is statically allocated.
  • the mapping entity of the global variable should only release the script instance space at the end of the life cycle, and should not release the C instance space.
  • the script instance space of this variable and the C instance space should be applied or released at the same time.
  • this mapping variable a is treated as another type of mapping variable b, such as a mandatory type conversion in C language
  • a variable in the same address space is treated as another type of variable, then the variable b should be created.
  • the C instance space can be shared by multiple mapping variables, and only the mapping variables involved in the C instance space are released, and the C instance space is automatically released.
  • the C instance space used by the mapping variable needs to be tested together, and the flag can be modified if necessary.
  • the Autofree attribute is set for the mapping variable. The attribute is TRUE, indicating that the C instance space of the mapping variable is released with the release of its script instance space. Otherwise, the value of the attribute is FALSE, indicating that the C instance space is not released with the release of the script instance space. .
  • Figure 8 shows an example of a mapped entity.
  • this attribute includes: Yes No Auto Free Memory (Autofree), Symbol Source (Owner), Offset Address (Offset) relative to the source.
  • the attribute "whether the memory is automatically freed” is used to indicate whether the C instance space of the mapped variable is released along with the script instance space.
  • the "symbol source” is used to indicate the attribution object of the mapping entity, and its value can be either an absolute address value or another mapping entity.
  • the offset address relative to the source is used to indicate the offset of the starting address of the C. instance space used by the mapping entity relative to the spatial address indicated by its symbol source. Since the scripting language has the automatic lifecycle management feature, if the symbol source attribute indicates another mapping instance, the automatic management of resources can be realized when the same C instance space is shared by multiple mapping instances.
  • the operational steering required by the present invention includes the following items:
  • variable container When the variable container is directly used for function call, it implicitly redirects to the call-method call of this object;
  • variable container takes its own description value (as used in print and other statements), it implicitly redirects to the --str method call of this object;
  • variable container When the variable container is used to obtain its own expression value (as used in repr and other statements), it implicitly redirects to the -repr method call of this object.
  • these targets are defined in the variable container as functions of TContainer (such as getValue, setValue, getltem, setltem ⁇ getPoint;, setPoint - call -, "str", “repr”).
  • Python There are already some scripting languages that support similar implementations, such as the Python language.
  • the members of the read-write class object can be directed to the _getattr_ and -setattr_ii functions, respectively. You only need to add -getattr - a setattr to the two class methods in Python's related class definitions.
  • Read and write class members can capture and automatically jump.
  • Python also supports class objects as arrays. When reading and writing its children, it can automatically jump to the _getitem of the class pair and a setitem-method. If a call-method is defined for a class object in Python, then when the object is called as a function, it will automatically jump to the __call-method. The same is true for the description value and the representation value, as long as the -str_ and -repr methods are defined separately. Therefore, the Python language has been able to implement seven of the nine steerings required by the present invention. .
  • the host interpreter should be able to capture the automatic steering when interpreting the operation, and then trigger an automatic jump. This is a requirement for the ability to interpret the execution of the host interpreter kernel.
  • Heterogeneous script mapping is usually in the form of script modules.
  • the objects involved in mapping are also limited to the entities that can be provided by the mapped language at the module's crest level, including: variables (including class objects) and functions.
  • the content of heterogeneous script mapping includes three aspects:
  • mapping entity i) Implement mapping of basic type data specified by the heterogeneous scripting system, and support related operations for the mapping entity, including: create, release, read, assign, and function call.
  • the above three aspects involve the three mapping entities included in the heterogeneous script mapping, namely: basic type data mapping, class instance mapping, and script module mapping.
  • mapping entities are all TData class objects of the host script.
  • the TType class object records the TType instance data, thereby indicating the data type of the mapping entity in the mapped system.
  • the TData and TType structure definitions for heterogeneous script mapping should be consistent with the TData and TType used in the C/C++ mapping described earlier. If some attribute definitions are not used, for example, the attribute used to indicate whether the C instance space of the mapped instance is released with the script instance space is no longer used, then leave it alone.
  • Basic Type Data Mapping 'Common scripting languages such as Python, Ruby, and TCL have basic types such as integer (int), float (float), string (string), and function. These basic type data, as data in a specific format that exists in heterogeneous scripting systems, cannot be directly used as variables in the host scripting language. Otherwise, an error occurs in data access. The same type of data is in two heterogeneous systems, and its internal format is not the same. The purpose of basic type data mapping is to ensure that the same type of data is automatically converted when passed across languages.
  • the TType class instance is used to record information about each basic type in the heterogeneous script system, including type definition, type length, and so on. This information can be obtained through the API functions of the heterogeneous scripting system. For example, calling Python's inline function "type(obj)" can get the type of the specified variable, call the inline function "len(obj)” to get the length of the specified variable, and so on.
  • the TData class is used to express the mapping entity.
  • the TData class inherits from TContainer and is also a variable container.
  • the type of the mapping entity (the value of TType), the address of the entity object, and the like are also recorded.
  • the referenced object in the heterogeneous scripting system is incremented by one reference, which is implemented by calling the API provided by the heterogeneous scripting system.
  • the API for adding a reference in Python is Py-INCREF
  • the API for reducing one reference is Py-DEC EF. If the mapped entity is released, the reference of the corresponding mapped object is decremented by 1.
  • the operation of the mapping entity implements the specific function in the steering objective function by reading and writing the sub-member, reading and writing the array member, calling the entity, taking the self-description value, and the implicit steering function when taking the self-representation value.
  • specific operations for the mapped entity is achieved by calling the API of the heterogeneous script system.
  • the heterogeneous scripting system is Python
  • the mapping function is called and implicitly redirected to the call-method call.
  • the present invention calls the API provided by Python in the call-method to call the related function in the mapped system.
  • the API that calls a function in Python is PyObject— CallFunction
  • the API that calls the class method is PyObject_CallMethod.
  • Vc newVarContainer("PYTHON");
  • vc.ADict[3] "abc"; II implicitly redirected to the call: vc.ADict.setItem(3,"abc,,); print(vc.ADict[3]); II implicitly redirected to call: print (vc.ADict.getItem(3)); In the turn function setltem and getltem, call the API provided by Python to read and write the Python dictionary data.
  • a special Python class method call can be implemented by calling the Python API.
  • Vc newVarContainer("PYTHON");
  • vc.AObj MapPyInstace('ACkss,,argl,arg2); II Create class instance mapping entity vc.AObj. method 1(1 , 2); // Step 1: Execute vc.AObj .method 1
  • ⁇ Step 2 Dynamically generate an AObj.methodl mapping function
  • Step 3 Execute AObj .methodl (1 , 2)
  • each time its method is called a corresponding mapping function is dynamically generated, and when the mapping function is called, it automatically switches to the call method call of the mapping function.
  • the special call process of the corresponding class method of Python is implemented. That is, if the heterogeneous language is Python, the corresponding call is implemented in Python format. If the heterogeneous language is Ruby, the corresponding call is implemented in Ruby format. Of course, the result values of the calls are also automatically assembled into mapped variables.
  • the way to search for its members from a class definition is different.
  • the heterogeneous scripting language is Python, or Ruby or TCL, with this scripting system
  • Providing the API and the type format defined by the scripting language it is always possible to traverse which methods are defined under the specified class class and which class members are defined.
  • the Python language provides a "dir(namespace)" inline function that scans which objects are defined under the specified namespace, which objects are defined under the module, and which properties are defined under the class. These can be known by calling the dir function. Therefore, for a class object mapping entity, each time the method is called, the corresponding function definition can be dynamically obtained, and a mapping function can be dynamically generated.
  • the present invention uses heterogeneous scripting language mapping, which can greatly enhance the system's debugging capabilities. Mapping heterogeneous scripts to the host scripting language, on the one hand, enables cross-language function calls, 'on the other hand, it also reduces the learning threshold, because the mapping syntax masks the differences in the representation of heterogeneous languages.

Abstract

A mapping method for a software testing and its program testing system using the method. The program testing system includes a testing host (1) and a target machine (2), and the testing host (1) tests the program in the target machine (2) in which a mapping support module (2112) is included. The method includes: 1) the mapping support module (2112) generates a symbol table and a type list of a tested program according to the testing database obtained after the tested program is compiled; 2) the mapping support module (2112) maps the variable and the function in the type list and the symbol table to a variable container to generate the mapping variable and the mapping function operated by a host script system, in which the variable container is a class object of the script TContainer class. The tested target machine (2) also can selectively reside a heterogonous script system to enhance the testing ability. The variable and the function in the heterogonous script system can be mapped into the host script system to be the mapping variable and the mapping function, thereby the host script system is provided with the ability to cross-language call the testing service.

Description

程序调测系统中的映射方法和程序调测系统 技术领域  Mapping method and program commissioning system in program commissioning system
本发明涉及软件调试与测试领域, 特别涉及针对 C/C++语言开发环境 的软件调试与测试的调测系统及方法。 ' 背景技术  The invention relates to the field of software debugging and testing, and particularly relates to a debugging system and method for software debugging and testing of a C/C++ language development environment. ' Background technique
在軟件开发领域, 支持 VxWorks实时操作系统开发的 Tornado编程环 境是众多嵌入式编程语言中调测性能表现最佳的编程环境之一。 Tornado 测试命令解释模块工具支持脚本化的被测变量读写与被测函数调用, 功能 比较强大。 关于 Tornado的评细说明, 可参见 Wind River Systems, Inc.出版 的 "Tornado User's Guide (Windows Version)", V2.0 Edition 1。  In the field of software development, the Tornado programming environment supporting VxWorks real-time operating system development is one of the best programming environments for debugging performance in many embedded programming languages. The Tornado test command interpretation module tool supports scripted variable read and write and function call calls, and is more powerful. For a detailed description of Tornado, see "Tornado User's Guide (Windows Version)", V2.0 Edition 1, by Wind River Systems, Inc.
尽管 Tornado 测试命令解释模块功能强大, 但由于使用两种解释器即 C解释器和 TCL解释器, 并且由于驻留在目标机服务器中的只有符号表, 没有类型表, 因而使它的调测能力受到不少限制, 主要包括:  Although the Tornado test command interpretation module is powerful, it uses two interpreters, the C interpreter and the TCL interpreter, and because it only has a symbol table that resides in the target server, there is no type table, so its debugging capability. Subject to many restrictions, mainly including:
1 ) 由于变量与函数的类型表未驻留, 难以支持针对复令类型的操作; 1) Since the type table of variables and functions does not reside, it is difficult to support operations for the type of the repeat;
2 ) 用于调测控制的 C解释器与 TCL解释器驻留于测试主机端, 导致' 调测控制与被测代码有紧耦合交互的情况下无法支持调测; 2) The C interpreter and TCL interpreter used for the commissioning control reside on the test host, which causes the commissioning control to be unable to support the commissioning when it is tightly coupled with the code under test;
3 )变量读写与函数调用与 if、 else等控制分别在两个脚本语言内实现。 因此, 在测试命令解释模块运行调测指令时, 经常要在 C解释器与 TCL解' 释器之间切换, 很烦瑣。 尽管 C解释器可内嵌一个 API来调用 TCL脚本, TCL脚本也可内嵌 C解释器, 但在使用上仍然不便,.而且运行效率低。  3) Variable read and write and function calls and if, else, etc. are implemented in two scripting languages respectively. Therefore, when the test command interpretation module runs the commissioning command, it is often cumbersome to switch between the C interpreter and the TCL solver. Although the C interpreter can embed an API to call TCL scripts, the TCL script can also embed the C interpreter, but it is still inconvenient to use, and it is inefficient.
4 )' 而且, 由于上述 3 ) 的原因, C解释器与 TCL解释器属两套系统, 难以在语法和语义级别进行融合, 增加了使用者的学习负担, 也不利于调 测功能的扩展。  4)' Moreover, due to the above 3), the C interpreter and the TCL interpreter are two sets of systems, which are difficult to integrate at the grammar and semantic levels, which increases the user's learning burden and is not conducive to the expansion of the debugging function.
第 4代白盒测试方法综合了软件白盒测试的最佳实践, 反映了现今白 盒测试的发展方向。 为了符合第 4 代白盒测试方法的要求, 需要对基于 Tornado技术的调测体系做如下改进:  The 4th generation white box test method combines the best practices of software white box testing, reflecting the development direction of today's white box testing. In order to meet the requirements of the 4th generation white box test method, the following adjustments to the Tornado technology-based commissioning system are required:
1、 引入 种支持即时调测的体系, 测试控制与被测代码应处于同一个 执亍体内。  1. Introduce a system that supports real-time commissioning. The test control and the code under test should be in the same body.
2、 使用一种脚本语言, 既描述针对被测 C/C++变量与函数的控制(类 似于 Tornado Shell中的 C解释器),也描述测试控制(类似于 Tornado Shell 中的 TCL解释器) , 使这两类描述维持近似的语言风格。 ' 发明内容 本发明为了改善当前软件开发中普遍存在的调测能力不足及测试效率 欠佳的问题, 并满足第 4代白盒测试方法的要求, 将相关的测试方法论应 用到 C/C++语言开发领域, 而提出一套编程语言映射技术, 即: 将 C/C++ 语言的变量操作、 函教操作映射到一个脚本语言系统, 将该脚本语言系統 驻留于被测系统中, 使这些脚本语言既实现脚本化的测试描述, 又能直接 操控被测系统中的变量、 函数等, 并使这种测试描述与 C/C++的语法规则 尽可能保持一致。 2. Use a scripting language that describes both the control of the C/C++ variables and functions being tested (similar to the C interpreter in the Tornado Shell) and the test control (similar to the TCL interpreter in the Tornado Shell). These two types of descriptions maintain an approximate language style. ' Invention content The invention aims to improve the problem of insufficient commissioning capability and poor test efficiency which are prevalent in current software development, and meets the requirements of the fourth generation white box test method, and applies the relevant test methodology to the field of C/C++ language development. A set of programming language mapping techniques is proposed, namely: mapping the variable operations and correspondence operations of the C/C++ language to a scripting language system, and the scripting language system resides in the system under test, so that the scripting languages are both scripted. The test description, and can directly manipulate the variables, functions, etc. in the system under test, and make this test description as consistent as possible with the C/C++ grammar rules.
另夕卜,对于大型软件测试,经常需要借助一个功能强大的脚本语言(如 Python, Ruby, TCL等) , 本发明的映射技术同样能够以尽可能近似的语 法规则 (近似 Python, 或 Ruby, 或 TCL ) ,描述这种脚本语言提供的功能接 口, 在调测中直接调用。  In addition, for large software testing, often with a powerful scripting language (such as Python, Ruby, TCL, etc.), the mapping technique of the present invention can also be as close as possible to the grammar rules (approx. Python, or Ruby, or TCL), describes the functional interface provided by this scripting language, which is called directly in the commissioning.
并且, 本发明还引入一种支持即时调测的体系, 使测试控制与被测代 码同处于一个执行体内。 本发明使用一种脚本语言既描述针对被测 C/C++ 语言的变量与函数的控制, 也描述测试控制,,并保持这两类描述具有相同 风格。  Moreover, the present invention also introduces a system that supports real-time debugging, so that the test control and the code to be tested are in the same execution body. The present invention uses a scripting language to describe both the control of variables and functions for the C/C++ language being tested, as well as the test control, and to keep both types of descriptions of the same style.
根据本发明, 提供了一种程序调测系统, 包括测试主机和目标机, 所 述测试主机对所述目标机的程序进行调测。 其中, 所述目标机中包括映射 支持模块, 所述映射支持模块包含变量容器; 所述变量容器是脚本的'' TContainer类的类对象, 所述被调测的 C/C++目标程序系统中的变量和函' 数被映射成所述变量容器中的映射变量和映射函数, 当宿主脚本语言中描 述映射变量或映射函数的操作时, 所述映射变量与所述映射函数与被测试 程序的变量和函数具有相似的表达; 通过所述变量容器, 利用所述宿主脚 本语言对所述映射变量的操作被转向到所述被调测的 C/C++目标程序系统 中相应变量的操作, 所述宿主脚本语言对所述映射函数的操作转向到所述 被调测的 C/C++目标程序系统中相应函数的操作。  According to the present invention, there is provided a program commissioning system comprising a test host and a target machine, the test host commissioning a program of the target machine. The target machine includes a mapping support module, and the mapping support module includes a variable container; the variable container is a class object of the script's TContainer class, and the debugged C/C++ target program system The variable and the function 'number are mapped into a mapping variable and a mapping function in the variable container, and when the operation of the mapping variable or the mapping function is described in the host scripting language, the mapping variable and the mapping function and the variable of the program under test And a function having a similar expression; by means of the variable container, the operation of the mapping variable using the host script language is diverted to the operation of a corresponding variable in the C/C++ target program system being debugged, the host The operation of the mapping language by the scripting language is directed to the operation of the corresponding function in the C/C++ target program system being debugged.
根据本发明的另一方面, 提供一种应用于程序调测系统中的映射方法。' 所述程序调测系统包括测试主机和目标机, 所述测试主机对所述目标机中 的程序进行调测, 在所述目标机中包含映射支持模块, 所述方法包括: 1 ) 所述映射支持模块^^据被调测程序被编译后的调试数据库产生所述被测试 程序的符号表和类型表; 2 )所述映射支持模块将所述类型表、 符号表中的 变量和函数都映射至变量容器中, 生成由宿主脚本系统可操作的映射变量 和映射函数, 其中, 所述变量容器是脚本 TContainer类的类对象。  According to another aspect of the present invention, a mapping method applied to a program commissioning system is provided. The program commissioning system includes a test host and a target machine, and the test host performs debugging on a program in the target machine, and includes a mapping support module in the target machine, the method includes: 1) The mapping support module generates a symbol table and a type table of the tested program according to the debug database compiled by the commissioning program; 2) the mapping support module sets the variables and functions in the type table and the symbol table Mapping to a variable container, generating a mapping variable and a mapping function operable by the host script system, wherein the variable container is a class object of the script TContainer class.
通过本发明的系统和方法, 可以将对软件调测的运算处理分配到测试 主机和目标机。 由测试主机处理被测程序的测试例的脚本编写、 脚本下发 (下发至目标机的宿主脚本系统) 以及测试中的输出信息显示。 驻留在目 标机的脚本系统完成对被测端 C/C++语言变量以及函数的映射和控制,即, 将 C/C++语言的变量操作、 函数搡作映射到一个脚本语言系统(即宿主脚 本系统) , 使这个驻留于被测系统中的脚本语言, 既实现脚本化的测试描 述, 又能直接操控被测系统中的变量、 函数等。 With the system and method of the present invention, arithmetic processing of software commissioning can be assigned to the test host and the target machine. The scripting of the test case of the test program is processed by the test host, the script is issued (the host script system that is delivered to the target machine), and the output information is displayed during the test. Residing in the destination The scripting system of the standard machine completes the mapping and control of the C/C++ language variables and functions of the tested terminal, that is, mapping the variable operations and functions of the C/C++ language to a scripting language system (ie, the host scripting system). This scripting language, which resides in the system under test, not only implements scripted test descriptions, but also directly manipulates variables, functions, etc. in the system under test.
本发明的映射技术有效地提升了软件产品的调试能力与白盒测试能 力。 与 Tornado 测试命令解释模块相比, 本发明通过在测试代理的脚本系 统中包含了调测模块和映射模块, 使得测试控制与被测代码都在一个系统 中。 调测控制与被测代码耦合更紧密。 紧耦合交互不会有两个系统因通信 连接带来的时延, 并且测试控制过程的复杂性也被降低了。  The mapping technique of the present invention effectively improves the debugging capability of the software product and the white box testing capability. Compared with the Tornado test command interpretation module, the present invention includes the commissioning module and the mapping module in the scripting system of the testing agent, so that both the test control and the tested code are in one system. The commissioning control is more closely coupled to the code under test. Tightly coupled interactions do not have the latency of the two systems due to communication connections, and the complexity of the test control process is also reduced.
综上所述, 本发明的优点在于: 通过釆用一种映射技术, 使调测脚本 可以直接控制被测系统的行为。 由于脚本的在线定义、 在线执行的特性, 大大提高了调测脚本的开发效率, 有力保证了第 4代白盒测试方法要求的 在线测试与灰盒调测的工具化实现。 相对于 Tornado 测试命令解释模块, 调测效率得到提高。 另外, 测试脚本不必经常在两种脚本语言之间切换, 数据传递与控制传递更加自由。 而如上所述, Tornado系统中 C解释器与 TCL解释器难以在语法语义级别融合。  In summary, the advantages of the present invention are: By using a mapping technique, the commissioning script can directly control the behavior of the system under test. Due to the online definition of the script and the online execution characteristics, the development efficiency of the commissioning script is greatly improved, which effectively guarantees the instrumentation implementation of the online test and gray box debugging required by the 4th generation white box test method. Compared to the Tornado test command interpretation module, the commissioning efficiency is improved. In addition, test scripts do not have to be frequently switched between the two scripting languages, and data transfer and control transfer are more free. As mentioned above, the C interpreter and the TCL interpreter in the Tornado system are difficult to integrate at the syntax and semantic level.
同时, 本发明的方法还能够保证测试描述尽可能地与 C/C++的语法规 则保持一致。 另外, 对于大型软件测试, 经常需要借助一个功能强大的脚 本语言 (如 Python、 Ruby, TCL等) , 本发明的方法同样尽可能以近似的 语法规则(近似 Python, 或 Ruby, 或 TCL )描述这种脚本语言提供的功能 接口, 在调测中直接调用。  At the same time, the method of the present invention can also ensure that the test description is as consistent as possible with the C/C++ language regulations. In addition, for large software testing, often with a powerful scripting language (such as Python, Ruby, TCL, etc.), the method of the present invention also describes this as much as possible with approximate grammar rules (approx. Python, or Ruby, or TCL). The function interface provided by the scripting language is called directly in the commissioning.
因此, 本发明可提升嵌入式软件的调测能力, 降低测试表述的学习门 槛, 并大幅提升调测脚本的开发效率。 附图说明  Therefore, the invention can improve the debugging capability of the embedded software, reduce the learning threshold of the test expression, and greatly improve the development efficiency of the commissioning script. DRAWINGS
图 1显示了现有的 Tornado技术的逻辑结构;  Figure 1 shows the logical structure of the existing Tornado technology;
图 2显示了本发明的程序调测系统的逻辑结构;  Figure 2 shows the logical structure of the program commissioning system of the present invention;
图 3显示了本发明的程序调测系统的組成框架;  Figure 3 shows the composition of the program commissioning system of the present invention;
图 4是本发明中测试代理的层次结构; ·  Figure 4 is a hierarchical structure of the test agent in the present invention;
图 5是映射支持模块的初始化过程;  Figure 5 is an initialization process of the mapping support module;
图 6是映射实例生成过程;  Figure 6 is a mapping instance generation process;
图 7示例性地显示了一个映射实例的 TData与 TType对应关系; 图 8示例性地显示了根据本发明的映射实例的属性。 具体实施方式 下面将结合附图详细说明用于软件调测的程序语言映射方法及应用该 方法的程序调测系统。 虽然以下将以 C语言为例进行说明, 但本发明的构 思与方案也可以用于其它语言的程序, 例如 C ++语言。 Fig. 7 exemplarily shows a TData correspondence with a TType of a mapping instance; Fig. 8 exemplarily shows attributes of a mapping instance according to the present invention. detailed description A program language mapping method for software commissioning and a program commissioning system to which the method is applied will be described in detail below with reference to the accompanying drawings. Although the C language will be described below as an example, the concepts and solutions of the present invention can also be applied to programs in other languages, such as the C++ language.
本发明中, 将被映射的脚本语言称为 "异构脚本语言" , 将映射后的 映射变量与映射函数所在的脚本语言称为 "宿主脚本语言" 。 即, 宿主脚 本语言是本系统环境下正常调测所使用的主脚本语言。 凡是与当前宿主脚 本语言不同、 并驻留到被测系统中服务于调测的脚本语言都是异构脚本语 言。 因为异构,' 才有跨语言实施操作映射的需求。  In the present invention, the mapped scripting language is referred to as "heterogeneous scripting language", and the mapped mapping variable and the scripting language in which the mapping function is located are referred to as "host scripting language". That is, the host script language is the main scripting language used for normal debugging in this system environment. Any scripting language that is different from the current host script language and resides in the system under test for debugging is a heterogeneous scripting language. Because of heterogeneity, there is a need to implement operational mapping across languages.
为便于清楚地理解本发明相对于 Tornado 的技术演进, 以下将在逻辑 上分析这两种技术方案, 然后比较两者的差异。 如图 1与图 2所示, 本发 明中的映射宿主脚本解释器相当于 Tornado中的 C解释器, 本发明中提供 调测基础库的脚本解释器(如 Python, 或 Ruby, 或 TCL )相当于 Tornado 中的 TCL解释器。 在 Tornado技术体系中, 针对 C/C++的变量脚本化读写 与函数脚本化调用 (即映射捧作 )是由 Tornado Shell、 Target Server, 以及 目标机中的 Agent共同完成的, 而在本发明中, 是在目标机中实现三者的 功能, 使得测试控制与被测代码处于一个执行体内。  To facilitate a clear understanding of the technology evolution of the present invention relative to Tornado, the following two logical solutions are logically analyzed and then the differences between the two are compared. As shown in FIG. 1 and FIG. 2, the mapping host script interpreter in the present invention is equivalent to the C interpreter in Tornado, and the script interpreter (such as Python, or Ruby, or TCL) providing the debugging base library in the present invention is equivalent. The TCL interpreter in Tornado. In the Tornado technology system, variable scripting and reading and function scripting calls (ie mapping) for C/C++ are jointly performed by Tornado Shell, Target Server, and Agent in the target machine, but in the present invention. , is to achieve the function of the three in the target machine, so that the test control and the code under test are in an execution body.
本发明中, 用于实现映射的映射实体 (包括映射变量与映射函数)存 在于宿主脚本语言中。 宿主脚本语言可以是 CSE语言, 但不限于此。 本发: 明的映射技术既支持针对 C/C++中变量与函数的映射, 也支持针对提供调 测基础库的异构脚本语言的映射。 这种映射主要集中在用于宿主脚本调用 其它基础库 (如 Python、 Ruby, TCL等) 的功能接口, 这些功能接口服务 于调测目的。 例如, 还可以在目标机中驻留一个异构脚本语言 Python。 借 助 Python提供的数据库接口、 文件操作接口、 XML解析服务等功能, 可 以大大增强系统调测能力。 因为异构脚本语言中的各种模块经映射后可被 宿主脚本语言直接调用, 从而可以实现跨语言月良务调用。  In the present invention, mapping entities (including mapping variables and mapping functions) for implementing mapping exist in the host scripting language. The host scripting language can be a CSE language, but is not limited to this. This presentation: The mapping technique supports both mapping of variables and functions in C/C++, as well as mapping to heterogeneous scripting languages that provide a debugging base library. This mapping focuses on the functional interfaces used by the host script to call other underlying libraries (such as Python, Ruby, TCL, etc.) that serve the purpose of debugging. For example, you can also host a heterogeneous scripting language, Python, in the target machine. The system debugging capability can be greatly enhanced by the functions of database interface, file operation interface and XML parsing service provided by Python. Because the various modules in the heterogeneous scripting language are mapped and can be directly called by the host scripting language, cross-language monthly service calls can be implemented.
本发明的映射支持模块可应用于由 C/C++语言开发生成的目标系统, 将该系统中的 C/C++变量与函数映射到宿主脚本系统中, 生成与 C/C++变 量与函数同名的映射变量与映射函数, 然后以脚本方式操作映射变量, 从 而可以实现如下功能:  The mapping support module of the present invention can be applied to a target system generated by the C/C++ language development, and the C/C++ variables and functions in the system are mapped to the host script system to generate a mapping variable having the same name as the C/C++ variable and the function. With the mapping function, and then manipulate the mapping variables in a script mode, you can achieve the following functions:
1 . 读变量  Read variable
2. 写变量  2. Write variables
3. 将某类型的映射变量转化成另一类型的映射变量, 即强制类型转换 以脚本方式操作映射函数, 可以实现如下功能:  3. Converting a type of mapped variable to another type of mapped variable, that is, forcing a type conversion. By manipulating the mapping function in a script mode, the following functions can be implemented:
1. 按 cdecl方式调用函数  1. Call the function by cdecl
2. 按 stdcall方式调用函数 3. 按 C/C++函数原型方式调用函数 2. Call the function by stdcall 3. Call the function as a C/C++ function prototype
4. 支持对 C/C++函数打桩, 以一个脚本函数替代原 C/C++函数执行。 实现从 C/C++语言向脚本语言的映射后, 就能在调测脚本中直接读写 被测的变量, 也能用脚本发起函数调用了。 通过映射实体 (包括映射变量 与映射函数) , 本发明用脚本实现了与写 C/C++代码等效的调测模式。  4. Support piling for C/C++ functions, replacing the original C/C++ function with a script function. After implementing the mapping from the C/C++ language to the scripting language, you can directly read and write the measured variables in the debugging script, and you can also use the script to initiate the function call. By mapping entities (including mapping variables and mapping functions), the present invention implements a commissioning mode equivalent to writing C/C++ code using a script.
针对异构脚本语言的映射, 与上述针对 C/C++的映射类似, 也包括异 构脚本系统中的变量与函数, 映射到宿主脚本系统中成为映射变量与映射 函数, 同样实现包括读变量、 写变量、 调用函数在内的映射操作。  The mapping for heterogeneous scripting languages is similar to the above mapping for C/C++. It also includes variables and functions in heterogeneous scripting systems. It maps to the host script system and becomes a mapping variable and mapping function. The same implementation includes reading variables and writing. Mapping operations such as variables and calling functions.
^在本发明的映射方法中, 提出了 "变量容器" 的概念, 以下将对变量  ^ In the mapping method of the present invention, the concept of "variable container" is proposed, and the following variables will be
1. .变量容器 Variable container
1.1 变量容器的功能  1.1 The function of the variable container
变量容器本质上是宿主脚本系统中的一个类对象, 存在于宿主脚本系 统中的映射支持模块中。 在宿主脚本系统中定义一个变量容器类 A variable container is essentially a class object in the host scripting system that exists in the mapping support module in the host scripting system. Define a variable container class in the host script system
TContainer, 变量容器就是这个 TContainer类的实例化对象。但与常规类对 象不同, 变量容器是一种具备特殊功能的类对象, 这些功能主要包括: TContainer, the variable container is the instantiated object of this TContainer class. But unlike regular class objects, the variable container is a class object with special functions. These functions include:
1 ) 变量容器可以层层嵌套。 因为被映射变量 (例如 C/C++中的 struct, 定义) 是可以层层展开的, 形成一种层与层具有归属关系的树状结构。 本.. 发明用变量容器树描述这种树状关系,树上的每个节点都是一个变量容器, 变量容器下可以再包含一个或多个下一级的变量容器, 以此构造层层归属 的树状关系。  1) Variable containers can be nested in layers. Because the mapped variables (such as struct defined in C/C++) can be layered, a tree structure with a layer-to-layer relationship is formed. This invention uses a variable container tree to describe this tree relationship. Each node on the tree is a variable container. The variable container can contain one or more variable containers of the next level to construct the layer attribution. Tree relationship.
2 )对变量容器的子成员进行操作时具有自动操作转向的功能。 例如通 过读取变量容器下某个子成员, 可以隐式地自动转向到某个函数调用。  2) It has the function of automatic operation steering when operating sub-members of the variable container. For example, by reading a sub-member of a variable container, you can implicitly and automatically switch to a function call.
3 )借助变量容器给映射变量赋值,赋值语句的表达方式可兼容强类型 与弱类型两种风格。  3) With the variable container to assign values to the mapping variables, the expression of the assignment statement can be compatible with both strong and weak types.
4 )具有变量容器属性的映射变量在宿主脚本系统中使用时,根据它所 处的上下文环境, 具有自动的、 隐式的转向功能。 例如映射变量在数学运 算中作为一个算子使用, 就自动读取它所代表的数值含义。 又如, 将映射 变量打印输出, 则取它的字串化描述。 再例如, 将映射变量看作一个函数 来调用时, 它就按特定格式 (例如从 C/C++映射过来的函数, 调用格式就 有 cdecl、 stdcalK thiscall等) 实现调用。  4) A mapping variable with a variable container property has an automatic, implicit steering function depending on the context in which it is used in the host scripting system. For example, a map variable is used as an operator in mathematical operations, and it automatically reads the meaning of the value it represents. As another example, if the mapping variable is printed out, its string representation is taken. For another example, when a mapped variable is called as a function, it is called in a specific format (for example, a function mapped from C/C++, the calling format is cdecl, stdcalK thiscall, etc.).
5 )变量容器代表异构系统(异构 C/C++系统或异构脚本系统)中的一 个实体(变量或函数) , 当它在赋值语句或在函数参数中被传递时, 能实 现它所代表的被映射实体的生存周期自动管理。  5) The variable container represents an entity (variable or function) in a heterogeneous system (heterogeneous C/C++ system or heterogeneous scripting system) that can be implemented when it is passed in an assignment statement or in a function parameter. The life cycle of the mapped entities is automatically managed.
变量容器的上述 5项特征中, 前 4项保证变量容器用于映射表述时, 其表达方式接近于被映射语言的语句。例如在映射 C/C++的变量与函数时, 相关的映射操作 (如: 读写变量与调用函数)要在表达上接近于, C语言风 格, 而当变量容器用来描述异构脚本语言 Python的变量与函数时, 读写映 射变量与调用映射函数在表达上又要与 Python近似。 Among the above five characteristics of the variable container, the first four items ensure that the variable container is used for mapping expressions. It is expressed in a manner close to the statement of the language being mapped. For example, when mapping C/C++ variables and functions, related mapping operations (such as: reading and writing variables and calling functions) should be similar in expression, C language style, and when the variable container is used to describe the heterogeneous scripting language Python When variables and functions, the read-write mapping variable and the calling mapping function are similarly expressed in Python.
1.2 变量容器树  1.2 variable container tree
映射变量与映射函数用 TData类实例表示。 TData类从 TContainer继 承而来, 所以映射变量与映射函数都具有变量容器属性。  The mapping variables and mapping functions are represented by TData class instances. The TData class inherits from TContainer, so both the map variable and the map function have variable container properties.
例如, 调用宿主脚本系统中 MapCString函数来创建 C/C++的字串映射 变量, 调用 MapCInt来创建 C/C++的 int类型映射变量, 调用 MapCStract 创建 C/C++的指定 struct类型的映射变量, 调用 MapPyString创建 Python 的字串类型映射变量, 调用 MapPylnt来创建 Python的 int类型变量。 这里 举例的 5个创建映射变量的函数,最终都生成 TData类型的变量容器。 TData 类继承了 TContainer类的所有属性, 所以 TData类属性具备完整的变量容 器的特征。  For example, call the MapCString function in the host script system to create a C/C++ string mapping variable, call MapCInt to create a C/C++ int type mapping variable, call MapCStract to create a C/C++ mapped variable of the specified struct type, and call MapPyString to create it. Python's string type mapping variable, call MapPylnt to create Python's int type variable. Here are five examples of functions that create mapped variables, and finally generate a variable container of type TData. The TData class inherits all the properties of the TContainer class, so the TData class property has the characteristics of a complete variable container.
TData在 TContainer定义基础上再附加了表示映射实体特征的几个属 性, 如该映射实体归属于谁, 即 TData的 Owner属性, 又如该映射实体的 数据类型, 即 TData的 DataType属性, 其值为 TType类实例。  TData adds several attributes indicating the characteristics of the mapping entity to the TContainer definition, such as who the mapping entity belongs to, that is, the Owner attribute of TData, and the data type of the mapping entity, that is, the DataType attribute of TData. An instance of the TType class.
TType类定义用来指明映射实体的数据类型。 例如创建从 C/C++系统 ' 映射过来的 int变量, 指明它的类型是占 4字节的整型类型, 除了描述 int、 short > double等基本类型外, TType还描述 class、 struct, union等复合数 据类型。 另外, TType也定义函数类型, 包括 cdecl、 stdcalK thiscall等风 格的函数原型定义。  The TType class definition is used to indicate the data type of the mapped entity. For example, create an int variable mapped from a C/C++ system, indicating that its type is a 4-byte integer type. In addition to describing basic types such as int, short > double, TType also describes class, struct, union, etc. type of data. In addition, TType also defines function types, including function prototype definitions for styles such as cdecl and stdcalK thiscall.
除了映射变量与映射函数是变量容器, 还有一种用于容纳映射变量与 映射函数的集合, 也是变量容器, 在本发明中称之为"异构集容器"。 异构 集容器是 TDataSet类实例, 而 TDataSet类从 TContainer类继承而来, 所以 异构集容器也具有变量容器属性。 异构集容器用来描述被映射的异构系统 (包括异构 C/C++系统与异构脚本系统) 中的一个抽象集合。 TDataSet在 继承 TContainer 所有属性的基础上再附加表示被映射系统特征的几个属 性, 例如记录被映射的系统是什么 (例如是 C/C++, 还是 Python ) 、 以及 实施映射所需的相关配置, 如: 是否将常量也生成映射实体, 枚举值按 2 字节还是按 4字节计算等。  In addition to the mapping variable and the mapping function are variable containers, there is also a collection for accommodating mapping variables and mapping functions, which is also a variable container, which is referred to as a "heterogeneous set container" in the present invention. The heterogeneous container is an instance of the TDataSet class, and the TDataSet class inherits from the TContainer class, so the heterogeneous container also has variable container properties. Heterogeneous container is used to describe an abstract collection of mapped heterogeneous systems, including heterogeneous C/C++ systems and heterogeneous scripting systems. The TDataSet inherits all the attributes of the TContainer and attaches several attributes that represent the characteristics of the mapped system, such as what is the system being mapped (for example, C/C++ or Python), and the relevant configuration required to implement the mapping, such as : Whether to generate a mapping entity for a constant, whether the enumeration value is 2 bytes or 4 bytes.
将一个异构系统 (异构 C/C++系统或异构脚本系统) 中的变量与函数 映射到宿主脚本系统, 成为该脚本系统中的一个实体。 要求用一个变量容 器即异构集容器来容纳所有这些映射过来的实体。  The variables and functions in a heterogeneous system (heterogeneous C/C++ system or heterogeneous scripting system) are mapped to the host scripting system and become an entity in the scripting system. It is required to use a variable container, a heterogeneous set container, to accommodate all of these mapped entities.
一般情况下, 从被映射语言 ( / ++¾异构脚本语言) 映射过来的实 体 (映射变量或映射函数) , 以及动态创建的新的映射变量, 应该存放在 异构集容器之下。 否则, 就不能保证针对该映射变量的赋值操作能够保持 被映射语言的风格。 只有将映射变量作为异构集容器的一个成员进行赋值 时, 赋值风格才与被映射语言保持一致。 In general, the mapping from the mapped language ( / ++ 3⁄4 heterogeneous scripting language) The body (mapped variable or mapping function), as well as the dynamically created new mapped variable, should be placed under the heterogeneous set container. Otherwise, there is no guarantee that the assignment operation for the mapped variable will maintain the style of the mapped language. The assignment style is consistent with the mapped language only if the map variable is assigned as a member of a heterogeneous set container.
以异构集容器为根节点, 其下保存一个或多个映射实体而构成一种树 状集合, 本发明中称为 "变量容器树" 。 变量容器树可以只有一层, 也可 以有多层。 当异构集容器下只保存基本类型的映射实体时, 就只有一层; 而当异构集容器下保存复合数据的映射变量(例如 C/C++中的 class、 struct 或 union数据, 或异构脚本系统中的类对象) , 就有多层。 每一层的每个 节点都是 TContainer类实例, 因而都具有 TContainer属性) , 而且子节点 层数与各层子节点名称与被映射的复合数据保持一致, 这使得各层的子成 员能准确描述映射过来的变量, 逐层读写子成员时, 该变量的子节点层数、 各层节点包含的子成员、 各层子成员的名称与数据类型等在映射前后保持 一致。  A heterogeneous set container is used as a root node, and one or more mapping entities are stored under it to form a tree set, which is referred to as a "variable container tree" in the present invention. The variable container tree can have only one layer or multiple layers. When a heterogeneous set container only saves the primitive type of mapped entity, there is only one layer; and when the heterogeneous set container holds the mapping variable of the composite data (such as class, struct or union data in C/C++, or heterogeneous There are multiple layers of class objects in the script system. Each node of each layer is an instance of TContainer class, and thus has a TContainer attribute), and the number of child nodes is consistent with the name of each layer of the child node and the mapped composite data, which enables the sub-members of each layer to accurately describe The mapped variables, when the sub-members are read and written layer by layer, the number of child nodes of the variable, the sub-members of each layer node, the names of the sub-layer members and the data types are consistent before and after the mapping.
在变量容器树中, 由于容纳映射实体的变量容器必须是异构集容器, 所以, 异构集容器只能处于变量容器树的根节点。 创建一个空的异构集容 器可以封装成一个脚本的 API (应用程序接口) 调用。 例如, 在宿主脚本 系统中定义 newVarContainer函数用来创建 C/C++系统或 Python系统的一 个空的异构集容器。 .、  In the variable container tree, because the variable container holding the mapped entity must be a heterogeneous set container, the heterogeneous set container can only be in the root node of the variable container tree. Creating an empty heterogeneous container can be packaged into a scripted API (application programming interface) call. For example, define the newVarContainer function in the host script system to create an empty heterogeneous container for a C/C++ system or a Python system. .,
下面以 C/C++系统来举例, 例如在被测系统中定义如下变量与函数: int i Value = 3;  The following is an example of a C/C++ system, such as defining the following variables and functions in the system under test: int i Value = 3;
struct MyStmct {  Struct MyStmct {
int memberl ;  Int memberl ;
char member2 [12];  Char member2 [12];
} struValue = {5,"example"} ; int sum(int i, int j)  } struValue = {5,"example"} ; int sum(int i, int j)
{  {
return i + j;  Return i + j;
}  }
然后在宿主脚本系统 (例如 CSE语言系统) 中定义如下语句:  Then define the following statement in the host scripting system (for example, the CSE language system):
. vc = newVarContainer("C/C++"); II 创建一个 C/C++的异构集容器  Vc = newVarContainer("C/C++"); II Create a C/C++ Heterogeneous Container
ScanCMapData(vc); // 扫描当前 C/C++系统, 生成映射变量与映射函数 到 vc下  ScanCMapData(vc); // Scan the current C/C++ system, generate mapping variables and mapping functions to vc
print(vc.iValue); // 值应为 3 print(vc.sum(vc.iValue,12)); II 结果值应为 15 Print(vc.iValue); // value should be 3 Print(vc.sum(vc.iValue,12)); II The result value should be 15
print(vc.stru Value. member2); II 值应为 "example"  Print(vc.stru Value. member2); II value should be "example"
vc.varl = MapCInt(7); II 创建一个 int类型的映射变量, 赋初值 7 print(vc.varl); // 值应为 7  Vc.varl = MapCInt(7); II Create a mapping variable of type int, assign initial value 7 print(vc.varl); // value should be 7
vc.var2 = MapCString(" Another string"); II 创建 char[]映射变量  Vc.var2 = MapCString(" Another string"); II Create char[] mapping variable
print(vc.var2); II 值应为 "Another string"  Print(vc.var2); II value should be "Another string"
在上例中, vc是异构集容器。它本身是一种变量容器,其下包含 iValue、 struValue, sum、 varl、 var2等映射实体, 这些映射实体都是变量容器。 由 于 struValue是 struct结构, 其下还有 member 1与 member2两个子成员 , 这 两个子成员都是 TData对象, 也都是变量容器, 都挂在 struValue这个映射 变量之下。 这里的 "挂" 是一种检索指向, 表示一种链接指向关系, 也隐 含一种主从推导关系。表达式 "vc.stmValue.member2,,是取其第二个子成员。 可见, 上述以 vc为根节点的树, 是由变量容器的特性支持层层嵌套的。  In the above example, vc is a heterogeneous set container. It is itself a variable container, which contains mapping entities such as iValue, struValue, sum, varl, var2, etc. These mapping entities are all variable containers. Since struValue is a struct structure, there are two sub-members, member 1 and member 2. These two sub-members are both TData objects and variable containers, which are hung under the struValue mapping variable. Here, "hanging" is a kind of retrieval pointing, indicating that a link points to a relationship, and also implies a master-slave derivation relationship. The expression "vc.stmValue.member2," is the second sub-member. It can be seen that the above tree with vc as the root node is nested by the property support layer of the variable container.
1.3 针对变量容器子成员的操作转向 1.3 Operational steering for variable container sub-members
针对变量容器的子属性的操作可以支持如下 3种操作转向:  The operation of the sub-attributes of the variable container can support the following three kinds of operation steering:
1 ) 对变量容器的子成员进行读写时, 自动实现操作转向  1) Automatically implement operation steering when reading and writing sub-members of the variable container
2 ) 对变量容器的数组子成员进行读写时, 自动实现操作转向  2) Automatically implement operation steering when reading and writing the array sub-members of the variable container
3 ) 对变量容器的指针指向值进行读写时, 自动实现操作转向  3) When the pointer of the variable container is read or written, the operation is automatically turned
按数值方式读写变量容器的子成员时, 自动转向到该容器的 getValue 与 setValue方法调用, 例如:  When you read and write a child member of a variable container by value, it automatically redirects to the container's getValue and setValue method calls, for example:
. vc = newVarContainer("C/C++"); II 创建一个 C/C++的异构集容器 vc.varl = MapCInt(7); II ^目当于 C语言: int varl = 7  Vc = newVarContainer("C/C++"); II Create a C/C++ heterogeneous container vc.varl = MapCInt(7); II ^Object in C: int varl = 7
vc.varl = 8; II 转向到隐式调用 vc.setValue(、varr,8)  Vc.varl = 8; II turns to implicit call vc.setValue(,varr,8)
print(vc.varl + 1); II 打印值应为 9  Print(vc.varl + 1); II print value should be 9
II 隐式转向为:  II Implicit steering is:
print(vc. get Value(" varl ' )+ 1 )  Print(vc. get Value(" varl ' )+ 1 )
上面传递给 getValue与 setValue的第一个参数若为 nil, 表示针对该映 射变量自身进行读值或赋值; 若不为 nil, 则表示给该映射变量的指定子成 员读值或赋值。 例如在上例添加语句 vc.varl .getValue(nil) , 则得到值是 8, 等同于 vc.getValue(、varr)。  The first parameter passed to getValue and setValue above is nil, which means that the mapping variable itself is read or assigned; if it is not nil, it means that the specified member of the mapping variable is read or assigned. For example, in the above example, adding the statement vc.varl .getValue(nil) , the value is 8, which is equivalent to vc.getValue(,varr).
在读写变量容器的数组子成员时, 自动转向到该数组成员的 getltem与 setltem方法调用, 例如:  When reading and writing the array child members of the variable container, it automatically redirects to the getltem and setltem method calls of the array member, for example:
vc - newVarContainer("C/C++"); II 创建一个 C/C++的异构集容器; vc.var3 = MapCArray(vt.int,4); II 相当于 C语言中的 int var3[4] vc.var3 [0] = 1 ; II 转向到隐式调用 vc.var3.setltem(0,l) Vc - newVarContainer("C/C++"); II Create a C/C++ heterogeneous container; vc.var3 = MapCArray(vt.int,4); II is equivalent to int var3 in C language [4] Vc.var3 [0] = 1 ; II turns to implicitly call vc.var3.setltem(0,l)
print(vc.var3 [0]); II 转向到隐式调用 vc.var3.getltem(0)  Print(vc.var3 [0]); II Turn to implicit call vc.var3.getltem(0)
读写变量容器的指针指向值时 (这里, 读写指针与读写指针指向值是两 个概念, 例如在 C语言中定义变量 "char * buff' , .给指针赋值如: buff = AnotherVar, 而给指针指向值赋值是: ' *buff = 'Α' ) , 自动转向到该成员的 getPoint与 setPoint方法调用, 例如:  When the pointer to the variable container is pointed to a value (here, the read and write pointer and the read and write pointer point to the value are two concepts, such as defining the variable "char * buff" in C language, assigning a pointer such as: buff = AnotherVar, and Assigning a pointer to a value is: ' *buff = 'Α' ) , which automatically redirects to the member's getPoint and setPoint method calls, for example:
vc = newVarContainer("C/C++"); II 创建一个 C/C++的异构集容器 vc.var4 = MapCStruct(vt.MyStruct); II 相当于: struct MyStmct var4 vc.var5 = MapCPoint(vt.struct.MyStmct,vc.var4); II 相当于 C语言中:  Vc = newVarContainer("C/C++"); II Create a C/C++ heterogeneous set container vc.var4 = MapCStruct(vt.MyStruct); II Equivalent to: struct MyStmct var4 vc.var5 = MapCPoint(vt.struct. MyStmct, vc.var4); II is equivalent to C:
struct MyStmct *var5 = &var4;  Struct MyStmct *var5 = &var4;
vc.var5->memberl = 17;〃转向到调用 vc.var5.setPoint(、memberr, 17) print( vc . var5 ->member 1 );〃转向到调用 vc.var5.getPoint(、 member ) 由于上述三种针对映射变量子成员的操作能够自动转向成映射实体下 特定的方法调用, 这就保证映射操作的表达方式尽可能与被映射语言的风 格保持一致。 因为同一操作 (例如读写子成员, 存取数组成员) 在不同语 言中有不同含义, 而同一操作在宿主脚本系统中运行时具有明确含义, 不 能将宿主脚本语言的固有操作方法直接用于映射过来的数据对象。 但经隐. 式转向后, 就能在转向函数中提供专用实现。  Vc.var5->memberl = 17; 〃 turn to call vc.var5.setPoint(,memberr, 17) print( vc . var5 ->member 1 ); 〃 turn to call vc.var5.getPoint(, member ) due to the above The three operations on the sub-members of the mapping variable can be automatically turned into specific method calls under the mapping entity, which ensures that the mapping operation is expressed as much as possible in the style of the mapped language. Because the same operation (such as reading and writing child members, accessing array members) has different meanings in different languages, and the same operation has a clear meaning when running in the host script system, the native operation method of the host scripting language cannot be directly used for mapping. The data object coming over. However, after the implicit steering, a dedicated implementation can be provided in the steering function.
所谓专用实现是指: 例如, 宿主脚本语言中的变量赋值不同于 C/C++ 语言中的变量赋值, 在宿主脚'本系统中用宿主脚本语言描述 C/C++的变量 赋值, 而实际实现赋值要借助转向函数。 在转向函数中专门针对 C/C++语 言规格实现赋值。 同样, 如果映射变量是从异构脚本系统映射过来的, 则 在转向函数中专门针对该异构函数的规格实现赋值。  The so-called private implementation means: For example, the variable assignment in the host scripting language is different from the variable assignment in the C/C++ language. In the host's system, the C/C++ variable assignment is described in the host scripting language, and the actual implementation assignment is With the help of the steering function. Assignment is specifically implemented in the steering function for C/C++ language specifications. Similarly, if the mapped variable is mapped from a heterogeneous scripting system, the steering function is specifically assigned to the specification of the heterogeneous function.
1.4 兼容强类型与弱类型的赋值风格 1.4 Compatible with strong and weak types of assignment style
C/C++是强类型风格语言, 但宿主脚本语言则与常规脚本语言一样, 是 一种弱类型风格语言。 前者 (强类型风格语言) 的变量的数据类型是代码 编译时就确定的, 并且在动态运行过程中, 变量的数据类型不会动态变化。 而后者是动态数据类型, 变量的数据类型在运行过程中随时发生变化。 例 如在宿主脚本语言 (例如 CSE语言 ) 中运行下面的语句:  C/C++ is a strongly typed style language, but host scripting languages, like regular scripting languages, are a weakly typed style language. The data type of the variable of the former (strongly typed language) is determined when the code is compiled, and the data type of the variable does not change dynamically during dynamic operation. The latter is a dynamic data type, and the data type of the variable changes at any time during the running process. For example, run the following statement in a host scripting language (such as the CSE language):
曹 1 = MapCInt(7);  Cao 1 = MapCInt(7);
varl = 8;  Varl = 8;
varl = 8.5;  Varl = 8.5;
在第一句脚本运行后, varl是映射变量 (即 TData的类实例) , 而笫 二句运行后, varl就变成宿主脚本语言的 int类型变量了, 这时 varl不再 是类实例, 也不再是映射变量, 而原先的映射变量的值仍是 7。 当最后第 三句运行后, varl又变成宿主脚本语言的 float类型变量了。 After the first script is run, varl is the mapping variable (that is, the TData class instance), and after the second sentence is run, varl becomes the int type variable of the host scripting language, and then val is no longer Is a class instance, and is no longer a mapping variable, and the value of the original mapping variable is still 7. When the last third sentence is run, varl becomes the float type variable of the host scripting language.
上述语法用于表达映射操作时, 就存在语义的冲突。 因为在 C语言中, 上述第 2奈语句的原来含义是: 将 int变量的值从 7改成 8。 这种语义冲突 是将强类型语言映射成弱类型语言来表达所固有的。  When the above syntax is used to express a mapping operation, there is a semantic conflict. Because in C language, the original meaning of the above second sentence is: Change the value of the int variable from 7 to 8. This semantic conflict is inherent in the mapping of strongly typed languages to weakly typed languages.
为解决这个问题, 本发明把映射变量置于变量容器下。 因为针对变量 容器子成员的赋值能转向到 setValue方法调用, 就能在 setValue调用中按 C语言风格进行赋值。 例如:  To solve this problem, the present invention places the mapping variable under the variable container. Because the assignment to the variable container sub-member can be redirected to the setValue method call, it can be assigned in the C language style in the setValue call. E.g:
vc = newVarContainer("C/C++"); II 创建一个 C/C++的异构集容器 vc.varl = MapCInt(7); II 相当于 C语言: int varl = 7  Vc = newVarContainer("C/C++"); II Create a C/C++ heterogeneous container vc.varl = MapCInt(7); II is equivalent to C: int varl = 7
vc.varl = 8; 〃 转向到隐式调用 vc.setValue(、varr,8)  Vc.varl = 8; 转向 Steer to implicit call vc.setValue(,varr,8)
这样, 把映射变量置于变量容器中, 缺省就按 C风格进行赋值, 而变 量容器外的变量赋值仍可保持宿主脚本语言的动态数据类型风格。  In this way, the mapping variable is placed in the variable container, and the default is assigned in C style, and the variable assignment outside the variable container can still maintain the dynamic data type style of the host scripting language.
另一方面, 如果变量容器下的映射变量一直维持强类型赋值风格, 也 会给调测工作带来不便。 例如在第一个测试用例中临时创建了一个指针类 型名为 var 的映射变量, 这个映射变量在该用例运行结束就不用了。 现在 接着设计第二个测试用例, 也使用一个名为 var的 int类型的映射变量。 这 时, 变量容器下名为 var 的映射变量还存在 (是上个用例执行后遗留的指 针类型变量) , 此时赋值若仍维持强类型风格, 就容易产生问题, 例如: II 测试用例 1中的语句  On the other hand, if the mapping variable under the variable container maintains the strong type assignment style, it will also bring inconvenience to the commissioning work. For example, in the first test case, a mapping variable named var is temporarily created. This mapping variable is not used when the use case ends. Now let's design the second test case, also using a mapping variable of type int called var. At this time, the mapping variable named var exists in the variable container (it is the pointer type variable left after the previous use case is executed). If the assignment still maintains the strong type style, it is easy to cause problems, for example: II Test Case 1 Statement
vc = newVarContainer("C/C++"); II 创建一个 C/C++的异构集容器 vc.var = MapCPoint(vt.int); II var是" int *"映射变量  Vc = newVarContainer("C/C++"); II Create a C/C++ heterogeneous container vc.var = MapCPoint(vt.int); II var is the "int *" mapping variable
II ... '  II ... '
II 测试用例 2中的语句  II Test statement in test case 2
vc.var = MapCInt(3); II 这时, vc.varl仍是" int *,,类型, 指针值是 3 Vc.var = MapCInt(3); II At this point, vc.varl is still "int *,, type, pointer value is 3
II ... II ...
期望在第二个用例中 "vc.var = MapCInt(3),,执行后, vc.var是值为 3的 int类型变量, 但实际上这时这个变量却是 "int *"类型。  Expected in the second use case "vc.var = MapCInt(3), after execution, vc.var is an int type variable with a value of 3, but in fact this variable is of type "int *".
为解决该问题, 宿主脚本系统可提供一个 API用来删除变量容器下指 定的子成员。 例如该 API 可以是 delete VcAttr。 上例中若在 "vc.var = MapCInt(3)"语句之前运行" deleteVcAttr(vc, ar7,, 则可消除语义冲突。  To solve this problem, the host scripting system can provide an API to delete the child members specified under the variable container. For example, the API can be delete VcAttr. In the above example, if you run "deleteVcAttr(vc, ar7,) before the "vc.var = MapCInt(3)" statement, the semantic conflict can be eliminated.
如果要进一步提高易用性, 还可以让宿主脚本语言支持某种特殊的赋 值操作。 在赋值前先删除已存在的同名子成员 , 例如: "vc.var := MapCInt(3)"。 这样, 对变量容器下子成员的赋值就形成清晰的规则, 缺省 "= "赋值按被映射语言的风格进行, 而": = "赋值则按宿主语言原有的风格进 行。 此处": = "是 CSE语言中的合法操作符, 含义为 "特殊赋值"。 If you want to further improve ease of use, you can also let the host scripting language support a special assignment operation. Delete an existing child member of the same name before the assignment, for example: "vc.var := MapCInt(3)". Thus, the assignment of sub-members to the variable container forms a clear rule. The default "=" assignment is done in the style of the mapped language, and the ":=" assignment is based on the original style of the host language. Row. Here ":=" is a legal operator in the CSE language, meaning "special assignment".
1.5 映射实体按使用环境隐式转向  1.5 Mapping entities are implicitly redirected by usage environment
同一映射实体在不同使用环境下具有不同含义。 例如 sum是 cdecl风格 的映射函数, 运行如下脚本:  The same mapping entity has different meanings in different usage environments. For example, sum is a cdecl-style mapping function, run the following script:
print(vc.sum); 〃 打印函数原型, 即: int一 cdecl sum(int,int) vc.sum(3,5); 〃 应调用 C函数 sum, 返回值为 8  Print(vc.sum); 〃 Print the function prototype, ie: int a cdecl sum(int,int) vc.sum(3,5); C The C function sum should be called, the return value is 8
print(vc.sum + 1); // 把该映射函数看成数值使用, 即: 取其地址值 再加上 1  Print(vc.sum + 1); // Think of the mapping function as a numeric value, ie: take its address value plus 1
上面第一行查看映射实体的描述值 (通常用于打印输出, 让调测者能 一眼看出这个实体是什么) , 第二行是按 C风格进行函数调用, 第三行是 把映射实体看作数值来使用。  The first line above looks at the description value of the mapped entity (usually used for printouts, allowing the debugger to see what the entity is at a glance), the second line is a function call in C style, and the third line is looking at the mapping entity. Use as a numerical value.
实现上述自动转向功能, 首先要求宿主脚本语言内核能识别当前变量 容器所处的上下文使用环境。 例如把映射实体用在加、 减、 乘、 除运算中, 系统就自动调用该映射实体的 getValue方法提取它所代表的数值。 上例中 第三行脚本反映了这种情况。  To achieve the above automatic steering function, the host scripting language kernel is first required to recognize the context in which the current variable container is located. For example, if the mapping entity is used in addition, subtraction, multiplication, and division, the system automatically calls the map entity's getValue method to extract the value it represents. The third line of script in the above example reflects this situation.
除了如上所述系统能捕获针对映射实体子成员读写操作外, 本发明要 求宿主脚本语言还能识别如下 4种上下文环境, 并实施隐式转向:  In addition to the system being able to capture read and write operations for mapping entity sub-members as described above, the present invention requires the host scripting language to recognize the following four contexts and implement implicit steering:
1 ) 映射实体出现在数学运算或逻辑运算中作为算子使用时, 或者映射 实体在映射函数调用中作为参数传入时, 该映射实体被看作数值来使用。 : 即: 将当前操作隐式转向到本对象的 getValue方法调用。  1) When a mapped entity is used as an operator in a mathematical or logical operation, or when a mapped entity is passed as a parameter in a mapping function call, the mapped entity is treated as a numeric value. : That is: implicitly redirect the current operation to the getValue method call of this object.
2 )如果映射实体直接用作函数调用, 则该映射实体将被理解为映射^) 数, 当前操作将隐式转向到本对象的 _call—方法调用, 在— call—方法中 实施被映射语言的相关函数调用。  2) If the mapping entity is used directly as a function call, then the mapping entity will be interpreted as a mapping ^) number, the current operation will implicitly redirect to the _call-method call of the object, and the mapped language will be implemented in the -call method. Related function calls.
3 ) 如果映射实体用于取自身描述值, 例如在 print语句中使用, 当前 操作将隐式转向到本映射实体的— str—方法调用。  3) If the mapping entity is used to fetch its own description value, for example in a print statement, the current operation will implicitly redirect to the -str-method call of the mapping entity.
4 )如果映射实体用于获取自身表述值, 例如在 repr函数中调用, 则当 前操作将隐式转向到本映射实体的—repr—方法调用。  4) If the mapping entity is used to retrieve its own representation value, for example in the repr function, the current operation will implicitly redirect to the -repr-method call of the mapping entity.
在上述 2 )中, 映射实体用于函数调用时转向到该实体的—call_方法。 其中—call—方法实现应能准确地模拟该函数在被映射语言中是如何运行 的。 首先要识别传入参数, 如果传入参数是一个映射实体, 则自动取其代 表的数值来压桟。 在取其数值的过程还应对照函数原型检查传入参数的类 型是否匹配, 若不匹配应该报告错误。 如果被调用的映射实体来源于 C++ 语言, 还应注意多态函数的原型申明。 因为多个同名函数, 参数个数或类 型不尽相同。 因此, 本发明逐一分析传入的参数, 参照多个同名函数的原 型进行匹配分析。 若匹配上了就选择其中匹配的函数来调用, 若匹配不上 就报告异常。 模拟调用时压栈与出栈方式也应与该函数申明的风格(如: cdecl、 stdcalK thiscall> fastcall等) 保持一致。 In the above 2), the mapping entity is used to transfer to the -call_ method of the entity when the function is called. The call-method implementation should accurately simulate how the function works in the mapped language. The first step is to identify the incoming parameter. If the incoming parameter is a mapped entity, it will automatically take the value it represents to suppress it. In the process of taking its value, it should also check whether the type of the incoming parameter matches against the function prototype. If it does not match, it should report an error. If the called mapping entity is derived from the C++ language, you should also pay attention to the prototype declaration of the polymorphic function. Because of multiple functions with the same name, the number or type of parameters is not the same. Therefore, the present invention analyzes the incoming parameters one by one, and performs matching analysis with reference to a plurality of prototypes of the same name function. If the match is matched, select the function that matches it to call, if the match does not match Report an exception. The push and pop methods of the simulation call should also be consistent with the style declared by the function (eg cdecl, stdcalK thiscall> fastcall, etc.).
另外, 在得到该映射函数的调用结果后, 如果该函数原型要求的返回 类型不为 void, 还必须将结果值按指定的返回类型映射成映射变量。 例如, 映射函数从 C/C++系统映射而来。 在— call—方法中模拟该函数调用后, 返 回一个数值, 该数值在 C/C++系统中有准确含义(例如是 int值) 。 但这种 返回值不能直接在宿主脚本中使用。 按相同的映射方法, 把该返回值映射 到宿主脚本系统, 成为宿主脚本系统中的一个映射变量后才能使用。  In addition, after the result of the call to the mapping function, if the return type required by the function prototype is not void, the result value must also be mapped to the mapped variable according to the specified return type. For example, mapping functions are mapped from a C/C++ system. After simulating the function call in the call- method, a value is returned, which has an exact meaning in the C/C++ system (for example, an int value). However, this return value cannot be used directly in the host script. According to the same mapping method, the return value is mapped to the host script system and becomes a mapping variable in the host script system before it can be used.
在上述 3 ) 和 4 ) 中, 取自身描述值与表述值是不相同的。 前者取描述 值仅用于调测时浏览查看目的, 而后者取表述值是无损失地获得该对象的 文本化描述。 该种文本化描述经自身脚本语言计算后能生成回与其自身一 致的数据。 例如, 在 Python语言中, 运行表达式" eval(repr(100)),,得到值仍 是值为 100 的 int数据, 而运行表达式 "eval(repr("100"))"得到值仍是值为 "100"的字串数据。 因为取表述值可以无损失地进行流式转化, 并能方便地 转化回来, 所以它常用于跨进程或跨机器透传某实体。 本发明所述的 "取描 述值"与 Python 内嵌函数" str"的含义一致, 本发明所述的 "取表述值"与 Python内嵌函数" repr"的含义一致, 本文不再展开详细解释。  In the above 3) and 4), the self-description value is different from the expression value. The former takes the description value only for browsing to view the purpose, while the latter takes the representation value to obtain a textual description of the object without loss. This textual description can be generated back to its own data after being calculated by its own scripting language. For example, in the Python language, run the expression "eval(repr(100)), and get the int data with a value of 100, while running the expression "eval(repr("100"))") is still the value String data with a value of "100". Because the representation value can be streamed without loss and can be easily converted back, it is often used to transparently transmit an entity across processes or across machines. The descriptive value "is consistent with the meaning of the Python inline function "str". The "representation value" described in the present invention is consistent with the meaning of the Python inline function "repr", and will not be explained in detail herein.
映射实体取表述值自动转向到该实体的— repr—方法调用,这项规则只 在异构脚本语言映射中支持, C/C++映射不支持, 因为 C/C++语言中没有对 应的 "取表述值"的概念。  The mapping entity takes the representation value automatically to the -repr-method call of the entity. This rule is only supported in heterogeneous scripting language mapping. C/C++ mapping is not supported because there is no corresponding "representation value" in C/C++ language. "the concept of.
1.6映射实体的生存周期自动管理  1.6 Mapping entity life cycle automatic management
变量生存周期自动管理是脚本语言普遍支持的一种特征。 其原理是对 每个受管理的数据都记录引用次数。 在创建一个对象并首次使用时, 引用 次数置为 1。 当该对象传递给其它实体, 其它实体也同时使用它时, 引用 次数将加 1。 而如果某实体不再使用该对象, 则引用次数減去 1。 如果某对 象的引用计次降为 0, 表示该对象不再被使用, 系统会立即释放它所占用 的资源。  Automatic management of variable life cycle is a feature commonly supported by scripting languages. The principle is to record the number of citations for each managed data. When you create an object and use it for the first time, the number of references is set to 1. When the object is passed to another entity and other entities use it at the same time, the number of references is incremented by 1. If an object no longer uses the object, the number of references is decremented by 1. If the reference count for an object drops to 0, the object is no longer used, and the system immediately releases the resources it occupies.
本发明提供了两类映射支持, 其一是从 C/C++系统把变量或函数映射 到宿主脚本系统, 其二是从异构脚本系统把变量或函数映射到宿主脚本系 统。 在第二种情况下, 由于异构脚本系统自身已支持变量生存周期自动管 理, 映射为宿主脚本系统的实例, 按照常规编程方法就自然支持映射实体 的生存周期自动管理了。 但是对于第一种情况, 因 C/C++不具备针对所有 数据类型提供生存周期自动管理的功能, 需要对 C/C++中的变量和函数提 供专门的映射支持。 实现映射后能保证用宿主脚本方式读写 C/C++变量与 调用 C/C++函数。但是,在新创建一个映射变量后,它使用的变量空间(即: 对应于 C/C++语言变量的空间) 不是自动管理的。 如果每次调测都手工去 释放无疑比较烦瑣, 会大大降低测试用例的设计效率, 以及损失测试用例 的代码质量。 The present invention provides two types of mapping support, one is to map variables or functions from a C/C++ system to a host scripting system, and the other is to map variables or functions from a heterogeneous scripting system to a host scripting system. In the second case, since the heterogeneous scripting system itself supports the automatic management of the variable life cycle, and maps to the instance of the host scripting system, the life cycle of the mapping entity is naturally managed automatically according to the conventional programming method. But for the first case, because C/C++ does not have the ability to provide automatic lifecycle management for all data types, special mapping support for variables and functions in C/C++ is required. After the mapping is implemented, it is guaranteed to use the host script to read and write C/C++ variables and call C/C++ functions. However, after a new mapping variable is created, it uses the variable space (ie: Spaces corresponding to C/C++ language variables are not automatically managed. If the manual release to each release is undoubtedly cumbersome, the design efficiency of the test case will be greatly reduced, and the code quality of the test case will be lost.
为了让从 C/C++系统映射过来的变量也能自动管理它的生存周期, 本 发明中规定每个映射变量所占用的内存块都有它的所有者, 即, 在 TData 类设置 Owner属性。 当同一内存块作为整体, 或者取其局部生成其它映射 实体时, 采用"引用计次"方法记录它的使用状况。 当不再有映射实体使用 该块内存时, 它占用的资源就自行释放。  In order to allow the variables mapped from the C/C++ system to automatically manage its life cycle, the present invention stipulates that the memory block occupied by each mapping variable has its owner, that is, the Owner attribute is set in the TData class. When the same memory block is used as a whole, or when it is locally generated to generate other mapping entities, the usage status is recorded by the "reference counting" method. When the mapped entity no longer uses the block memory, the resources it occupies are released by itself.
2. 调测系统的实现  2. Implementation of the commissioning system
图 3是根据本发明的脚本解释器驱动测试系统的示意方框图。 如图所 示, 测试主机 1 包含测试壳 (Test Shell ) 11 , 用于发起调测命令, 以及提 供开发、 测试的平台。 测试主机端可以釆用个人桌面系统 (如 Windows、 Linux等) 。 测试壳 11可以是其中的一个可执行程序。  3 is a schematic block diagram of a script interpreter driven test system in accordance with the present invention. As shown in the figure, the test host 1 includes a test shell 11 for initiating commissioning commands and a platform for development and testing. The test host can use a personal desktop system (such as Windows, Linux, etc.). The test case 11 can be one of the executable programs.
目标机 1通常是被测单板, 或者是一个仿真程序。 目标机 2中驻留有 测试代理 ( Test Agent ) 21。 该测试代理 21可以是一个脚本语言系统。 在 本发明中, 对脚本语言的种类并没有限定, 只要能满足本发明规定的映射 规则即可。在目标机 2的测试代理 21 内包含有被测试程序的符号表和类型 表。 关于符号表和类型表将在后文中说明。  The target machine 1 is usually the board being tested, or a simulation program. A Test Agent 21 resides in the target 2. The test agent 21 can be a scripting language system. In the present invention, the type of the script language is not limited as long as the mapping rule defined by the present invention can be satisfied. The symbol table and type table of the program under test are included in the test agent 21 of the target machine 2. The symbol table and type table will be described later.
目标机 2可以与测试主机 1共用同一台设备, 例如计算机。 在此情况 下, 被测程序是 exe程序, 测试主机也是 exe程序, 两者可以同时运行在 一台机器的操作系统 (如 windows这样的支持多进程的平台) 上。  The target machine 2 can share the same device as the test host 1, such as a computer. In this case, the program under test is an exe program, and the test host is also an exe program. Both can run on the operating system of one machine (such as a multi-process platform such as Windows).
测试主机 1的测试外壳 11与测试代理 21具有通信连接。 此连接的通 信方式可以是共享内存通信 (对于目标机与测试主机共用同一台计算机的 情况、 TCP/IP通信, 或是其它如串口通信等形式。  The test housing 11 of the test host 1 has a communication connection with the test agent 21. The communication method for this connection can be shared memory communication (for the case where the target computer shares the same computer with the test host, TCP/IP communication, or other forms such as serial communication).
如图 4所示, 测试代理 21 包括脚本系统 211和通讯单元 212。 通讯单 元 212负责处理测试代理 21与测试主机 1的测试外壳 11的上述通信连接。  As shown in FIG. 4, the test agent 21 includes a script system 211 and a communication unit 212. The communication unit 212 is responsible for processing the above communication connection between the test agent 21 and the test casing 11 of the test host 1.
脚本系统 211 包括内嵌调测支持模块 2111和映射支持模块 2112。 内 嵌调测支持模块 2111是常规的调测应用编程接口 (API ) 的集合, 提供诸 如复位目标机、 启动或停止某任务、 设置断点、 删除断点等功能。 映射支 持模块 2112用于实现被测系统中的 C/C++语言变量与函数向脚本系统映射 的功能。 在完成映射后, 脚本系统 21 1 中生成与 C/C++语言的变量和函数 同名的映射变量与映射函数。  The scripting system 211 includes an inline debugging support module 2111 and a mapping support module 2112. The embedded debug support module 2111 is a collection of conventional commissioning application programming interfaces (APIs) that provide functions such as resetting the target, starting or stopping a task, setting breakpoints, and deleting breakpoints. The mapping support module 2112 is used to implement the function of mapping C/C++ language variables and functions in the system under test to the script system. After the mapping is completed, the script system 21 1 generates mapping variables and mapping functions having the same names as the variables and functions of the C/C++ language.
当目标机 2执行测试并反馈结果、 或在测试过程中发出了打印信息, 测试主机 1的测试外壳 1 1将会接收该结果或信息并进行处理。 3. C/C++映射 When the target machine 2 performs the test and feeds back the results, or issues print information during the test, the test shell 11 of the test host 1 will receive the result or information and process it. 3. C/C++ mapping
3.1 映射支持模块的初始化  3.1 Mapping support module initialization
参见图 5 , 首先, 目标机 2要进行初始化处理。 当测试主机 1启动命 令解释模块的程序时, 目标机 2启动被测程序 ( S501 ) 。 然后, 目标机 2 初始化其中包含的脚本系统 211 ,包括设置测试代理 21的相关配置( S502 )。 在此过程中, 测试代理 21的表生成单元(未示出)从目标机 2被测试的软 件在其最后一次编译后生成的 GDB或 PDB调试数据库中提取与被映射的 变量 /函数相关的信息, 生成符号表和类型表(后文将要说明) , 并记录在 测试代理 21中 (S503 ) 。 然后, 测试代理 21的脚本系统 21 1把符号表及 类型表映射到一个全局的变量容器 (即异构集容器) (S504 ) 。 按照预定 的脚本把类型表、 符号表的符号都映射至变量容器中 (S505 ) 。 该操作将 被测程序中的变量与函数在脚本系统中描迷为映射实体 (即脚本的 TData 类对象)。 由于转换全部符号会导致 CPU与内存资源浪费, 因此根据本发 明的一个实施方式, 不对符号作一次性全部转换, 而仅根据测试需要来映 射。 例如, 运行测试脚本时, 脚本包含哪些映射的变量与函数, 就动态转 换那些变量或函数, 或者由用户自行确定规则来按需转换, 例如所有外部 定义的符号都不作映射。  Referring to Fig. 5, first, the target machine 2 is subjected to initialization processing. When the test host 1 starts the program of the command interpretation module, the target machine 2 starts the program under test (S501). Then, the target machine 2 initializes the script system 211 contained therein, including setting the relevant configuration of the test agent 21 (S502). In this process, the table generation unit (not shown) of the test agent 21 extracts information related to the mapped variables/functions from the GDB or PDB debug database generated by the software of the target machine 2 after the last compilation thereof. , a symbol table and a type table (to be described later) are generated and recorded in the test agent 21 (S503). Then, the scripting system 21 of the test agent 21 maps the symbol table and the type table to a global variable container (i.e., a heterogeneous set container) (S504). The symbols of the type table and the symbol table are mapped to the variable container according to the predetermined script (S505). This operation describes the variables and functions in the program under test as mapping entities (that is, script TData class objects) in the script system. Since converting all symbols results in wasted CPU and memory resources, in accordance with one embodiment of the present invention, the symbols are not converted all at once, but only for testing purposes. For example, when running a test script, the script contains which mapped variables and functions, dynamically convert those variables or functions, or the user can determine the rules to convert on demand, for example, all externally defined symbols are not mapped.
此后, 进行被测系统的正常测试(S506 ) 。 在测试主机 1, 用户使用". 类似 C/C++语言的脚本文件对传送来的编码进行操作。测试外壳 11中的命 ·· 令解释模块解释用户的输入, 并发出相应的测试指令。 该命令被传送到测 试目标机 2, 并在其脚本系统 21 1 中运行, 从而得到按编码£辑所得到的 测试运行结果。 这个测试运行结果可被反馈到测试主机 1 , 并显示给用户。 在上述方法中, 由于可以在线地编写测试脚本, 直观地查看或修改被测变 量、 调用被测函数, 可以马上看到测试结果, 也可马上改进测试, 从而提 高了测试的效率。  Thereafter, a normal test of the system under test is performed (S506). In test host 1, the user operates on the transmitted code using a script file similar to the C/C++ language. The command in the test shell 11 causes the interpretation module to interpret the user's input and issue the corresponding test command. It is transmitted to the test target machine 2 and runs in its script system 21 1 to obtain the test run result obtained by encoding the code. The test run result can be fed back to the test host 1 and displayed to the user. In the method, since the test script can be written online, the measured variable can be visually viewed or modified, and the measured function can be called, the test result can be immediately seen, and the test can be improved immediately, thereby improving the efficiency of the test.
因为 C/C++语言编码对其数据的结构 /类型要求很严格, 作为它的映射 后的脚本, 必须能够支持基本的 C/C++编程的功能和要求。  Because C/C++ language coding is very strict on the structure/type of its data, its mapped script must be able to support the basic C/C++ programming features and requirements.
3.2 对宿主脚本语言的基本要求  3.2 Basic requirements for host scripting languages
为了实现本发明的目的, 本发明中使用的宿主脚本语言需要在表达方 式上满足以下描述方式:  In order to achieve the object of the present invention, the host scripting language used in the present invention needs to satisfy the following description in the expression:
1) 指针搡作与 C/C++语言风格保持一致, 包括 "- >"操作符使用方法, 例如用 "pStmct- >Memberl "描述某结构指针指向某成员; 也包括指针移动 的规则,例如 "pint +2"将 int指针向后移动 2,实际指向将偏移 2 * sizeof(int) 个字节。  1) The pointer is consistent with the C/C++ language style, including the "->" operator usage, such as "pStmct->Memberl" to describe a structure pointer to a member; also includes rules for pointer movement, such as "pint +2" moves the int pointer backward by 2, and the actual pointer will offset 2 * sizeof(int) bytes.
2) 存取数组成员的方式与 C/C++语言的风格保持一致。 使用中括号按 下标取子成员, 例如用 "ArrayVar[2],, 表示存取数组变量 Array Var的第 3 个子成员。 2) The way to access array members is consistent with the style of the C/C++ language. Use square brackets The subscript takes the sub-member, for example, with "ArrayVar[2],, the third sub-member of the array variable Array Var.
3) 存取 struct与 union成员的方式与 C/C++语言风格保持一致。 使用 点号区隔 stmct/union变量与其成员, 例如某 Struct类型定义了两个子成员 Member 1 与 Member2 , 存取该类型变量 StmVar第一个子成员的描述形式 为 " StruVar.Member 1 " 。  3) The way to access struct and union members is consistent with the C/C++ language style. Use the dot to separate the stmct/union variable from its members. For example, a Struct type defines two child members, Member 1 and Member2. Accessing the type variable, the first child member of StmVar, is described as " StruVar.Member 1 ".
4) 支持下列与 C/C++语言含义一致的二元操作, 操作符表达方式与优 先级都一致。  4) Support the following binary operations that are consistent with the C/C++ language, and the operator expressions are consistent with the priority.
Figure imgf000017_0001
Figure imgf000017_0001
以上涉及取值描述的应同样适用于赋值描述, 如 "pStmct->Memberl = 3" 、 "ArrayVar[2] = 3" 、 " StruVar.Member 1 = 3" 。  The above descriptions of the values should also apply to assignment descriptions such as "pStmct->Memberl = 3", "ArrayVar[2] = 3", "StruVar.Member 1 = 3".
同时, 为达到高效率测试及支持必要的扩展能力, 驻留在测试代理中 宿主脚本语言优选应能满足如下要求:  At the same time, in order to achieve high efficiency testing and support the necessary scalability, reside in the test agent. The host scripting language should preferably meet the following requirements:
1) 脚本中的所有变量与函数, 能实现生存周期自动管理, 多数脚本语 言都具备本项特性, 通常使用引用计次技术实现生存周期自动管理。  1) All variables and functions in the script can realize automatic management of life cycle. Most script languages have this feature. Usually, the life cycle is automatically managed by using the reference counting technology.
2) 支持常见的数据类型, 如 4字节整数、 单精度或双精度浮点数、 字' 串、 数组序列、 字典等。  2) Support common data types, such as 4-byte integers, single-precision or double-precision floating-point numbers, word 'strings, array sequences, dictionaries, and so on.
3) 支持 if、 else、 while等基本的分支与循环控制。  3) Support basic branch and loop control such as if, else, and while.
4) 支持函数定义扩展与模块定义扩展。  4) Support for function definition extensions and module definition extensions.
5) 支持类定义与类继承。 这是由于本发明使用的映射规则依赖于特定 的类定义格式。 因此需要类定义的功能。  5) Support for class definitions and class inheritance. This is due to the fact that the mapping rules used by the present invention depend on a particular class definition format. Therefore the functionality of the class definition is required.
6) 在不重启脚本系统前提下, 可在线增删变量、 函数, 以及类的定义, 现在技术中已有许多脚本语言都能支持这一点。  6) Variables, functions, and class definitions can be added and removed online without restarting the scripting system. Many scripting languages in the technology now support this.
满足上述要求的脚本系统都是可以从现有技术中得到的, 如 Python、 Ruby等, 它们都支持在线增加或删除变量定义或函数定义。  Scripting systems that meet the above requirements are available from the prior art, such as Python, Ruby, etc., which support the addition or deletion of variable definitions or function definitions online.
3.3 驻留符号表与类型表  3.3 Resident Symbol Table and Type Table
为了实现对 C/C++语言编码的映射, 根据本发明 , 在目标机 2的测试 代理 21中驻留了被测试程序的符号表和数据类型表。这两个表将直接支持 本发明规定的映射规则的实现。 本发明的映射方法依赖于对目标机系统的 各种符号及其类型信息的收集与分析。 调试数据库在编译过程中由编译器 产生, 例如在 Visual C/C++编译过程中, 编译器会从源码中提取相关信息 生成作为中间格式数据的 PDB文件。 GCC在编译时也会将中间格式数据的 GDB调试信息编译到目标程序中。 驻留在目标机的映射支持模块将进一步 分析中间格式数据 (PDB/GDB ) , 生成符号表与类型表。 In order to achieve mapping of C/C++ language encoding, according to the present invention, the symbol table and data type table of the program under test are resident in the test agent 21 of the target machine 2. These two tables will directly support the implementation of the mapping rules specified by the present invention. The mapping method of the present invention relies on the collection and analysis of various symbols of the target system and their type information. Debugging the database by the compiler during compilation Generated, for example, during Visual C/C++ compilation, the compiler extracts relevant information from the source code to generate a PDB file as intermediate format data. GCC also compiles the GDB debug information of the intermediate format data into the target program at compile time. The mapping support module residing on the target machine will further analyze the intermediate format data (PDB/GDB) to generate a symbol table and a type table.
不同的 C/C++编译器生成的调试数据库格式并不一样。 本发明通过对 类型表和符号表的生成达到了对不同格式的统一。 类型表记录被测系统定 义过的各种类型。 这些类型必须包括: 主类型信息、 子类型信息、 以及占 用.字节数。 表 1是类型定义格式的示例:  The debug database format generated by different C/C++ compilers is not the same. The invention achieves the unification of different formats by generating the type table and the symbol table. The type table records the various types defined by the system under test. These types must include: primary type information, subtype information, and occupancy. Bytes. Table 1 is an example of a type definition format:
表 1 :  Table 1 :
Figure imgf000018_0001
Figure imgf000018_0001
同时要确保类型表下各栏目具有唯一性, 即, 由相同的主类型与子类 型以及占相同字节数而构成的类型项只能存在一个。  Also make sure that the columns under the type table are unique, that is, there can only be one type of the same main type and subtype and the same number of bytes.
符号表记录变量或函数的地址值及其类型 ID。 其中符号地址有两种形 式, 既可以是绝对地址, 也可以是相对地址。 例如, 存取函数内局部变量 或传入参数时, 则使用相对于当前栈顶位置的偏移值。 再如, 某变量在另 一变量空间下存在, 其地址也按该另一变量的地址加上一个偏移来表达。  The symbol table records the address value of a variable or function and its type ID. The symbol address has two forms, which can be either an absolute address or a relative address. For example, when accessing a local variable or passing in a parameter, the offset value relative to the current top position is used. For another example, a variable exists in another variable space, and its address is also expressed by the address of the other variable plus an offset.
符号来源有两种方式, 一是来源于另一映射实体, 二是来源于某绝对 地址。 后者是描述变量或函数的常规方式., 前者常在将同一内存空间看作 多种类型的变量进行操作时使用, 例如强制类型转换,'是将某字串数組的 某一偏移看成整数类型变量。 There are two ways to source symbols, one is from another mapping entity, and the other is from an absolute address. The latter is a general way of describing variables or functions. The former is often used when the same memory space is treated as multiple types of variables, such as forced type conversion, 'is an array of strings An offset is treated as an integer type variable.
3.4 变量与函数的映射  3.4 Mapping of variables and functions
上述类型表和符号表按照特定格式组织, 驻留在被测系统中, 符号表 中各个符号可映射到宿主脚本系统, 成为映射实体, 也即脚本系统中的 TData 类实例。 为了节省资源开销, 本发明的一个方式是按需映射而非一 次全部映射, 使变量与函数只有在被使用时才映射为脚本对象。  The above type table and symbol table are organized according to a specific format and reside in the system under test. Each symbol in the symbol table can be mapped to the host script system and become a mapping entity, that is, an instance of the TData class in the script system. In order to save resource overhead, one aspect of the present invention is to map on demand rather than all at once, so that variables and functions are mapped to script objects only when they are used.
在生成了符号表和类型表之后, 为了脚本的操作方便, 需要定义与表 中数据相应的转化脚本类对象, 即 TType类对象对应于类型表, TData类 对象对应于符号表。 在 TType类对象定义的实例化数据包含如下信息: 该 类型唯一的标识, 类型主类别信息, 类型子类别信息, 类型大小。 各个符 号映射为 TData类定义的实例化数据, 包含以下信息: 该符号对应的类型 ID, 符号的来源, 相对于来源的偏址, 是否是自动释放内存。  After the symbol table and the type table are generated, in order to facilitate the operation of the script, it is necessary to define a conversion script class object corresponding to the data in the table, that is, the TType class object corresponds to the type table, and the TData class object corresponds to the symbol table. The instantiated data defined in the TType class object contains the following information: The type unique identifier, type main category information, type subcategory information, type size. Each symbol is mapped to the instantiated data defined by the TData class and contains the following information: The type ID of the symbol, the source of the symbol, the offset from the source, whether the memory is automatically freed.
表格内容的映射过程按图 6进行。 首先, 脚本系统 211从符号表里找 出需要的符号 (变量或函数)信息, 如符号名称, 符号的类型 ID及符号地 址(S601 )。 然后脚本系统 211通过该类型 ID查找相应的类型是否有生成 的 TType类对象, 若没有则先创建该 TType类对象, 即通过定义 TData或 TType类对象, 调用类定义的建构函数来创建这个类对象的实例 (S602 ) 。 最后, 根据该符号的来源、 所属的 TType对象、 地址偏移及是否自动释放 内存等信息来创建被映射符号的 TData类对象 (S603 ) 。  The mapping process of the table contents is performed as shown in Fig. 6. First, the script system 211 finds the required symbol (variable or function) information from the symbol table, such as the symbol name, the type ID of the symbol, and the symbol address (S601). The script system 211 then finds whether the corresponding type has the generated TType class object by using the type ID. If not, the TType class object is created first, that is, by defining a TData or TType class object, calling the class definition constructor to create the class object. An instance (S602). Finally, a TData class object of the mapped symbol is created according to the source of the symbol, the associated TType object, the address offset, and whether the memory is automatically released (S603).
在创建的映射实体包括映射变量与映射函数时, 首先要有相应的 TType对象指明类型信息。 当类型表中的各项都转化成 TType类实例后, 原有类型信息表不再有用,其占用的资源可释放,而用新生成的各个 TType 类实例组成一个新表, 即 TType类型表。 映射变量与映射函数都是 TData 类实例。 如图 7所示, 每个 TData类实例使用该符号对应的类型 ID ( Data type ) 指示它使用 TType 类型表中的哪个类型。  When the created mapping entity includes mapping variables and mapping functions, the corresponding TType object must first indicate the type information. When the items in the type table are converted into TType class instances, the original type information table is no longer useful, and the occupied resources can be released, and the newly generated TType class instances form a new table, that is, the TType type table. Both map variables and map functions are instances of the TData class. As shown in Figure 7, each TData class instance uses the type ID ( Data type ) of the symbol to indicate which type in the TType type table it uses.
需要注意, TType 类的对象可能是嵌套引用的。 某些复合类型如 stmct/union/指针等包含了子类型, 而且同一子类型可能被多个复合类型引 用。 所以, 在创建每个 TType对象时, 该类型涉及的其它类型也同时被创 建。  Note that objects of the TType class may be nested references. Some composite types such as stmct/union/pointers contain subtypes, and the same subtype may be referenced by multiple composite types. Therefore, when creating each TType object, other types involved in that type are also created at the same time.
3.4 映射数据的生存周期的自动管理  3.4 Automatic management of the life cycle of mapping data
由于测试主机和目标机的系统资源是有限的, 为了更有效地进行测试, 在相应时期对使用资源的处理是十分重要的。 根据本发明, 为了有效利用 系统資源, 变量、 函数、 类对象等在脚本语言中作为一个实体存在, 实现 了生存周期自动管理。 这些实体所占用的资源会自动申请、 自动释放。 映 射数据作为脚本类对象, 也支持它所涉及资源的自动申请与释放。 例如, 脚本系统 21要创建一个映射变量 buff, 它是一个长度为 24字 节的字串数组, 这时脚本系统 21会向目标机 2 自动申请它占用的内存, 包 括 buff变量作为脚本 TData类实例要占用的内存空间, 以及字串数组的 24 字节空间。 为描述方便, 在本发明中, 将前一类空间称为脚本实例空间, 将后一类空间称为 C/C++实例空间 (本说明中简称 C实例空间) 。 当新创 建的映射变量的生存周期结束时, 这两种空间都将被自 '动释放。 Since the system resources of the test host and the target machine are limited, in order to test more effectively, it is very important to handle the use of resources in the corresponding period. According to the present invention, in order to effectively utilize system resources, variables, functions, class objects, and the like exist as an entity in a scripting language, and automatic life cycle management is realized. The resources occupied by these entities are automatically applied and automatically released. Mapping data as a script class object also supports the automatic application and release of the resources it involves. For example, the script system 21 creates a mapping variable buff, which is an array of strings of length 24 bytes. At this time, the script system 21 automatically requests the memory occupied by the target machine 2, including the buff variable as an example of the script TData class. The amount of memory to occupy, and the 24-byte space of the string array. For convenience of description, in the present invention, the former type of space is referred to as a script instance space, and the latter type of space is referred to as a C/C++ instance space (referred to as a C instance space in this description). When the life cycle of the newly created mapping variable ends, both spaces will be released.
但是, 由于编程的复杂生, 脚本实例空间与 C实例空间并不总是同时 申请或同时释放的。 例如对于被测系统的全局变量, 其占用空间是静态分 配的, 全局变量的映射实体在生存周期结束时, 应只释放脚本实例空间, 而不应释放 C实例空间。 再如, 使用脚本文件中创建一个映射变量 a后, 这个变量的脚本实例空间与 C实例空间应同时申请或释放。 但是, 如果把 这个映射变量 a看成另一类型的映射变量 b, 例如 C语言中的强制类型转 换时, 将同一地址空间下某变量, 看成另一类型的变量, 则创建变量 b时 应新申请脚本实例空间, 但不应重复申请 C实例空间。 另外, 当变量 a或 变量 b被删除时, 不管先删除哪一个, 都应保证尚在使用的另一个变量所 操作的 C实例空间还有效。 也即: C实例空间可被多个映射变量共享, 只 有该 C实例空间所全部涉及的映射变量都释放了, 这个 C实例空间才自动 被释放。 此外, 映射变量使用的 C实例空间还需配合测试, 必要情况下可 修改其中的标志。 例如为映射变量设置 Autofree属性, 该属性为 TRUE表 示该映射变量的 C实例空间是随它的脚本实例空间释放而释放的, 否则属 性取值为 FALSE , 表示 C实例空间不随脚本实例空间释放而释放。  However, due to the complexity of programming, the script instance space and the C instance space are not always applied or released at the same time. For example, for the global variables of the system under test, the occupied space is statically allocated. The mapping entity of the global variable should only release the script instance space at the end of the life cycle, and should not release the C instance space. For another example, after creating a mapping variable a in the script file, the script instance space of this variable and the C instance space should be applied or released at the same time. However, if this mapping variable a is treated as another type of mapping variable b, such as a mandatory type conversion in C language, a variable in the same address space is treated as another type of variable, then the variable b should be created. Newly apply for script instance space, but you should not apply for C instance space repeatedly. In addition, when the variable a or the variable b is deleted, regardless of which one is deleted first, it should be guaranteed that the C instance space operated by another variable that is still in use is still valid. That is: the C instance space can be shared by multiple mapping variables, and only the mapping variables involved in the C instance space are released, and the C instance space is automatically released. In addition, the C instance space used by the mapping variable needs to be tested together, and the flag can be modified if necessary. For example, the Autofree attribute is set for the mapping variable. The attribute is TRUE, indicating that the C instance space of the mapping variable is released with the release of its script instance space. Otherwise, the value of the attribute is FALSE, indicating that the C instance space is not released with the release of the script instance space. .
为实现上述目的, 根据本发明的一个实施方式, 对映射实体设置了 3 个属性。 图 8显示了映射实体的一个示例。 如图 8所示, 该属性包括: 是 否自动释放内存 ( Autofree ) 、 符号来源(Owner)、 相对于来源的偏移地址 ( Offset ) 。 其中 "是否自动释放内存" 的属性用于指示该映射变量的 C实 例空间是否跟随脚本实例空间一起释放。 "符号来源" 用于指示该映射实 体的归属对象, 其取值既可以是某绝对地址值, 也可以是另一个映射实体。 相对于来源的偏移地址用于指示本映射实体所用 C.实例空间的起始地址相 对于其符号来源指示的空间地址的偏移量是多少。 由于脚本语言具备生存 周期自动管理特性, 所以如果使符号来源属性指示另一映射实例, 就实现 了同一 C实例空间被多个映射实例共用时也能够实现资源的自动管理。  To achieve the above object, according to one embodiment of the present invention, three attributes are set for the mapping entity. Figure 8 shows an example of a mapped entity. As shown in Figure 8, this attribute includes: Yes No Auto Free Memory (Autofree), Symbol Source (Owner), Offset Address (Offset) relative to the source. The attribute "whether the memory is automatically freed" is used to indicate whether the C instance space of the mapped variable is released along with the script instance space. The "symbol source" is used to indicate the attribution object of the mapping entity, and its value can be either an absolute address value or another mapping entity. The offset address relative to the source is used to indicate the offset of the starting address of the C. instance space used by the mapping entity relative to the spatial address indicated by its symbol source. Since the scripting language has the automatic lifecycle management feature, if the symbol source attribute indicates another mapping instance, the automatic management of resources can be realized when the same C instance space is shared by multiple mapping instances.
3.5 搡作转向的实现  3.5 Implementation of the steering
综合前文所述, 本发明要求实现的操作转向包括下面几项:  In summary, the operational steering required by the present invention includes the following items:
1 ) 按数值方式给变量容器的子成员赋值时, 自动转向到子成员的 setValue方法调用; . ^ 2 ) 变量容器作为算子使用时 (即: 出现在数学运算或逻辑运算中, 或 者出现在映射函数调用的传入参数中) , 隐式转向到本对象的 getValue方 法调用, 来取其数值形式的值; 1) When assigning a value to a child member of a variable container by value, it automatically switches to the setValue method call of the child member; ^ 2) When the variable container is used as an operator (ie: in a mathematical operation or a logical operation, or in an incoming parameter of a mapping function call), implicitly redirects to the getValue method call of the object to take its value. Form value
3 ) 读写变量容器的数组子成员时, 分别自动转向到该数组成员的 getltem与 setltem方法调用; '  3) When reading and writing the array sub-members of the variable container, they are automatically redirected to the getltem and setltem method calls of the array member;
4 )读写变量容器的指针指向值时, 分别自动转向到该成员的 getPoint 与 setPoint方法调用;  4) When the pointer of the read/write variable container points to a value, it automatically switches to the member's getPoint and setPoint method calls respectively;
5 ) 变量容器直接用于函数调用时, 隐式转向到本对象的—call一方法 调用;  5) When the variable container is directly used for function call, it implicitly redirects to the call-method call of this object;
6 ) 变量容器在取自身描述值时 (如在 print等语句中使用) , 隐式转 向到本对象的— str一方法调用;  6) When the variable container takes its own description value (as used in print and other statements), it implicitly redirects to the --str method call of this object;
7 )变量容器用于获取自身表述值时(如在 repr等语句中使用) , 隐式 转向到本对象的—repr一方法调用。  7) When the variable container is used to obtain its own expression value (as used in repr and other statements), it implicitly redirects to the -repr method call of this object.
实现上述七种操作自动转向, 依赖于两个条件:  The automatic steering of the above seven operations depends on two conditions:
其一, 应有一种形式来定义目标转向函数  First, there should be a form to define the target steering function.
口前文所述, 这些目标 向函数 (如 getValue、 set Value、 getltem、 setltem ^ getPoint;、 setPoint ― call―、― str―、― repr一 )都作为 TContainer 的类方法定义到变量容器中。  As mentioned earlier, these targets are defined in the variable container as functions of TContainer (such as getValue, setValue, getltem, setltem ^ getPoint;, setPoint - call -, "str", "repr").
目.前已有一些脚本语言支持类似的实现, 例如 Python语言。 其中读写 类对象成员可分别被定向到 _getattr_与— setattr_ii两个函数。 只须在 Python的相关类定义中增加—getattr—与一 setattr一这两个类方法, 读写类 成员就能捕获并自动跳转。 类似地, Python也支持把类对象作为数組, 读 写其子成员时, 能自动跳转到该,类对 的 _getitem—与一 setitem—方法。 在 Python中若为类对象定义一 call一方法, 则把该对象作为函数来调用时, 也自动跳转到 __call—方法。 取描述值与取表述值也同样, 只要分别定义 —str—与— repr一方法即可。 所以, Python语言已能实现本发明所要求的 9 种转向中的 7种。 。  There are already some scripting languages that support similar implementations, such as the Python language. The members of the read-write class object can be directed to the _getattr_ and -setattr_ii functions, respectively. You only need to add -getattr - a setattr to the two class methods in Python's related class definitions. Read and write class members can capture and automatically jump. Similarly, Python also supports class objects as arrays. When reading and writing its children, it can automatically jump to the _getitem of the class pair and a setitem-method. If a call-method is defined for a class object in Python, then when the object is called as a function, it will automatically jump to the __call-method. The same is true for the description value and the representation value, as long as the -str_ and -repr methods are defined separately. Therefore, the Python language has been able to implement seven of the nine steerings required by the present invention. .
其二, 宿主解释器在解释运行过程中, 应能捕获该进行自动转向的场 合, '然后触发自动跳转。 这一点是对宿主解释器内核的解释执行能力提出 的要求。  Second, the host interpreter should be able to capture the automatic steering when interpreting the operation, and then trigger an automatic jump. This is a requirement for the ability to interpret the execution of the host interpreter kernel.
上述操作自动转向是可实现, 现有 Python语言已提供我们所要求 9种 转向中的 7 种。 只剩下读写变量容器的指针指向值 (跳转到 getPoint 与 setPoint )未提供, 读写指针的 "- >" 操作符在 Python语言中是非法的。 因 此, 本发明所要求的宿主脚本语言可以仿照 Python来开发。 因 Python是开 源产品, 依据本领域已有知识, 不难实现本专利所要求的映射操作隐式转 向的功能。 The automatic steering of the above operations is achievable, and the existing Python language has provided 7 of the 9 kinds of steering we have requested. Only the pointer to the value of the read-write variable container (jump to getPoint and setPoint) is not provided. The "->" operator for reading and writing pointers is illegal in the Python language. Therefore, the host scripting language required by the present invention can be developed in the same way as Python. Because Python is an open source product, based on the existing knowledge in the field, it is not difficult to implement the implicit mapping operation required by this patent. To the function.
4. 异构脚本语言的映射 4. Mapping of heterogeneous scripting languages
借助上文描述的变量容器的特性, 还可以实现将异构脚本语言映射到 宿主脚本语言。下面的实施例将以 Python与 CSE语言为例介绍该映射的实 现方法, Python (参见 www.python.org ) 用作异构脚本语言, CSE (参见 www.cse-soft.org )用作宿主脚本语言。 本领域技术人员可以理解, 该说明 仅为示例, 本发明的实施并不限于这两种语言。  With the features of the variable container described above, it is also possible to map a heterogeneous scripting language to a host scripting language. The following example will introduce the implementation of this mapping using Python and CSE as an example. Python (see www.python.org) is used as a heterogeneous scripting language, and CSE (see www.cse-soft.org) is used as a host script. Language. Those skilled in the art will appreciate that the description is merely an example and that the implementation of the invention is not limited to the two languages.
4.1映射内容  4.1 mapping content
异构脚本映射通常以脚本模块为单位, 涉及被映射的对象也限于被映 射语言在模块摔口级别所能提供的实体, 主要包括: 变量(包括类对象) 、 函数。  Heterogeneous script mapping is usually in the form of script modules. The objects involved in mapping are also limited to the entities that can be provided by the mapped language at the module's crest level, including: variables (including class objects) and functions.
异构脚本映射的内容包括三个方面:  The content of heterogeneous script mapping includes three aspects:
i )实现异构脚本系统规定的基本类型数据的映射, 支持针对该映射实 体的相关操作, 包括: 创建、 释放、 读值、 赋值、 函数调用。  i) Implement mapping of basic type data specified by the heterogeneous scripting system, and support related operations for the mapping entity, including: create, release, read, assign, and function call.
2 )实现异构脚本系统中的类实例映射,支持针对该类实例的相关操作, 包括: 创建、 释放、 读写成员、 调用类方法。  2) Implement class instance mapping in a heterogeneous scripting system, and support related operations for the class instance, including: creating, releasing, reading and writing members, and calling class methods.
3 )把异构脚本系统中的一个模块映射到宿主脚本系统中的一个变量容 器中。 ,  3) Map a module in a heterogeneous scripting system to a variable container in the host scripting system. ,
以上三个方面涉及异构脚本映射所包含的 3种映射实体, 即: 基本类 型数据映射、 类实例映射、 脚本模块映射。  The above three aspects involve the three mapping entities included in the heterogeneous script mapping, namely: basic type data mapping, class instance mapping, and script module mapping.
这三类映射实体都是宿主脚本的 TData类对象。 同样, 该 TData类对 象中记录 TType实例数据, 以此指示该映射实体在被映射系统中的数据类 型。 用于异构脚本映射的 TData与 TType结构定义应与前文所述的 C/C++ 映射所用的 TData与 TType维持一致。 如果某些属性定义未使用, 例如, 用于指示映射实例的 C实例空间是否跟随脚本实例空间一起释放的属性不 再被使用, 则保留不用就行了。  These three types of mapping entities are all TData class objects of the host script. Similarly, the TType class object records the TType instance data, thereby indicating the data type of the mapping entity in the mapped system. The TData and TType structure definitions for heterogeneous script mapping should be consistent with the TData and TType used in the C/C++ mapping described earlier. If some attribute definitions are not used, for example, the attribute used to indicate whether the C instance space of the mapped instance is released with the script instance space is no longer used, then leave it alone.
4.2基本类型数据映射 ' 常见脚本语言,如 Python、 Ruby, TCL都有整型( int )、浮点型 ( float )、 字串 (string )、 函数(function )等基本类型。 这些基本类型数据作为存在 于异构脚本系统中的特定格式的数据, 不能直接用作宿主脚本语言中的变 量。 否则, 数据存取会发生错误。 相同类型的数据在两个异构系统中, 其 内部格式并不相同。 基本类型数据映射的目的是要保证相同类型数据在跨 语言传递时能自动转换。  4.2 Basic Type Data Mapping 'Common scripting languages such as Python, Ruby, and TCL have basic types such as integer (int), float (float), string (string), and function. These basic type data, as data in a specific format that exists in heterogeneous scripting systems, cannot be directly used as variables in the host scripting language. Otherwise, an error occurs in data access. The same type of data is in two heterogeneous systems, and its internal format is not the same. The purpose of basic type data mapping is to ensure that the same type of data is automatically converted when passed across languages.
被映射的基本类型数据在跨语言存取(例如取值或赋值, 或在函数参 数或返回值中传递) 时要做隐式转换。 因此, 涉及大数据量传递的类型不 宜用作基本类型来映射, 如下文所述, 而应作为一种类对象形式进行映射。The basic type data being mapped is accessed across languages (such as values or assignments, or in function arguments) Implicit conversions are made when the number or return value is passed. Therefore, types involving large data transfers are not suitable for use as primitive types for mapping, as described below, but should be mapped as a class object form.
― 在此同样是使用 TType类实例记录异构脚本系统中各个基本类型的相 关信息, 包括类型定义, 类型长度等。 这些信息可以通过异构脚本系统的 API 函数来获得。 例如调用 Python的内嵌函数 "type(obj)" 可以获得指定 变量的类型, 调用内嵌函数 "len(obj)" 可以获得指定变量的长度, 等等。 ― Here again, the TType class instance is used to record information about each basic type in the heterogeneous script system, including type definition, type length, and so on. This information can be obtained through the API functions of the heterogeneous scripting system. For example, calling Python's inline function "type(obj)" can get the type of the specified variable, call the inline function "len(obj)" to get the length of the specified variable, and so on.
同样, 在本实施例中, 使用 TData类表达映射实体。 当然, TData类 从 TContainer继承而来, 也属于变量容器。 在 TData类实例中同样要记录 该映射实体的类型 (TType的值) 、 实体对象的地址等信息。  Also, in this embodiment, the TData class is used to express the mapping entity. Of course, the TData class inherits from TContainer and is also a variable container. In the TData class instance, the type of the mapping entity (the value of TType), the address of the entity object, and the like are also recorded.
新创建一个映射实体后, 异构脚本系统中被映射的对象要增加一次引 用计次, 这通过调用异构脚本系统提供的 API来实现。' 例如, Python中增 加一次引用的 API是 Py一 INCREF , 减少一次引用的 API是 Py一 DEC EF, 如果该映射实体被释放了, 相应被映射的对象的引用计次要减 1。  After a new mapping entity is created, the referenced object in the heterogeneous scripting system is incremented by one reference, which is implemented by calling the API provided by the heterogeneous scripting system. For example, the API for adding a reference in Python is Py-INCREF, and the API for reducing one reference is Py-DEC EF. If the mapped entity is released, the reference of the corresponding mapped object is decremented by 1.
如前文所述, 针对映射实体的操作通过读写子成员、 读写数組成员、 调用实体、 取自身描述值、 以及取自身表述值时的隐式转向功能, 在转向 目标函数中实现具体的、 针对被映射实体的特定操作。 具体操作实现通过 调用异构脚本系统的 API来完成。 例如, 异构脚本系统若是 Python, 调用 映射函数后隐式转向到— call一方法调用。 本发明在— call—方法中调用 Python提供的 API来调用被映射系统中的相关函数。在 Python中调用函数 的 API 是 PyObject— CallFunction , 调 用 类 方 法 的 API 是 PyObject_CallMethod。  As described above, the operation of the mapping entity implements the specific function in the steering objective function by reading and writing the sub-member, reading and writing the array member, calling the entity, taking the self-description value, and the implicit steering function when taking the self-representation value. , specific operations for the mapped entity. The specific operation is achieved by calling the API of the heterogeneous script system. For example, if the heterogeneous scripting system is Python, the mapping function is called and implicitly redirected to the call-method call. The present invention calls the API provided by Python in the call-method to call the related function in the mapped system. The API that calls a function in Python is PyObject— CallFunction , and the API that calls the class method is PyObject_CallMethod.
4.3 i实例与脚本模块映射 .  4.3 i instance and script module mapping.
在许多脚本语言中, 基本类型与 class类经常没有明确区分, 如 Python 中的字典类型 (diet ) 。 尽管是基本类型, 但在本发明中稍作封装就完全可 以按类实例的方式使用。 例如下面的 Python代码:  In many scripting languages, the basic types are often not clearly distinguished from the class class, such as the dictionary type (diet) in Python. Although it is a basic type, it can be used in the form of a class example in the present invention. For example the following Python code:
class TDict: Class TDict:
def― init一 (self):  Def― init one (self):
self.— value = { } def setValue(self,key, value):  Self.— value = { } def setValue(self,key, value):
self.value[key] = value; def getValue(self,key):  Self.value[key] = value; def getValue(self,key):
self.value[key] ADict = TDict(); Self.value[key] ADict = TDict();
ADict.setValue(3,"abc"); # 等同于: ADict[3] = "abc";  ADict.setValue(3,"abc"); # is equivalent to: ADict[3] = "abc";
print ADict. get Value(3); # 等同于: print ADict[3]; Print ADict. get Value(3); # equate to: print ADict[3];
因为某些数据类型可能存贮庞大数据, 而基本数据在穿越两个异构脚 本系统时要做转换, 因此不便将涉及庞大数据的数据类型作为基本类型进 行跨语言传递, 以避免使用效率降低。 针对这种类型数据, 本发明是将其 视为一种类对象。 如对于上面举例的 Python字典类型, 先将其封装成类, 然后按类对象的形式实施映射。 在这种情况下, 尽管 diet数据作为整体并 不跨越两个异构脚本系统, 但 diet的组成元素是能正常跨越两个异构脚本 系统的。 例如:  Because some data types may store large amounts of data, and basic data is converted as it traverses two heterogeneous scripting systems, it is inconvenient to cross-language data types involving large amounts of data as basic types to avoid inefficient use. For this type of data, the present invention treats it as a class object. For the Python dictionary type exemplified above, first wrap it as a class and then implement the mapping as a class object. In this case, although the diet data as a whole does not span two heterogeneous scripting systems, the components of diet can normally span two heterogeneous scripting systems. E.g:
vc = newVarContainer("PYTHON");  Vc = newVarContainer("PYTHON");
vc. ADict = MapPyDict();  Vc. ADict = MapPyDict();
vc.ADict[3] = "abc"; II 隐式转向到调用: vc.ADict.setItem(3,"abc,,); print(vc.ADict[3]); II 隐式转向到调用: print(vc.ADict.getItem(3)); 在转向函数 setltem与 getltem中, 再调用 Python提供的 API, 实现对 Python字典数据的读写操作。  vc.ADict[3] = "abc"; II implicitly redirected to the call: vc.ADict.setItem(3,"abc,,); print(vc.ADict[3]); II implicitly redirected to call: print (vc.ADict.getItem(3)); In the turn function setltem and getltem, call the API provided by Python to read and write the Python dictionary data.
对于每个类对象映射实体的类方法调用, 同样可以通过动态生成一个 类方法的变量容器, 然后调用这个变量容器 (即类方法映射实体) , 就自 动转向到该类方法映射实体的—call一方法。 在_0&11—方法中, 可通过调 用 Python的 API实现专用的 Python类方法调用。 例如:  For the class method call of each class object mapping entity, you can also dynamically generate a variable container of a class method, and then call the variable container (that is, the class method mapping entity), then automatically turn to the call method of the class mapping entity - call one method. In the _0&11-method, a special Python class method call can be implemented by calling the Python API. E.g:
vc = newVarContainer("PYTHON");  Vc = newVarContainer("PYTHON");
vc.AObj = MapPyInstace('ACkss、,argl ,arg2); II 创建类实例映射实体 vc.AObj. method 1(1 , 2); // 第 1步: 执行 vc.AObj .method 1 vc.AObj = MapPyInstace('ACkss,,argl,arg2); II Create class instance mapping entity vc.AObj. method 1(1 , 2); // Step 1: Execute vc.AObj .method 1
Figure imgf000024_0001
Figure imgf000024_0001
〃第 2步: 动态生成一个 AObj.methodl映射函数 〃Step 2: Dynamically generate an AObj.methodl mapping function
〃 第 3步: 执行 AObj .methodl (1 ,2) 〃 Step 3: Execute AObj .methodl (1 , 2)
II 转向到 AObj .method 1.— call—( 1 ,2)  II turns to AObj .method 1.—call—( 1 ,2)
对于类对象映射实体, 每次调用其方法, 都动态生成一个对应的映射 函数, 然后调用映射函数时, 自动转向到该映射函数的— call一方法调用。 在—call—方法中再专项实现 Python相应类方法的正常调用过程。 即, 如 果异构语言是 Python就按 Python 的格式实现相应调用, 如果异构语言是 Ruby就-按 Ruby的格式实现相应调用。 当然, 调用的结果值也自动装配成 映射变量。  For the class object mapping entity, each time its method is called, a corresponding mapping function is dynamically generated, and when the mapping function is called, it automatically switches to the call method call of the mapping function. In the call-method, the special call process of the corresponding class method of Python is implemented. That is, if the heterogeneous language is Python, the corresponding call is implemented in Python format. If the heterogeneous language is Ruby, the corresponding call is implemented in Ruby format. Of course, the result values of the calls are also automatically assembled into mapped variables.
针对异构脚本语言的不同,从类定义中搜索它的成员的方法不尽相同。 但是, 无论异构脚本语言是 Python, 还是 Ruby或 TCL, 借助该脚本系统 提供 API及该脚本语言所定义的类型格式,总是可以遍历指定 class类下都 定义了哪些方法、 定义了哪些类成员的。 同样, 也总是可以遍历指定模块 下都定义了哪些对象实体。 例如 Python语言就提供一个 "dir(namespace)" 内嵌函数, 可以扫描指定域名空间下都定义哪些对象, 模块下都定义哪些 对象, class 类下都定义哪些属性。 这些都可以通过调用 dir函数来荻知。 所以, 对于类对象映射实体, 每次调用其方法都能动态获得相应函数定义, 都可以动态地生成一个映射函数。 For different heterogeneous scripting languages, the way to search for its members from a class definition is different. However, whether the heterogeneous scripting language is Python, or Ruby or TCL, with this scripting system Providing the API and the type format defined by the scripting language, it is always possible to traverse which methods are defined under the specified class class and which class members are defined. Similarly, it is always possible to traverse which object entities are defined under the specified module. For example, the Python language provides a "dir(namespace)" inline function that scans which objects are defined under the specified namespace, which objects are defined under the module, and which properties are defined under the class. These can be known by calling the dir function. Therefore, for a class object mapping entity, each time the method is called, the corresponding function definition can be dynamically obtained, and a mapping function can be dynamically generated.
也可以通过一次扫描异构脚本系统中的模块, 在获知该模块下都定义 哪些对象后, 再将这些对象按其 TType的不同生成不同的映射实体, 保存 到指定的变量容器之下。  You can also scan the modules in the heterogeneous script system. After you know which objects are defined under the module, you can generate different mapping entities according to their TType and save them under the specified variable container.
因为某些大型脚本语言如 Python、 Ruby能提供丰富的软件功能, 因此 本发明采用异构脚本语言映射, 可以大幅增强系统的调测能力。 将异构脚 本映射到宿主脚本语言, 一方面能够实现跨语言功能调用, ' 另一方面, 也 降低了学习门槛,,因为映射语法屏蔽了异构语言在表述上的差异。  Because some large scripting languages such as Python and Ruby can provide rich software functions, the present invention uses heterogeneous scripting language mapping, which can greatly enhance the system's debugging capabilities. Mapping heterogeneous scripts to the host scripting language, on the one hand, enables cross-language function calls, 'on the other hand, it also reduces the learning threshold, because the mapping syntax masks the differences in the representation of heterogeneous languages.

Claims

权利要求书: Claims:
1. 程序调测系统, 包括测试主机和目标机, 所述测试主机对所述目标 机的 C/C++目标程序系统进行调测, 其中, A program commissioning system, comprising: a test host and a target machine, wherein the test host performs commissioning on a C/C++ target program system of the target machine, wherein
所述目标机中包含映射支持模块, 所述映射支持模块包含变量容器; 所述变量容器是脚本的 TContainer类的类对象, 所述被调测的 C/C++ 目标程序系统中的变量和函数被映射成所述变量容器中的映射变量和映射 函数, 当以宿主脚本语言描述映射变量或映射函数的操作,时, 所述映射变 量和所述映射函数与被测试程序的相应变量和函数具有相似的表达;  The target machine includes a mapping support module, the mapping support module includes a variable container; the variable container is a class object of a script TContainer class, and variables and functions in the debugged C/C++ target program system are Mapping to a mapping variable and a mapping function in the variable container, when describing an operation of mapping a variable or a mapping function in a host scripting language, the mapping variable and the mapping function are similar to corresponding variables and functions of the tested program expression;
通过所述变量容器, 利用所述宿主脚本语言对所述映射变量和映射函 数的操作被转向到所述被调测的 C/C++目标程序系统中相应变量和函数的 操作。  Through the variable container, operations on the mapping variables and mapping functions using the host scripting language are diverted to operations of corresponding variables and functions in the C/C++ target program system being debugged.
2. 根据权利要求 1所述的程序调测系统, 其中在所述目标机中还包括 异构脚本语言系统, 用于提供测试服务的脚本系统。 ' 2. The program commissioning system according to claim 1, wherein the target machine further comprises a heterogeneous scripting language system for providing a scripting system for testing services. '
3. 根据权利要求 2所述的程序调测系统, 其中所述变量容器层层嵌套 构成变量容器树, 并且, 所述变量容器树中每个节点都具有 TContainer属 性。 3. The program commissioning system according to claim 2, wherein said variable container layer nesting constitutes a variable container tree, and each node in said variable container tree has a TContainer attribute.
4. 根据权利要求 3所述的程序调测系统, 其中所述变量容器树的根节 点中包括异构集容器, 所述异构集容器记录被映射系统的类型以及实施映 射所需的相关配置;和 4. The program commissioning system according to claim 3, wherein a root node of the variable container tree includes a heterogeneous set container, the heterogeneous set container records a type of the mapped system and a related configuration required to implement the mapping ;with
所述映射变量与所述映射函数都是脚本 TData类的类对象,所述 TData 类从 TContainer类继承而来, 所述映射变量与所述映射函数都记录在所述 异构集容器中。  The mapping variable and the mapping function are both class objects of the script TData class, the TData class inherits from the TContainer class, and the mapping variable and the mapping function are recorded in the heterogeneous set container.
5'. 根据权利要求 2所述的程序调测系統, 其中所述变量容器树中还包 含复合数据映射变量, 所述复合数据映射变量的层次和子成员从属关系与 映射之前保持一致,所述复合数据包括 C/C++语言中的 class, struct, union, 以及所述异构脚本系统中的类定义。 The program commissioning system according to claim 2, wherein the variable container tree further includes a composite data mapping variable, and the hierarchical and sub-member affiliation of the composite data mapping variable is consistent with that before the mapping, the composite The data includes classes, structs, unions in the C/C++ language, and class definitions in the heterogeneous scripting system.
6. 根据权利要求 1所述的程序调测系统, 其中所述目标机包含宿主脚 本解释器, 当对所述变量容器中的所述映射变量的赋值操作在所述宿主脚 本解释器中用脚本语言表达时, 缺省保持所述 C/C++目标程序系统的强类 型风格, 其中: 6. The program commissioning system of claim 1, wherein the target machine includes a host script interpreter, wherein an assignment operation to the map variable in the variable container is scripted in the host script interpreter When the language is expressed, the strong class of the C/C++ target program system is maintained by default. Style, where:
对所述变量容器下子成员赋值时, 在赋值前后子成员的类型不发生变 化, 只修改该子成员的映射实体所代表的处于被映射系统中的数值;  When assigning a value to a child member of the variable container, the type of the child member does not change before and after the assignment, and only the value represented by the mapping entity of the child member in the mapped system is modified;
在所述宿主脚本解释器中使用 API 能够删除所述变量容器下的指定子 成员。  Using the API in the host script interpreter can remove the specified sub-members under the variable container.
7. 根据权利要求 6所述的程序调测系统, 其中还允许非缺省的弱类型 风格。 7. The program commissioning system of claim 6, wherein a non-default weak type style is also allowed.
8. 根据权利要求 1所述的程序调测系统, 其中所述宿主脚本解释器与 所述变量容器在针对所述映射变量或所述映射函数进行读 /写或函数调用 时具备自动转向的功能, 包括: 8. The program commissioning system according to claim 1, wherein the host script interpreter and the variable container have an automatic steering function when performing read/write or function call for the mapping variable or the mapping function. , including:
由所迷宿主脚本解释器捕获对映射变量或映射函数的操作;和  Capturing operations on mapping variables or mapping functions by the host script interpreter; and
隐式触发与所捕获的相关操作相应的目标转向函数。 '  The target steering function corresponding to the captured related operation is implicitly triggered. '
9. 根据权利要求 8所述的程序调测系统, 其中所有所述目标转向函数 都作为类方法定义在映射实体中。 9. The program commissioning system of claim 8, wherein all of the target steering functions are defined as class methods in a mapping entity.
10. 根据权利要求 8 所述的程序调测系统, 其中所述宿主脚本解释器 捕获对映射变量或映射函数的操作包括: 10. The program commissioning system according to claim 8, wherein the operation of the host script interpreter to capture a mapping variable or a mapping function comprises:
读取映射实体自身或其子成员的数值;  Read the value of the mapped entity itself or its child members;
给映射实体的子成员赋值;  Assign values to child members of the mapped entity;
读取数組映射实体的子成员;  Read the child members of the array mapping entity;
给数组映射实体的子成员赋值;  Assign a value to a child member of an array map entity;
读取映射实体的指针指向值;  Read the pointer of the mapped entity to the value;
给映射实体的指针指向赋值;  Pointer to the mapping entity points to the assignment;
调用映射实体;  Calling the mapping entity;
取映射实体的描述值;  Take the description value of the mapping entity;
取映射实体的表述值。  Take the representation value of the mapped entity.
11. 根据权利要求 1 所述的程序调测系统, 其中所述宿主脚本解释器 自动管理映射实体的资源空间, 所述资源空.间包括 C实例空间和脚本实例 空间, 所述自动管理包括: The program commissioning system according to claim 1, wherein the host script interpreter automatically manages a resource space of a mapping entity, where the resource space includes a C instance space and a script instance space, and the automatic management includes:
脚本实例空间与 C实例空间同时申请与释放;  The script instance space is applied and released simultaneously with the C instance space;
全局变量的资源空间自动管理: 所述 C 实例空间不随所述脚本实例空 间一起申请和释放; Automatic management of resource space for global variables: The C instance space is not empty with the script instance Apply and release together;
由一个映射变量生成另一个映射变量时的资源空间自动管理: 所述 C 实例空间随第一个映射变量的脚本实例空间申请而申请, 并随最后一个共 用所述 C实例空间的映射变量的脚本实例空间的释放而释放; 以及  Automatic resource space management when another mapping variable is generated by one mapping variable: The C instance space is applied with the script instance space request of the first mapping variable, and the last script that shares the mapping variable of the C instance space Released by the release of the instance space;
支持手工修改映射变量的标志, 对所述 C实例空间是否随变量的脚本 实例空间的释放而释放进行控制。  Supports manual modification of the flag of the mapped variable to control whether the C instance space is released with the release of the script's instance space of the variable.
12. 根据权利要求 4所述的程序调测系统, 其中所迷 TData对象包括 如下属性: 12. The program commissioning system according to claim 4, wherein the TData object includes the following attributes:
用于指示所述映射实例的数据类型的属性;  An attribute indicating a data type of the mapping instance;
用于指示所述映射实例的 C 实例空间是否跟随脚本实例空间一起释放 的属性;  An attribute indicating whether the C instance space of the mapping instance is released along with the script instance space;
用于指示所述映射实例的 C实例空间的归属对象的属性; 和 , 用于指示所述映射实例使用的 C 实例空间相对其归属对象的偏移的属 性。  An attribute of a home object used to indicate a C instance space of the mapping instance; and an attribute indicating an offset of a C instance space used by the mapping instance relative to its home object.
13. 一种应用于程序调测系统中的映射方法, 所述程序调测系统包括 测试主机和目标机, 所述测试主机对所述目标机中的程序进行调测, 在所 述目标机中包含映射支持模块, 所述方法包括: ' 13. A mapping method applied to a program commissioning system, the program commissioning system comprising a test host and a target machine, wherein the test host performs commissioning on a program in the target machine, in the target machine Include a mapping support module, the method comprising: '
1 )所述映射支持模块根据被调测程序被编译后的调试数据库产生所述 被测试程序的符号表和类型表;  1) the mapping support module generates a symbol table and a type table of the tested program according to the debug database compiled by the debugger;
2 ) 所述映射支持模块将所述类型表、 符号表中的变量和函数都映射至 变量容器中, 生成由宿主脚本系统可操作的映射变量和映射函数,  2) the mapping support module maps the variables and functions in the type table and the symbol table to a variable container, and generates a mapping variable and a mapping function operable by the host script system.
其中, 所迷变量容器是脚本 TContainer类的类对象。  Among them, the variable container is a class object of the script TContainer class.
14. 根据权利要求 13所述的方法, 还包括在所述目标机有选择地驻留 一个与宿主脚本语言不同的异构脚本系统, 所述异构脚本系统中变量、 函 数能够映射到宿主脚本系统的变量容器中。 14. The method of claim 13, further comprising selectively hosting a heterogeneous scripting system different from a host scripting language in the target machine, wherein variables, functions in the heterogeneous scripting system can be mapped to a host script The variable container of the system.
15.根据权利要求 14所述的方法,其中在所述变量容器中对所述 C/C++ 目标程序系统的映射变量赋值的操作在所述宿主脚本系统的宿主脚本解释 器中用脚本语言表达时, 按如下方式缺省保持被映射系统的强类型风格: 对所述变量容器下子成员赋值时, 在赋值前后子成员的类型不发生变 化, 只修改该子成员映射实体所代表的处于被映射系统中的数值; 15. The method of claim 14, wherein the operation of assigning a value of a mapping variable of the C/C++ target program system in the variable container is expressed in a scripting language in a host script interpreter of the host script system The default type of the mapped system is maintained as follows: When assigning values to sub-members of the variable container, the type of the child member does not change before and after the assignment, and only the system represented by the sub-member mapping entity is modified. Value in
在所述宿主脚本解释器使用一个 API删除所述变量容器下指定子成员。 The host script interpreter uses an API to delete the specified sub-members under the variable container.
16. 根据权利要求 15所述的方法, 其中所述宿主脚本解释器与所述变 量容器在针对所迷映射变量或所述映射函数进行读写或函数调用时, 按如 下方式实现自动转向的功能: 16. The method according to claim 15, wherein the host script interpreter and the variable container implement automatic steering function as follows when performing read/write or function call on the mapped variable or the mapping function. :
由所述宿主脚本解幹器捕获对映射变量或映射函数的操作;和  Capturing operations on mapping variables or mapping functions by the host script de-spreader; and
隐式触发与所捕获的相关操作相应的目标转向函数。  The target steering function corresponding to the captured related operation is implicitly triggered.
17. 根据权利要求 16所述的方法, 其中所有所述目标转向函数都作为 类方法定义在映射实体中, 所述映射实体包括所述映射变量和映射函数, 包括: The method according to claim 16, wherein all the target steering functions are defined as a class method in a mapping entity, the mapping entity including the mapping variable and a mapping function, including:
用于读取映射实体自身或其子成员数值时自动转向到 getValue方法; 用于给映射实体的子成员赋值时自动转向到 setValue方法;  It is used to automatically switch to the getValue method when reading the value of the mapping entity itself or its sub-members; it is used to automatically redirect to the setValue method when assigning values to the child members of the mapping entity;
用于读取数組映射实体的子成员时自动转向到 getltem方法; 用于给数组映射实体的子成员赋值时自动转向到 setltem方法; 用于读取映射对象的指针指向值时自动转向到 getPoint方法; 用于给映射实体的指针指向赋值时自动转向到 setPoint方法; 用于调用映射实体时自动转向到— call一方法;  Used to read the child members of the array mapping entity automatically to the getltem method; used to automatically assign to the setltem method when assigning values to the child members of the array mapping entity; automatically redirects to getPoint when the pointer used to read the mapping object points to the value Method; is used to automatically point to the setPoint method when the pointer to the mapping entity points to the assignment; automatically redirects to the call-call method when calling the mapping entity;
用于取映射实体的描迷值时自动转向到一 str_方法;  Automatically switch to a str_ method when used to fetch the value of the mapped entity;
用于取映射实体的表述值时自动转向到— repr—方法。  Used to take the representation value of the mapped entity and automatically switch to the -repr-method.
18. 根据权利要求 17所述的方法, 其中所述宿主脚本解释器捕获对映 射变量或映射函数的操作包括: 18. The method of claim 17, wherein the operation of the host script interpreter to capture a mapping variable or mapping function comprises:
读取映射实体自身或其子成员的数值;  Read the value of the mapped entity itself or its child members;
给映射实体的子成员赋值;  Assign values to child members of the mapped entity;
读取数组映射实体的子成员;  Read the child members of the array mapping entity;
给数组映射实体的子成员赋值;  Assign a value to a child member of an array map entity;
读取映射实体的指针指向值;  Read the pointer of the mapped entity to the value;
给映射实体的指针指向赋值;  Pointer to the mapping entity points to the assignment;
调用映射实体;  Calling the mapping entity;
取映射实体的描述值;和  Take the description value of the mapped entity; and
取映射实体的表述值。  Take the representation value of the mapped entity.
PCT/CN2007/003244 2006-11-17 2007-11-16 Mapping method in the program testing system and program testing system WO2008058473A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2007800016987A CN101401075B (en) 2006-11-17 2007-11-16 Mapping method in the program testing system and program testing system

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN200610145196.9 2006-11-17
CNA2006101451969A CN1949186A (en) 2006-11-17 2006-11-17 Program testing system and mapping method for said program testing system

Publications (1)

Publication Number Publication Date
WO2008058473A1 true WO2008058473A1 (en) 2008-05-22

Family

ID=38018710

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2007/003244 WO2008058473A1 (en) 2006-11-17 2007-11-16 Mapping method in the program testing system and program testing system

Country Status (2)

Country Link
CN (2) CN1949186A (en)
WO (1) WO2008058473A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103729288A (en) * 2013-11-01 2014-04-16 华中科技大学 Application program debugging method under embedded multi-core environment
CN107729254A (en) * 2017-11-10 2018-02-23 郑州云海信息技术有限公司 A kind of implementation method for safeguarding Batch orders technique automatically by shell scripts
CN113407454A (en) * 2021-06-29 2021-09-17 山东派盟网络科技有限公司 Method, device and equipment for comprehensive test
CN114629830A (en) * 2022-03-02 2022-06-14 深圳市吉祥腾达科技有限公司 Method and system for automatically controlling TestCenter instrument test
CN117171044A (en) * 2023-08-16 2023-12-05 上海同星智能科技有限公司 Development and debugging system and method based on automatic read-write method of automobile calibration signals

Families Citing this family (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1949186A (en) * 2006-11-17 2007-04-18 深圳市领测科技有限公司 Program testing system and mapping method for said program testing system
CN101114940B (en) * 2007-06-26 2011-12-07 中兴通讯股份有限公司 Method for implementing module logicalization
US9141513B2 (en) 2009-10-01 2015-09-22 Kryterion, Inc. Maintaining a secure computing device in a test taking environment
US9280907B2 (en) 2009-10-01 2016-03-08 Kryterion, Inc. Proctored performance analysis
CN102135935A (en) * 2010-01-22 2011-07-27 华为技术有限公司 Software optimizing and debugging method and device
US10672286B2 (en) 2010-03-14 2020-06-02 Kryterion, Inc. Cloud based test environment
US8713130B2 (en) 2010-08-04 2014-04-29 Kryterion, Inc. Peered proctoring
US9137163B2 (en) 2010-08-04 2015-09-15 Kryterion, Inc. Optimized data stream upload
CN103176894B (en) * 2011-12-22 2017-06-23 中国银联股份有限公司 A kind of test data automatic derivatization method and apparatus of data base-oriented
CN102629277A (en) * 2012-03-21 2012-08-08 北京英孚斯迈特信息技术有限公司 General structured query language (SQL) data processing method and system
CN103049377B (en) * 2012-12-14 2016-01-13 中国信息安全测评中心 Based on the parallel symbol manner of execution of path cluster reduction
CN103559123B (en) * 2013-10-24 2016-02-10 烽火通信科技股份有限公司 Based on function call stack analytical approach and the device of vxworks operating system
CN104731695B (en) * 2013-12-19 2018-11-09 广州凯乐软件技术有限公司 A kind of unit test system and method for supporting the input of table driving bottom
WO2015165078A1 (en) * 2014-04-30 2015-11-05 Hewlett-Packard Development Company, L.P. Performing mirror test for localization testing
CN105573903A (en) * 2014-10-11 2016-05-11 中兴通讯股份有限公司 Automatic test method, automatic test device, automatic test system and access proxy
CN104298600A (en) * 2014-10-23 2015-01-21 广州华多网络科技有限公司 Software testing method and device
CN105808421A (en) * 2014-12-31 2016-07-27 中兴通讯股份有限公司 White box test realization method and test control end
CN104881358B (en) * 2015-05-28 2018-02-16 南京南瑞继保电气有限公司 A kind of procedure simulation method of testing and system
CN106126431A (en) * 2016-08-23 2016-11-16 腾讯科技(深圳)有限公司 Performance test methods and system
CN106445829A (en) * 2016-10-21 2017-02-22 天津海量信息技术股份有限公司 Debugging debug method with large data indexing rules
CN106610838B (en) * 2016-12-27 2020-04-24 北京酷我科技有限公司 Conversion method of multiple scripting languages
CN107766252A (en) * 2017-11-08 2018-03-06 平安科技(深圳)有限公司 Test script automated execution method, apparatus, equipment and storage medium
CN109344083B (en) * 2018-11-05 2022-07-08 郑州云海信息技术有限公司 Program debugging method, device and equipment and readable storage medium
CN109960590B (en) * 2019-03-26 2021-05-18 北京简约纳电子有限公司 Method for optimizing diagnostic printing of embedded system
CN110347594B (en) * 2019-06-28 2023-03-10 上海电气泰雷兹交通自动化系统有限公司 Static variable synchronization and setting method in CBTC system safety function module test
CN110853327B (en) * 2019-11-02 2021-04-02 杭州雅格纳科技有限公司 Ship cabin equipment data field debugging and collecting method and device based on single chip microcomputer
CN114124772A (en) * 2021-11-05 2022-03-01 中国航空工业集团公司雷华电子技术研究所 Network debugging method based on VxWorks operating system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1477800A (en) * 2002-08-20 2004-02-25 华为技术有限公司 Mirror image test method
KR20040087767A (en) * 2003-04-09 2004-10-15 바산네트워크(주) Development of Realtime, Embedded S/W Component Testing and Realtime Analysis Methods and Systems
CN1737775A (en) * 2004-08-18 2006-02-22 华为技术有限公司 Automated testing apparatus and method for embedded software
CN1763717A (en) * 2005-11-24 2006-04-26 北京中星微电子有限公司 System and method for calling host software functions by using script and its compiler
CN1949186A (en) * 2006-11-17 2007-04-18 深圳市领测科技有限公司 Program testing system and mapping method for said program testing system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5600579A (en) * 1994-07-08 1997-02-04 Apple Computer, Inc. Hardware simulation and design verification system and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1477800A (en) * 2002-08-20 2004-02-25 华为技术有限公司 Mirror image test method
KR20040087767A (en) * 2003-04-09 2004-10-15 바산네트워크(주) Development of Realtime, Embedded S/W Component Testing and Realtime Analysis Methods and Systems
CN1737775A (en) * 2004-08-18 2006-02-22 华为技术有限公司 Automated testing apparatus and method for embedded software
CN1763717A (en) * 2005-11-24 2006-04-26 北京中星微电子有限公司 System and method for calling host software functions by using script and its compiler
CN1949186A (en) * 2006-11-17 2007-04-18 深圳市领测科技有限公司 Program testing system and mapping method for said program testing system

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103729288A (en) * 2013-11-01 2014-04-16 华中科技大学 Application program debugging method under embedded multi-core environment
CN107729254A (en) * 2017-11-10 2018-02-23 郑州云海信息技术有限公司 A kind of implementation method for safeguarding Batch orders technique automatically by shell scripts
CN113407454A (en) * 2021-06-29 2021-09-17 山东派盟网络科技有限公司 Method, device and equipment for comprehensive test
CN113407454B (en) * 2021-06-29 2022-08-05 山东派盟网络科技有限公司 Method, device and equipment for comprehensive test
CN114629830A (en) * 2022-03-02 2022-06-14 深圳市吉祥腾达科技有限公司 Method and system for automatically controlling TestCenter instrument test
CN114629830B (en) * 2022-03-02 2023-08-11 深圳市吉祥腾达科技有限公司 Method and system for automatically controlling test center instrument test
CN117171044A (en) * 2023-08-16 2023-12-05 上海同星智能科技有限公司 Development and debugging system and method based on automatic read-write method of automobile calibration signals

Also Published As

Publication number Publication date
CN101401075A (en) 2009-04-01
CN101401075B (en) 2012-01-04
CN1949186A (en) 2007-04-18

Similar Documents

Publication Publication Date Title
WO2008058473A1 (en) Mapping method in the program testing system and program testing system
US7010796B1 (en) Methods and apparatus providing remote operation of an application programming interface
US7444619B2 (en) Inter-process communication using different programming languages
KR100995199B1 (en) Reflection-based processing of input parameters for commands
Robinson et al. PROFESSIONAL C# (2004 Ed.)
US7627594B2 (en) Runtime support for nullable types
JP2000099332A (en) Remote procedure call optimization method and program execution method using the optimization method
US6986124B1 (en) Debugger protocol generator
Zhu et al. Safe programming with pointers through stateful views
EP0912934A1 (en) Method and apparatus for transporting interface definition language-defined data structures between heterogeneous systems
JP2000515280A (en) Object-oriented information transmission method and apparatus
KR101103973B1 (en) Method and apparatus for performing adjustable precision exception handling
US20090320007A1 (en) Local metadata for external components
US7752596B2 (en) Connecting alternative development environment to interpretive runtime engine
US6799320B1 (en) Providing binding options for component interfaces
JPH05224949A (en) Method and apparatus for converting abstract syntax in high-level configuration into intermediate configuration
US6708310B1 (en) Method and system for implementing user-defined codeset conversions in a computer system
Monnier et al. Evolution of emacs lisp
US7934193B2 (en) Processing a module specification to produce a module definition
Parson Using Java reflection to automate extension language parsing
US7590975B1 (en) Mechanism for translation of data in an execution framework
Bell et al. Learn to Tango with D
Geisseler et al. GslAtorPtr-C++ core guidelines pointer checker and support library refactorings
Chisnall Cocoa programming developer's handbook
Chuang et al. Non‐intrusive object introspection in C++

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 200780001698.7

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 07816850

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS EPO FORM 1205A DATED 30.09.2009.

122 Ep: pct application non-entry in european phase

Ref document number: 07816850

Country of ref document: EP

Kind code of ref document: A1