CN108614680A - A kind of automatic generation method and system of information inquiring command program - Google Patents
A kind of automatic generation method and system of information inquiring command program Download PDFInfo
- Publication number
- CN108614680A CN108614680A CN201611155269.2A CN201611155269A CN108614680A CN 108614680 A CN108614680 A CN 108614680A CN 201611155269 A CN201611155269 A CN 201611155269A CN 108614680 A CN108614680 A CN 108614680A
- Authority
- CN
- China
- Prior art keywords
- file
- order
- command
- debugger
- binary image
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/22—Procedural
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/447—Target code generation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention belongs to embedded development fields, are related to a kind of automatic generation method and system of information inquiring command program, including automatic generator (1), debugger (2), typelib binary image and generation command-in file;It generates command-in file and is formed by generating order and character text two parts, generate the function association of order and debugger (2), for searching the return value in type binary image, the return value will substitute generation order, character text is constant part, is uniformly output in information inquiring command program;Type binary image includes the data structure information of remote system object to be checked;Command-in file is generated to be input into automatic generator (1), automatic generator (1) controls debugger (2) analysis type library binary image, return value is obtained according to order operation is generated, automatic generator (1) replaces the generation order in command-in file with return value and ultimately generates information inquiring command program.
Description
Technical field
The invention belongs to embedded development fields, and in particular to a kind of automatic generation method of information inquiring command program and
System.
Background technology
When carrying out embedded software developing, current more common way is to use embedded integration development environment.It is embedded
Formula Integrated Development Environment is a series of set of developing instruments, including source code editor, engineering management, cross compile, debugging, is gone back
Including tools such as some advanced developing instruments, such as remote system browsing etc..Embedded-development environment provides (general in host side
PC machine) development goal equipment (being typically the embedded computer being made of processors such as X86, PowerPC, ARM, MIPS) software
Ability, its partial code resides in target generator terminal, realizes the interaction with host side software, complete specific function jointly.
Remote system browsing is exactly that the information of system object in remote object machine system is browsed in host side, helps exploit person
Member grasps remote system state in real time.In order to realize that this function, development environment host side beard and hair send information inquiring command program to arrive
Target generator terminal obtains remote system object information data stream, and tissue replys data and is presented to user, long-range to realize
System browses.
Developer can obtain the relevant information of target machine system by embedded integration development environment, these information master
Refer to operating system nucleus object information, including:Task, semaphore, timer etc..Use information querying command program side
Formula obtains the information of kernel objects, is partially completed by accessing the specified memory of kernel objects.It is embedding by this mechanism
Entering formula Integrated Development Environment can help developer to browse teledata, monitoring objective machine state in real time.Current information
The generating mode of querying command mainly has the following two kinds:
1. static analysis mode.The code structure that Query Information is wanted in analysis operation system source code calculates the field complete
Deviant in office's variant structural body.Make in this way, developer to be needed skillfully to grasp basic number in operating system source code
According to the computational methods of type and the size of composite data type, known byte-aligned knowledge.Even if developer has these energy
Inevitably there are all kinds of mistakes in power, the information inquiring command program for writing out, need to carry out multiple combined debugging, final ability
Develop correct information querying command program.
2. encoding calculation.The association code that wanted query object is extracted from operating system source code, writes program,
By the actual motion on target machine, deviant of the field in global variable structure is calculated.Make in this way,
Deviant can be accurately obtained, information inquiring command program is write in accordance with information inquiring command rules of order according to deviant.
But since the workload for removing association code in operating system source code is too big so that difficulty in this way also compares
Greatly.
Also, all there is maintenance and expansion difficulty in above two mode, when the association code of wanted query object
When structure changes, need to recalculate offset, corresponding information inquiring command program is also required to modify.
Invention content
The invention aims to realize automatically generating for information inquiring command program, therefore propose a kind of information inquiry life
The automatic generation method and system of program are enabled,
Technical solution of the present invention provides a kind of automatic generation method of information inquiring command program, includes the following steps:
Step 1:Type binary image is loaded into debugger (2) by automatic generator (1);
Step 2:Automatic generator (1) is analyzed line by line generates command-in file, judges the end for whether reaching file
Otherwise tail, arrives step 4 if it find that the end of file, arrives step 3;
Step 3:Automatic generator (1) output information querying command program file arrives step 6;
Step 4:Determine whether the row has generation to order, if not finding to generate order, automatic generator (1) is moved to down
A line arrives step 2;It was found that the generation order of mistake uses, step 6 is arrived, without file generated;It recognizes and correctly generates life
It enables, arrives step 5;
Step 5:Automatic generator (1) according to generating command calls debugger, the debugger type two that has loaded of analysis into
Image processed obtains return value according to order operation is generated, this return value generates order for replacing, and continues to analyze next line, arrive
Step 2;
Step 6:Generation terminates.
A kind of automatic creation system of information inquiring command program, including automatic generator (1), debugger (2), typelib
Binary image and generation command-in file;
It generates command-in file to be made of generation order and character text two parts, generates order and debugger (2)
Function association, for searching the return value in type binary image, the return value will substitute generation order, character text
It is constant part, is uniformly output in information inquiring command program;Type binary image includes remote system pair to be checked
The data structure information of elephant;It generates command-in file to be input into automatic generator (1), automatic generator (1) control is adjusted
Device (2) analysis type library binary image is tried, obtains return value according to order operation is generated, automatic generator (1) uses return value
The generation order replaced in command-in file ultimately generates information inquiring command program.
The return value includes the deviant and sizes values of character in type binary image.
The invention has the advantages that automatically generating information inquiring command and comparing has great advantage, hand with manual mode
Dynamic writes information inquiring command program, needs to analyze data member one by one from operating system nucleus, calculates specific fields
Size and offset, due to the difference of architecture, identical data type may have different size of data, need to develop in this way
Personnel have deep understanding and enough carefulness to target body architecture, can just write correct information inquiring command journey
Sequence.Therefore, very time-consuming and be easy to lead to mistake using manual mode.If data structure changes generation in image
When, corresponding information inquiring command program will need to rewrite or even this modification may spread to other information inquiry life
It enables in program, if considering deficiency to changing, it will introduce new mistake.
Description of the drawings
Fig. 1 automatic creation system interaction figures of the present invention;
Fig. 2 the method for the present invention flow charts.
Specific implementation mode
Present system includes:Type binary image, generates command-in file, information inquiring command journey at debugger
Sequence and automatic generator.Automatic generator is responsible for whole scheduling, is loaded into using type binary image as symbol file
In debugger, the type binary image includes the data type information to be inquired.The analysis of automatic generator line by line generates
Command-in file is ordered each generation, can all be produced per that may include to generate order or character text etc. in a line
The function call of a raw debugger, debugger analysis type binary image return to operation result.Automatic generator is each
A generation order is substituted for corresponding numerical result, final to generate information inquiring command program file.
It is as follows to each section principles illustrated of the system:
1. type binary image includes the data structure information of remote system object to be checked, it must when being compiled generation
Debugging message (source code language acquiescence is C language) must be carried, only in this way, when it, which is debugged device, is loaded as symbol file,
Debugger can just inquire complex data type or simple data type therein, to calculate size and the offset of field.
2. debugger can be GNU debuggers (giving tacit consent in text) or other debuggers.It should be noted that debugger with
Type binary image is related.
It is formed 3. generating command-in file by generating order and character text two parts.Generate the work(of order and debugger
Energy relevant, sizes values and deviant for searching field in type binary image, these values will substitute generation order;
Character text is constant part, is uniformly output in information inquiring command program.
4. information inquiring command program is the output of system and final file destination.
5. automatic generator is the core of whole system, type binary image is loaded into debugger by it, point
Analysis generates command-in file, and identification generates command calls debugger and obtains the information such as deviant, replaces and generates order, forms letter
Cease querying command program.When finding to have undefined grammer in querying command input file, automatic generator needs, which are given, to be used
Person's prompt message, such as wrong generation order etc., termination automatically generate process, not will produce information inquiring command program.Mirror
In the automatic generator using character processing as core important business, therefore using perl language as development language.
Software and hardware information does not repeat herein in computer needed for other.
Technical solution of the present invention is specifically described with reference to embodiment:
1. the generation foundation of information inquiring command program
Message command polling routine is write according to the structure of remote operating system kernel objects on target machine, host
The size and structural information of all data used just are contained in the type binary image at end.Generally speaking there is the number of two classes
According to type:Basic data type and composite data type.Basic data type is the simple data type by language definition, such as
Int, char etc.;Composite data type is custom data type, and program language generally supports User Defined data
Struct in type, such as C language, its inside can include basic data type or other composite data types.
Assuming that in target machine operation code, there are following data structures:
typedef struct node
{
struct node*pNext
int attribute
int value;
char*name;
}_NODE
When writing information inquiring command program, need to calculate offset of each data member for first address, such as existing
It is PPC in target machine system architecture, is compiled using GNU compilers, obtained data member is relative to initial address
Offset it is as shown in table 1.
The offset of 1 data member of table
Data member | It deviates (byte) | Data member | It deviates (byte) | |
pNext | 0 | attribute | 8 | |
value | 4 | name | 12 |
It can be seen that if the data type for changing a certain item changes, being changed to char (1B) from int (4B), at this moment
Data-bias will change, and can be embodied in information inquiring command program;Another situation, if data structure is sent out
When raw change, for example data member is increased, then, it is required for recalculating from the offset after this data member.This
It embodies and code is write using manual mode, it is strictly very time-consuming and error-prone.
By taking PPC structures as an example, if it is desired to value member conditions are obtained, then corresponding information inquiring command program
For:_NODE_ADDR<+8@>, therein _ NODE_ADDR is the initial address of structure, and+8 be relative to the inclined of initial address
It moves, is to write shape data on returned data band.
If obtaining the information of the data member of total body, the information inquiring command program that may be used is:_
NODE_ADDR<+0@><+8@><+12@><+16$>, i.e., pNext pointer address, the value of value, the value of attribute and
Name character strings write back on returned data band.About the specific definition of information inquiring command, as shown in table 2.
2 information inquiring command of table defines
After order is sent to target generator terminal, it will the reply data received are as shown in table 3.
Table 3 replys data
Data member | Recovery value | Data member | Recovery value | |
pNext | “2 0x60000064” | attribute | “2 0” | |
value | “2 50” | name | “6user” |
The information inquiry stream of reply format description returned from target generator terminal is as shown in table 4.
4 stream of reply format description of table
Type code | Meaning | Type code | Meaning | Type code | Meaning | ||
UINT8 | 0 | FLOAT32 | 3 | STRING | 6 | ||
UINT16 | 1 | FLOAT64 | 4 | ADDR | 7 | ||
UINT32 | 2 | FLOAT80 | 5 |
2. information inquiring command automatically generates process
Automatic generator analysis generates the generation order in command-in file, generates debugger (having loaded image library) work(
It can call, be deviated and sizes values.Wherein, it is as shown in table 5 to generate order.
Table 5 generates command specification
Order | Meaning |
offset | Calculate offset of the specific fields in construction inner |
size | Calculate specific type size |
array_size | Calculate array size |
It generates in command-in file and generates commands to define offset information, the size in region, global change using in table 5
The size of array is measured, these orders are all relevant with the function of debugger.Assuming that obtain _ NODE structures in value at
The offset of member, needs to automatically create value of the information inquiring command program to obtain it, then being used as information inquiry in command file
The input of order generator is:_NODE_ADDR<+offset(_NODE.value)@>.
Automatic generator will analyze this line of input, identify predefined order offset, general _ NODE.value as ginseng
Number calls the corresponding function of debugger, deviant is obtained, to generate following program file:_NODE_ADDR<+8@>.
Similarly, _ all data member information of NODE_ADDR are obtained, are needed using following text as automatic raw
The input grown up to be a useful person:_NODE_ADDR<+offset(_NODE.pNext)@><+offset(_NODE.value)@><+offset(_
NODE.attribute)@><+offset(_NODE.name)$>.Generating following information inquiring command program is:_NODE_
ADDR<+0@><+8@><+12@><+16$>。
If it includes a undefined member to generate order, such as below:<+offset(_
NODE.WrongMember)@>.Mistake when automatic generator will will produce an operation at this time, not will produce any program text
Part.If also do not meet the code of defined grammar property containing other in input file, it can be all automatically generated device identification,
It is handled as error situation.
Since Perl language is for the superiority of word processing, so the exploitation language using Perl as automatic generator
Speech, generating information inquiring command program can be inputted by this order line:perl IQC_Gen.p type_lib.o
node.in.This order line is decomposed, " perlIQC_Gen.p " is operation information querying command automatic generator IQC_Gen.p
Method, next two parameters represent the type binary image (type_lib.o) that debugger uses and generate order input
File (node.in), output are saved in the node.out files of acquiescence.
Claims (3)
1. a kind of automatic generation method of information inquiring command program, which is characterized in that include the following steps:
Step 1:Type binary image is loaded into debugger (2) by automatic generator (1);
Step 2:Automatic generator (1) is analyzed line by line generates command-in file, judges the end for whether reaching file, such as
Fruit finds the end of file, arrives step 3, otherwise, arrives step 4;
Step 3:Automatic generator (1) output information querying command program file arrives step 6;
Step 4:Determine whether the row has generation to order, if not finding to generate order, automatic generator (1) is moved to next
Row arrives step 2;It was found that the generation order of mistake uses, step 6 is arrived, without file generated;It recognizes and correctly generates order,
To step 5;
Step 5:Automatic generator (1) is reflected according to command calls debugger, the type binary system that debugger analysis has loaded is generated
Picture obtains return value according to order operation is generated, this return value generates order for replacing, and continues to analyze next line, arrives step
2;
Step 6:Generation terminates.
2. a kind of automatic creation system of information inquiring command program, which is characterized in that including automatic generator (1), debugger
(2), typelib binary image and generation command-in file;
It generates command-in file and is formed by generating order and character text two parts, generate the function of order and debugger (2)
Association, for searching the return value in type binary image, the return value will substitute generation order, and character text is not
Become part, is uniformly output in information inquiring command program;Type binary image includes remote system object to be checked
Data structure information;It generates command-in file to be input into automatic generator (1), automatic generator (1) controls debugger
(2) analysis type library binary image obtains return value according to order operation is generated, and automatic generator (1) is replaced with return value
Generation order in command-in file ultimately generates information inquiring command program.
3. a kind of automatic creation system of information inquiring command program according to claim 2, which is characterized in that described to return
Return the deviant and sizes values that value includes field in type binary image.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611155269.2A CN108614680A (en) | 2016-12-14 | 2016-12-14 | A kind of automatic generation method and system of information inquiring command program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611155269.2A CN108614680A (en) | 2016-12-14 | 2016-12-14 | A kind of automatic generation method and system of information inquiring command program |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108614680A true CN108614680A (en) | 2018-10-02 |
Family
ID=63658056
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611155269.2A Pending CN108614680A (en) | 2016-12-14 | 2016-12-14 | A kind of automatic generation method and system of information inquiring command program |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108614680A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030200525A1 (en) * | 2002-04-18 | 2003-10-23 | Mcdermott Andrew | Automatic gopher program generator |
US20110066651A1 (en) * | 2009-07-29 | 2011-03-17 | Tomislav Pericin | Portable executable file analysis |
CN103136107A (en) * | 2011-12-03 | 2013-06-05 | 南京南瑞继保电气有限公司 | Variable debugging method of embedded program dynamic storage allocation |
CN105677438A (en) * | 2016-01-07 | 2016-06-15 | 南京邮电大学 | Method for automatically calculating calculation formula in file through compiler |
-
2016
- 2016-12-14 CN CN201611155269.2A patent/CN108614680A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030200525A1 (en) * | 2002-04-18 | 2003-10-23 | Mcdermott Andrew | Automatic gopher program generator |
US20110066651A1 (en) * | 2009-07-29 | 2011-03-17 | Tomislav Pericin | Portable executable file analysis |
CA2806367C (en) * | 2009-07-29 | 2019-03-12 | Reversinglabs Corporation | Repairing portable executable files |
CN103136107A (en) * | 2011-12-03 | 2013-06-05 | 南京南瑞继保电气有限公司 | Variable debugging method of embedded program dynamic storage allocation |
CN105677438A (en) * | 2016-01-07 | 2016-06-15 | 南京邮电大学 | Method for automatically calculating calculation formula in file through compiler |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106528165B (en) | Code generating method and code generating system | |
Chakraborty et al. | On multi-modal learning of editing source code | |
CN106874244B (en) | Method for constructing automatic document generation model based on work sequence | |
CN103838672A (en) | Automated testing method and device for all-purpose financial statements | |
CN107221328B (en) | Method and device for positioning modification source, computer equipment and readable medium | |
US9405518B2 (en) | Leveraging legacy applications for use with modern applications | |
CN101894236A (en) | Software homology detection method and device based on abstract syntax tree and semantic matching | |
CN107608951B (en) | Report generation method and system | |
US20140325472A1 (en) | Providing Code, Code Generator and Software Development Environment | |
JP2018505506A (en) | Machine-based instruction editing | |
CN116842964A (en) | Business process generation method and system based on semantic analysis | |
Owens et al. | Lem: A lightweight tool for heavyweight semantics | |
CN112416788B (en) | Hierarchical standard Web application UI automatic test method | |
CN110750297A (en) | Python code reference information generation method based on program analysis and text analysis | |
CN116560631B (en) | Method and device for generating machine learning model code | |
CN116991711A (en) | Test case generation method and device, terminal equipment and storage medium | |
Unterdechler et al. | Identifying repeating patterns in IEC 61499 systems using Feature-Based embeddings | |
Nikiforova et al. | An approach to compare UML class diagrams based on semantical features of their elements | |
CN108614680A (en) | A kind of automatic generation method and system of information inquiring command program | |
CN108829968A (en) | Circuit diagram checking method based on Python spread function | |
WO2021174823A1 (en) | Grammatical error correction method, apparatus, computer system, and readable storage medium | |
Egorova et al. | Visual parallel programming as PaaS cloud service with graph-symbolic programming technology | |
CN105335153A (en) | Dynamic script automatic-generating method | |
Karmakar | Establishing benchmarks for learning program representations | |
Lúcio et al. | Symbolic execution for the verification of model transformations |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20181002 |
|
RJ01 | Rejection of invention patent application after publication |