CN115857942A - Code processing method and device, equipment and storage medium - Google Patents

Code processing method and device, equipment and storage medium Download PDF

Info

Publication number
CN115857942A
CN115857942A CN202211527462.XA CN202211527462A CN115857942A CN 115857942 A CN115857942 A CN 115857942A CN 202211527462 A CN202211527462 A CN 202211527462A CN 115857942 A CN115857942 A CN 115857942A
Authority
CN
China
Prior art keywords
matching
code
instrumentation
pile
language
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
Application number
CN202211527462.XA
Other languages
Chinese (zh)
Inventor
王波
周浩
曾浩
肖坤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guoke Chushi Chongqing Software Co ltd
Original Assignee
Guoke Chushi Chongqing Software 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 Guoke Chushi Chongqing Software Co ltd filed Critical Guoke Chushi Chongqing Software Co ltd
Priority to CN202211527462.XA priority Critical patent/CN115857942A/en
Publication of CN115857942A publication Critical patent/CN115857942A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The present disclosure relates to a code processing method and apparatus, device, and storage medium, wherein an instrumentation rule set is established, where the instrumentation rule set includes: the file name of the compiling unit, the matching type of the pile inserting position, the matching content corresponding to the matching type and the pile inserting mode; acquiring a target source code according to the file name of the compiling unit; determining a code analysis tool corresponding to the language type of the target source code; generating a data structure corresponding to the target source code through the code analysis tool; determining the instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position by utilizing a component corresponding to the language type of the target source code; and inserting preset codes to be inserted into the inserting positions, combining an inserting rule set established based on user requirements and a data structure corresponding to the target source codes, accurately and comprehensively analyzing the target source codes, realizing automatic inserting of any position of the target source codes, and improving the flexibility and expansibility of inserting.

Description

Code processing method and device, equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a code processing method and apparatus, a device, and a storage medium.
Background
In the related art, a specific user behavior or event is captured, processed and transmitted through a data buried point, wherein the specific user behavior may be the number of times a user clicks on an icon, the duration of watching a video, and the like. Wherein, data embedding is usually realized by means of instrumentation.
The existing instrumentation mode comprises an advanced Automatic Object Programming (AOP) Programming extension framework and a Java bytecode manipulation framework, wherein the advanced AOP Programming extension framework is mature and stable and is simple to use, but the function of the framework cannot meet the requirements of certain scenes, for example, the framework cannot be suitable for scenes for instrumenting all functions; the Java bytecode manipulation framework can meet 100% of scenes, but is difficult to use and not strong in universality.
Disclosure of Invention
To overcome the problems in the related art, the present disclosure provides a code processing method and apparatus, a device, and a storage medium.
According to a first aspect of the embodiments of the present disclosure, there is provided a code processing method, including:
establishing an instrumentation rule set, wherein the instrumentation rule set comprises: compiling a file name of a unit, a matching type of a pile inserting position, and matching content and a pile inserting mode corresponding to the matching type;
acquiring a target source code according to the file name of the compiling unit; determining a code analysis tool corresponding to the language type of the target source code; generating a data structure corresponding to the target source code through the code analysis tool;
determining the instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position by utilizing the component corresponding to the language type of the target source code; and inserting a preset code to be inserted into the inserting position, wherein the component is a software unit and corresponds to the inserting mode.
In some embodiments, the matching type of the pile insertion position is a matching mode based on a generated data structure or a matching mode combining a regular expression, the matching content is a function name, and the pile insertion mode is to label the pile insertion position and insert a preset code to be inserted into the pile insertion position; or
The matching type of the pile inserting position is a mode of matching based on annotation content, the matching content is keywords, and the pile inserting mode is a mode of prompting the annotation and inserting a preset code to be inserted into the pile inserting position.
In some embodiments, the language type of the target source code is C language or C + + language, the code analysis tool is a claspg tool chain, and the data structure is an abstract syntax tree, wherein the tool chain comprises a series of software;
the language type of the target source code is any one of C language, C + + language, java language, python language and Go language, the code analysis tool is an LLVM tool chain, and the data structure is an intermediate layer code.
In some embodiments, the determining, by the component corresponding to the language type of the target source code, the instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position; and inserting a preset code to be inserted into the inserting position, which specifically comprises the following steps:
analyzing the matching type of the pile inserting position in the pile inserting rule set, and the matching content and the pile inserting mode corresponding to the matching type into a parallel processing rule set, wherein the parallel processing rule set comprises a plurality of rules, and each rule comprises a group of corresponding matching type, matching content and pile inserting mode;
determining a component library corresponding to the language type of the target source code;
and calling the component matched with each rule from the component library, and controlling the component to execute the steps of determining the instrumentation position in the data structure and inserting a preset code to be instrumented into the instrumentation position.
In some embodiments, the method further comprises:
and allocating the parallel processing rule sets to the thread pools, wherein one compiling unit corresponds to one thread in the thread pools corresponding to the parallel processing rule sets.
In some embodiments, the determining the instrumented locations in the data structure according to the matching types and matching contents of the instrumented locations comprises:
determining a target instrumentation statement in the data structure according to the matching type and the matching content of the instrumentation position;
and taking the specified position corresponding to the target pile-inserting sentence as a pile-inserting position.
In some embodiments, the inserting a preset code to be instrumented into the instrumentation position includes:
and setting the code line after the preset code to be inserted into the stub as a line-feed-free mode.
In some embodiments, the preset code to be instrumented adopts a macro definition mode.
According to a second aspect of the embodiments of the present disclosure, there is provided a code processing apparatus including:
an establishing module configured to establish an instrumentation rule set, wherein the instrumentation rule set includes: the file name of the compiling unit, the matching type of the pile inserting position, the matching content corresponding to the matching type and the pile inserting mode;
the determining module is used for acquiring the target source code according to the file name of the compiling unit and determining a code analysis tool corresponding to the language type of the target source code; generating a data structure corresponding to the target source code through the code analysis tool;
the instrumentation module is used for determining the instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position by utilizing the component corresponding to the language type of the target source code; and inserting a preset code to be inserted into the inserting position, wherein the component is a software unit and corresponds to the inserting mode.
In some embodiments, in the establishing module,
the pile inserting position matching type is a mode of matching based on a generated data structure or a mode of matching by combining a regular expression, the matching content is a function name, and the pile inserting mode is to label the pile inserting position and insert a preset code to be inserted into the pile inserting position; or
The matching type of the pile inserting position is a mode of matching based on annotation content, the matching content is keywords, and the pile inserting mode is a mode of prompting the annotation and inserting a preset code to be inserted into the pile inserting position.
In some embodiments, in the determining module,
the language type of the target source code is C language or C + + language, the code analysis tool is a clang tool chain, the data structure is an abstract syntax tree, and the tool chain comprises a series of software;
the language type of the target source code is any one of C language, C + + language, java language, python language and Go language, the code analysis tool is an LLVM tool chain, and the data structure is a middle layer code.
In some embodiments, the stake module comprises:
the analysis unit is used for analyzing the matching types of the pile inserting positions in the pile inserting rule set, the matching contents corresponding to the matching types and the pile inserting modes into a rule set capable of being processed in parallel, wherein the rule set capable of being processed in parallel comprises a plurality of rules, and each rule comprises a group of corresponding matching types, matching contents and pile inserting modes;
the corresponding unit is used for determining a component library corresponding to the language type of the target source code;
and the control unit is used for calling the components matched with each rule from the component library, controlling the components to execute the steps of determining the pile inserting positions in the data structure and inserting preset codes to be inserted into the pile inserting positions.
In some embodiments, the apparatus further comprises:
and the distribution module is used for distributing the parallel processing rule sets to the thread pools, wherein one compiling unit corresponds to one thread in the thread pools corresponding to the parallel processing rule sets.
In some embodiments, the stake module is further to:
determining a target instrumentation statement in the data structure according to the matching type and the matching content of the instrumentation position;
and taking the specified position corresponding to the target pile-inserting sentence as a pile-inserting position.
In some embodiments, the stake module is further to:
and setting the code line after the preset code to be inserted into the stub as a non-line-feed mode.
In some embodiments, in the instrumentation module, the preset code to be instrumented adopts a macro definition mode.
According to a third aspect of the disclosed embodiment, a vehicle is provided. The vehicle stores a set of instructions that are executed by the vehicle to implement the code processing method provided by the first aspect of the disclosure.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic apparatus, including:
a processor;
a memory for storing the processor-executable instructions;
the processor is configured to read the executable instructions from the memory and execute the instructions to implement the code processing method provided by the first aspect of the present disclosure.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the steps of the code processing method provided by the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
the code processing method disclosed by the invention can accurately and comprehensively analyze the target source code by combining the instrumentation rule set established based on the user requirements and the data structure corresponding to the target source code, realize automatic instrumentation of any position of the target source code and improve the flexibility and expansibility of instrumentation.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a flow diagram illustrating a method of code processing according to an example embodiment.
FIG. 2 is an application flow diagram illustrating a method of code processing in accordance with an exemplary embodiment.
Fig. 3 is a schematic illustration of a pile insertion APP frame composition structure according to an exemplary embodiment.
FIG. 4 is a block diagram illustrating a code processing apparatus according to an example embodiment.
FIG. 5 is a block diagram of a vehicle shown in accordance with an exemplary embodiment.
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
Exemplary embodiments will be described in detail below with reference to the accompanying drawings.
It should be noted that the related embodiments and the accompanying drawings are provided only for the purpose of describing exemplary embodiments provided by the present disclosure, and not for the purpose of describing all embodiments of the present disclosure, and it should be understood that the present disclosure is not limited by the related exemplary embodiments.
It should be noted that the terms "first", "second", etc. are used in this disclosure only to distinguish different steps, devices or modules, etc. Related terms do not denote any particular technical meaning, nor do they denote an order or interdependence between them.
It should be noted that the terms "a", "an", "a", "at least one", and "one" as used in this disclosure are intended to be illustrative, and not limiting. Unless the context clearly dictates otherwise, it should be understood to be "one or more".
It should be noted that the term "and/or" as used in this disclosure is used to describe an associative relationship between associated objects, and generally means that there are at least three types of associative relationships. For example, a and/or B, may represent at least: a exists alone, A and B exist simultaneously, and B exists alone.
It should be noted that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. The scope of the present disclosure is not limited by the order of description of the steps in the related embodiments, unless otherwise specified.
It should be noted that all the actions of acquiring signals, information or data in the present disclosure are performed under the premise of complying with the corresponding data protection regulation policy of the country of the location and obtaining the authorization given by the owner of the corresponding device.
Description of technical terms
Pile inserting technology: a section of code is inserted into a target source code to realize acquisition, for example: and adopting a tag to explain failure reasons when the function parameter, the return value, the function execution time and the function execution fail, and obtaining the information.
SOA(Service-Oriented Architecture Service-oriented architecture) call chain: representing a primary function, implemented by one or more SOA services. The call chain represents the call relation between the SOA services and the call relation between the functions inside the SOA services. For a function call, the two may constitute a call chain.
SOA calling chain embedded point: and (5) adopting a instrumentation technology to perform the position of a code insertion point on the target source code. The instrumented source code is the information of the SOA call chain buried point.
CI/CD (Continuous Integration/Continuous delivery and Continuous delivery) system: continuously integrated, continuously delivered, and continuously deployed automation systems. The automatic pile inserting technology can be used in a CI/CD system, and is convenient for a user to automatically manage the system.
Abstract syntax tree: aiming at a C/C + + language, an abstract syntax tree is generated for target source codes by using a clone compiler tool chain, and instrumentation rules are conveniently customized according to user requirements, wherein the clone compiler is a front end of a LLVM compiler tool set and is used for compiling C, C + +, objective-C, and the tool chain comprises a series of software. Abstract syntax trees for other languages are generated with corresponding tool chains.
Pile inserting APP: and realizing regular behaviors by using a reflection mechanism, wherein the behaviors are based on an application program for code instrumentation of the generated abstract syntax tree, and the multi-language support is realized by adopting a componentization technology.
Exemplary method
FIG. 1 is a flowchart illustrating a code processing method according to an exemplary embodiment, as shown in FIG. 1, the code processing method including the steps of: s110 to S130.
In step S110, an instrumentation rule set is established, wherein the instrumentation rule set includes: and compiling the file name of the unit, the matching type of the pile inserting position, and the matching content and the pile inserting mode corresponding to the matching type.
In this embodiment, the preset code to be instrumented adopts a macro definition mode.
In an embodiment, when the matching type of the pile insertion position is a matching mode based on a generated data structure or a matching mode combining a regular expression, the matching content is a function name, and the pile insertion mode is to label the pile insertion position and insert a preset code to be inserted into the pile insertion position.
In another embodiment, when the matching type of the instrumentation position is a way of matching based on annotation content, the matching content is a keyword, and the instrumentation way is a prompt for annotation and a preset code to be instrumented is inserted into the instrumentation position.
In step S120, a target source code is obtained according to the file name of the compiling unit; determining a code analysis tool corresponding to the language type of the target source code; and generating a data structure corresponding to the target source code by the code analysis tool.
In an embodiment, in a case that a language type of the target source code is C language or C + + language, the code analysis tool is a clang tool chain, and the data structure is an abstract syntax tree.
In another embodiment, in a case that the language type of the target source code is any one of C language, C + + language, java language, python language, and Go language, the code analysis tool is an LLVM tool chain, and the data structure is middle layer code.
In step S130, determining an instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position by using a component corresponding to the language type of the target source code; and inserting a preset code to be inserted into the inserting position, wherein the component is a software unit and corresponds to the inserting mode.
In this embodiment, the inserting a preset code to be inserted into the insertion position includes:
and setting the code line after the preset code to be inserted into the stub as a line-feed-free mode.
In practical application, after the code line to be instrumented is inserted into the designated code line, line feed may occur due to the overlong code line, and by ensuring that the code line after the code line to be instrumented is inserted does not have line feed, the target source code structure after all the code lines to be instrumented are inserted is kept unchanged, so that the purpose of high accuracy of the target source code after all the code lines to be instrumented are inserted can be achieved.
In this embodiment, the determining, by using a component corresponding to a language type of the target source code, an instrumentation position in the data structure according to a matching type and matching content of the instrumentation position; and inserting a preset code to be inserted into the inserting position, which specifically comprises the following steps:
analyzing the matching type of the pile inserting position in the pile inserting rule set, and the matching content and the pile inserting mode corresponding to the matching type into a parallel processing rule set, wherein the parallel processing rule set comprises a plurality of rules, and each rule comprises a group of corresponding matching type, matching content and pile inserting mode;
determining a component library corresponding to the language type of the target source code;
and calling the component matched with each rule from the component library, and controlling the component to execute the steps of determining the instrumentation position in the data structure and inserting a preset code to be instrumented into the instrumentation position.
In one embodiment, a rule of a set of rules may be processed in parallel, including: the matching type of the pile inserting position is based on the generated data structure for matching, the matching content is a function name, and the pile inserting mode is to label the pile inserting position and insert a preset code to be inserted into the pile inserting position.
In another embodiment, a rule of a set of rules may be processed in parallel, including: the matching type of the pile inserting position is matched by combining a regular expression, the matching content is a function name, and the pile inserting mode is to label the pile inserting position and insert a preset code to be inserted into the pile inserting position.
In yet another embodiment, a rule of a set of rules may be processed in parallel, including: the matching type of the pile inserting position is based on annotation content for matching, the matching content is keywords, and the pile inserting mode is prompting annotation and inserting a preset code to be inserted into the pile inserting position.
In an embodiment, the language type correspondence between the component library and the target source code includes a component library of each language of a C language, a C + + language, a Java language, a Python language, and a Go language, and a component in the component library is a software unit and is configured to implement parallel processing of each rule in a rule set according to a instrumentation manner in each rule.
The code processing method provided by the disclosure can support instrumentation of target source codes of different languages by providing the component library of multiple languages and taking the components in the component library as rules for realizing parallel processing rule set.
In this embodiment, the method further includes:
and allocating the parallelable processing rule set to the thread pool, wherein one compiling unit corresponds to one thread in the thread pool.
In practical application, all rules of a rule set can be processed in parallel in one compiling unit in one thread in a thread pool, and the instrumentation of a plurality of compiling units can be processed in parallel, so that the instrumentation efficiency is improved.
In this embodiment, the determining an instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position includes:
determining a target instrumentation statement in the data structure according to the matching type and the matching content of the instrumentation position;
and taking the designated position corresponding to the target pile-inserting sentence as a pile-inserting position.
In practical application, the instrumentation can be performed before, after and at a certain position of the current target instrumentation sentence, so as to meet the practical requirements of the user.
In a vehicle-transport integrated system, the code processing method provided by the disclosure can be applied to automatic generation of SOA service embedded point information by a vehicle end and a cloud end. Because the implementation of the corresponding embedded point information is embedded-oriented, the embedded point information has the characteristics of small size and high efficiency, and different languages can be used for instrumentation based on the generated data structures and the instrumentation rule set customized by user requirements, the code processing method provided by the disclosure can also be applied to other fields, can also expand the support of different languages, and has universality.
Referring to fig. 2, the application method of the code processing method provided by the present disclosure in generating vehicle-side SOA call link buried point information includes:
firstly, based on a source code structure (realized by C/C + + language) of target SOA service of a user, a cloning tool chain is used for a compiling unit to generate an abstract syntax tree, and an instrumentation rule set shown in the following table 1 is customized according to user requirements.
TABLE 1
Figure BDA0003973422800000111
In the code processing method, the target source code is maintained under the condition of definite rules based on the user customized rules, and the changes are not easily interfered.
In the code processing method, the instrumentation rule set can be convenient for users to customize requirements quickly and friendly, and the generated rule set is also convenient to expand to other projects for use.
The second step, based on the stake rule set, utilize stake APP to realize the automatic stake of inserting to burying some information based on the reflection mechanism, wherein, stake APP includes extensible basic frame part, and convenience of customers extension can realize the application of stake APP to different scenes and demands.
The code processing method disclosed by the invention is based on the realization of the abstract syntax tree, the support of different languages can be realized, the functions are strong, the expansibility is good, the instrumentation APP realizes the instrumentation process by using a modular technology, the modular realization can be restricted to the realization of each component corresponding to different languages, and the uniform interface adaptation is realized.
The code processing method disclosed by the invention is based on the customized instrumentation rule set and the universal instrumentation APP, the instrumentation process of the target source code is automated, the instrumentation process is conveniently integrated with a user CI/CD system, a whole set of efficient automation system is formed, the source code originally issued by a user can be automatically instrumented to realize the insertion of SOA service embedded point information, and finally issued source codes are formed.
Referring to fig. 3, stake APP frame component structure includes:
the analysis module is used for analyzing the matching types of the pile inserting positions in the pile inserting rule set, the matching contents corresponding to the matching types and the pile inserting modes into a rule set capable of being processed in parallel, wherein the rule set capable of being processed in parallel comprises a plurality of rules, and each rule comprises a group of corresponding matching types, matching contents and pile inserting modes;
a scheduling module for forming a reflection processing function corresponding to each rule, wherein the reflection processing function is used for matching a corresponding component for each rule;
the instrumentation execution module is used for generating a component library of an abstract syntax tree for a compiling unit by using a clang tool chain based on a source code structure (realized by C/C + + language) of target SOA service of a user;
and the control module is used for calling components in the instrumentation execution module according to the reflection processing function corresponding to each rule for the same compiling unit corresponding to the same thread in the thread pool, and completing instrumentation on the abstract syntax tree.
According to the code processing method, automatic target source code instrumentation is achieved by using a reflection mechanism according to the instrumentation rule set based on the abstract syntax tree corresponding to the target source code and the instrumentation rule set customized by user requirements, so that embedding points of SOA (service oriented architecture) services are automatically achieved, the target source code can be accurately and comprehensively analyzed, the instrumentation rule set is generated by combining with the user requirements, and expansion is facilitated.
According to the code processing method, aiming at the situation that the realization of the user target source code is complex and various, each part of the user target source code can be accurately and comprehensively analyzed based on the analysis of the abstract syntax tree, and the pile insertion at any position and the arbitrary customization of the target source code are realized.
Exemplary devices
FIG. 4 is a block diagram illustrating a code processing apparatus according to an example embodiment. Referring to fig. 4, the apparatus 400 includes a setup module 410, a determination module 420, and a staking module 430.
The establishing module 410 is configured to establish an instrumentation rule set, where the instrumentation rule set includes: compiling a file name of a unit, a matching type of a pile inserting position, and matching content and a pile inserting mode corresponding to the matching type;
the determining module 420 is configured to obtain a target source code according to the file name of the compiling unit, and determine a code analysis tool corresponding to the language type of the target source code; generating a data structure corresponding to the target source code through the code analysis tool;
the instrumentation module 430 is configured to determine an instrumentation position in the data structure according to a matching type and matching content of the instrumentation position by using a component corresponding to a language type of a target source code; and inserting a preset code to be inserted into the inserting position, wherein the component is a software unit and corresponds to the inserting mode.
In some embodiments, in the establishing module 410,
the pile inserting position matching type is a mode of matching based on a generated data structure or a mode of matching by combining a regular expression, the matching content is a function name, and the pile inserting mode is to label the pile inserting position and insert a preset code to be inserted into the pile inserting position; or
The matching type of the pile inserting position is a mode of matching based on annotation content, the matching content is keywords, and the pile inserting mode is a mode of prompting the annotation and inserting a preset code to be inserted into the pile inserting position.
In some embodiments, in the determination module 420,
the language type of the target source code is C language or C + + language, the code analysis tool is a clang tool chain, the data structure is an abstract syntax tree, and the tool chain comprises a series of software;
the language type of the target source code is any one of C language, C + + language, java language, python language and Go language, the code analysis tool is an LLVM tool chain, and the data structure is a middle layer code.
In some embodiments, the stake module 430 includes:
the analysis unit is used for analyzing the matching types of the pile inserting positions in the pile inserting rule set, the matching contents corresponding to the matching types and the pile inserting modes into a rule set capable of being processed in parallel, wherein the rule set capable of being processed in parallel comprises a plurality of rules, and each rule comprises a group of corresponding matching types, matching contents and pile inserting modes;
the corresponding unit is used for determining a component library corresponding to the language type of the target source code;
and the control unit is used for calling the components matched with each rule from the component library, controlling the components to execute the steps of determining the pile inserting positions in the data structure and inserting preset codes to be inserted into the pile inserting positions.
In some embodiments, the apparatus further comprises:
and the distribution module is used for distributing the parallel processing rule sets to the thread pools, wherein one compiling unit corresponds to one thread in the thread pools corresponding to the parallel processing rule sets.
In some embodiments, the stake module 430 is further configured to:
determining a target instrumentation statement in the data structure according to the matching type and the matching content of the instrumentation position;
and taking the designated position corresponding to the target pile-inserting sentence as a pile-inserting position.
In some embodiments, the stake module 430 is further configured to:
and setting the code line after the preset code to be inserted into the stub as a non-line-feed mode.
In some embodiments, in the instrumentation module, the preset code to be instrumented adopts a macro definition mode.
Exemplary vehicle
FIG. 5 is a block diagram of a vehicle shown in accordance with an exemplary embodiment. The vehicle 500 may be a fuel powered vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other type of vehicle.
Referring to FIG. 5, a vehicle 500 may include a number of subsystems, such as a drive system 510, a control system 520, a sensing system 530, a communication system 540, an information display system 550, and a computing processing system 560. Vehicle 500 may also include more or fewer subsystems, and each subsystem may also include multiple components, which need not be described in detail herein.
The drive system 510 includes components that provide powered motion to the vehicle 500. Such as an engine, energy source, transmission, etc.
The control system 520 includes components that provide control for the vehicle 500. For example, vehicle control, cabin equipment control, driving assistance control, and the like.
The perception system 530, includes components that provide ambient environmental perception for the vehicle 500. For example, a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, an image pickup apparatus, and the like.
The communication system 540 includes components that provide communication connectivity for the vehicle 500. For example, mobile communication networks (e.g., 3G, 4G, 5G networks, etc.), wiFi, bluetooth, car networking, etc.
The information display system 550 includes components that provide various information displays for the vehicle 500. Such as vehicle information displays, navigation information displays, entertainment information displays, and the like.
The computing system 560 includes components that provide data computing and processing capabilities for the vehicle 500. The computing processing system 560 may include at least one processor 561 and memory 562. The processor 561 may execute instructions stored in the memory 562.
The processor 561 may be any conventional processor, such as a commercially available CPU. The processor may also include, for example, an image processor (GPU), a Field Programmable Gate Array (FPGA), a System On Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.
The memory 562 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
In the disclosed embodiment, the memory 562 stores a set of instructions that the processor 561 can execute to implement all or part of the steps of any of the code processing methods described in the above exemplary embodiments.
In other embodiments, the vehicle 500 may include the code processing apparatus provided in the above embodiments.
Exemplary electronic device
Fig. 6 is a block diagram illustrating an electronic device 600 in accordance with an example embodiment. The electronic device 600 may be a vehicle controller, a vehicle mounted terminal, a vehicle mounted computer, or other type of electronic device.
Referring to fig. 6, an electronic device 600 may include at least one processor 610 and a memory 620. The processor 610 may execute instructions stored in the memory 620. The processor 610 is communicatively coupled to the memory 620 via a data bus. In addition to the memory 620, the processor 610 may be communicatively coupled to an input device 630, an output device 640, and a communication device 650 via a data bus.
The processor 610 may be any conventional processor, such as a commercially available CPU. The processor may also include, for example, an image processor (GPU), a Field Programmable Gate Array (FPGA), a System On Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.
The memory 620 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
In the embodiment of the present disclosure, the memory 620 stores executable instructions, and the processor 610 may read the executable instructions from the memory 620 and execute the instructions to implement all or part of the steps of the code processing method described in any of the above exemplary embodiments.
Exemplary computer readable storage Medium
In addition to the above-described methods and apparatuses, exemplary embodiments of the present disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer product includes computer program instructions that are executable by a processor to implement all or part of the steps described in any of the above exemplary embodiments.
The computer program product may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + +, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages, and scripting languages (e.g., python). The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server.
The computer-readable storage medium may take any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the readable storage medium include: static Random Access Memory (SRAM) having one or more electrically conductive lines, electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic or optical disk, or any suitable combination of the foregoing.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice in the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A code processing method, comprising:
establishing an instrumentation rule set, wherein the instrumentation rule set comprises: the file name of the compiling unit, the matching type of the pile inserting position, the matching content corresponding to the matching type and the pile inserting mode;
acquiring a target source code according to the file name of the compiling unit; determining a code analysis tool corresponding to the language type of the target source code; generating a data structure corresponding to the target source code through the code analysis tool;
determining the instrumentation position in the data structure according to the matching type and the matching content of the instrumentation position by utilizing the component corresponding to the language type of the target source code; and inserting a preset code to be inserted into the inserting position, wherein the component is a software unit and corresponds to the inserting mode.
2. The method according to claim 1, wherein the matching type of the pile insertion position is a mode of matching based on a generated data structure or a mode of matching by combining a regular expression, the matching content is a function name, and the pile insertion mode is to label the pile insertion position and insert a preset code to be inserted into the pile insertion position; or
The matching type of the pile inserting position is a mode of matching based on annotation content, the matching content is keywords, and the pile inserting mode is a mode of prompting the annotation and inserting a preset code to be inserted into the pile inserting position.
3. The method according to claim 1 or 2, wherein the language type of the target source code is C language or C + + language, the code analysis tool is a clasping tool chain, and the data structure is an abstract syntax tree, wherein the tool chain comprises a series of software;
the language type of the target source code is any one of C language, C + + language, java language, python language and Go language, the code analysis tool is an LLVM tool chain, and the data structure is a middle layer code.
4. The method according to claim 1, wherein the determining of the instrumentation position in the data structure is performed by using a component corresponding to the language type of the target source code according to the matching type and the matching content of the instrumentation position; and inserting a preset code to be inserted into the inserting position, which specifically comprises the following steps:
analyzing the matching type of the pile inserting position in the pile inserting rule set, and the matching content and the pile inserting mode corresponding to the matching type into a parallel processing rule set, wherein the parallel processing rule set comprises a plurality of rules, and each rule comprises a group of corresponding matching type, matching content and pile inserting mode;
determining a component library corresponding to the language type of the target source code;
and calling the component matched with each rule from the component library, and controlling the component to execute the steps of determining the instrumentation position in the data structure and inserting a preset code to be instrumented into the instrumentation position.
5. The method of claim 4, further comprising:
and allocating the parallel processing rule sets to the thread pools, wherein one compiling unit corresponds to one thread in the thread pools corresponding to the parallel processing rule sets.
6. The method according to claim 1 or 2, wherein the determining of the instrumented position in the data structure according to the matching type and the matching content of the instrumented position comprises:
determining a target instrumentation statement in the data structure according to the matching type and the matching content of the instrumentation position;
and taking the designated position corresponding to the target pile-inserting sentence as a pile-inserting position.
7. A code processing apparatus, comprising:
an establishing module configured to establish an instrumentation rule set, wherein the instrumentation rule set includes: compiling a file name of a unit, a matching type of a pile inserting position, and matching content and a pile inserting mode corresponding to the matching type;
the determining module is used for acquiring the target source code according to the file name of the compiling unit and determining a code analysis tool corresponding to the language type of the target source code; generating a data structure corresponding to the target source code through the code analysis tool;
the instrumentation module is used for determining instrumentation positions in the data structure according to the matching types and the matching contents of the instrumentation positions by utilizing components corresponding to the language types of the target source codes; and inserting a preset code to be inserted into the inserting position, wherein the component is a software unit and corresponds to the inserting mode.
8. A vehicle having stored thereon a set of instructions that are executable by the vehicle to implement the code processing method of any of claims 1-6.
9. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor is configured to read the executable instructions from the memory and execute the instructions to implement the steps of the code processing method according to any one of claims 1 to 6.
10. A computer-readable storage medium, on which computer program instructions are stored, which program instructions, when executed by a processor, are adapted to carry out the steps of the code processing method of any of claims 1-6.
CN202211527462.XA 2022-11-30 2022-11-30 Code processing method and device, equipment and storage medium Pending CN115857942A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211527462.XA CN115857942A (en) 2022-11-30 2022-11-30 Code processing method and device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211527462.XA CN115857942A (en) 2022-11-30 2022-11-30 Code processing method and device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115857942A true CN115857942A (en) 2023-03-28

Family

ID=85668724

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211527462.XA Pending CN115857942A (en) 2022-11-30 2022-11-30 Code processing method and device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115857942A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116775040A (en) * 2023-08-16 2023-09-19 北京安普诺信息技术有限公司 Pile inserting method for realizing code vaccine and application testing method based on code vaccine

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116775040A (en) * 2023-08-16 2023-09-19 北京安普诺信息技术有限公司 Pile inserting method for realizing code vaccine and application testing method based on code vaccine
CN116775040B (en) * 2023-08-16 2023-11-17 北京安普诺信息技术有限公司 Pile inserting method for realizing code vaccine and application testing method based on code vaccine

Similar Documents

Publication Publication Date Title
US20200007926A1 (en) Method and apparatus for playing video
CN107506300B (en) User interface testing method, device, server and storage medium
CN110765661A (en) Automatic driving simulation scene generation method and device, electronic equipment and storage medium
CN104765617A (en) Stream application function interface distributing method and system realized on basis of HTML5
CN109509365A (en) A kind of information of vehicles error correction method, system and hand-held mobile terminal device
CN110209967B (en) Page loading method and device, terminal equipment and computer readable medium
US20180293610A1 (en) Methods and systems for integrating applications into a content recommendation network
CN112749081A (en) User interface testing method and related device
CN115857942A (en) Code processing method and device, equipment and storage medium
CN113391801B (en) Recommendation engine architecture based on cloud service
CN113608997B (en) Remote debugging method and device for embedded webpage of application program and electronic equipment
CN113221161B (en) Information protection method and readable storage medium in online education big data scene
CN114327185A (en) Vehicle screen control method and device, medium and electronic equipment
CN114064172A (en) Data rendering method and device
CN109299124A (en) Method and apparatus for more new model
CN112348632A (en) Method, device and equipment for online transaction of RPA robot based on AI
CN116661936A (en) Page data processing method and device, computer equipment and storage medium
CN114237634A (en) Application release risk identification method, device, equipment, medium and program product
CN115291872A (en) Data processing method, electronic device and storage medium
CN109828752B (en) Project code automatic generation method, device, computer equipment and storage medium
CN116994380B (en) Information interaction method and device
CN116679936A (en) Automatic conversion method and device for function modules between compiling and constructing systems
CN117009100A (en) Data processing method, device, vehicle and equipment based on socket multiplexing
CN116860220A (en) C/C++ programming method, device, vehicle, electronic device and storage medium
CN114791842A (en) Vehicle-road cooperative information processing method and device and terminal equipment

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