CN115981578A - Device, method and equipment for generating printing identification - Google Patents

Device, method and equipment for generating printing identification Download PDF

Info

Publication number
CN115981578A
CN115981578A CN202211627352.0A CN202211627352A CN115981578A CN 115981578 A CN115981578 A CN 115981578A CN 202211627352 A CN202211627352 A CN 202211627352A CN 115981578 A CN115981578 A CN 115981578A
Authority
CN
China
Prior art keywords
file
statement
printing
identifier
macro definition
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
CN202211627352.0A
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.)
Beijing Eswin Computing Technology Co Ltd
Guangzhou Quanshengwei Information Technology Co Ltd
Original Assignee
Beijing Eswin Computing Technology Co Ltd
Guangzhou Quanshengwei Information 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 Beijing Eswin Computing Technology Co Ltd, Guangzhou Quanshengwei Information Technology Co Ltd filed Critical Beijing Eswin Computing Technology Co Ltd
Priority to CN202211627352.0A priority Critical patent/CN115981578A/en
Publication of CN115981578A publication Critical patent/CN115981578A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a generating device, a method and equipment of a printing identifier, wherein the device comprises: the first processing module is used for acquiring the file name of a C file to be debugged through a macro definition script, wherein the C file comprises a preset printing function name; and adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name; the second processing module is used for generating a script through the printing identifier, and acquiring the file name included in the first macro definition statement in the C file and the target line number of the name of the preset printing function in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number. The device, the method and the equipment for generating the printing identifier are used for improving the efficiency of generating the printing identifier.

Description

Device, method and equipment for generating printing identification
Technical Field
The invention relates to the technical field of embedded development, in particular to a device, a method and equipment for generating a printing identifier.
Background
In the embedded system development process, the lower computer can compile the C file to generate log information, and the log information is sent to the upper computer through the transmission interface, so that software developers can debug the C file based on the log information. Because the resources of the transmission interface are limited, the lower computer generally sends a printing identifier to the upper computer through the transmission interface, the upper computer determines a formatted character string corresponding to the printing identifier in the dictionary mapping table according to the printing identifier, and performs formatting analysis processing on the formatted character string to obtain log information; the dictionary mapping table comprises a plurality of printing identifications and formatting character strings corresponding to the printing identifications.
In the related art, the following method is generally adopted to obtain a plurality of print identifiers in the dictionary mapping table: presetting a printing identification range corresponding to each C file, and selecting a corresponding printing identification for a printing statement by a software developer from the printing identification range corresponding to the C file aiming at each C file; and scanning the printing identifications corresponding to the printing sentences in all the C files, and determining all the selected printing identifications as a plurality of printing identifications in the dictionary mapping table under the condition that no printing identification conflict is determined (the printing identification conflict is, for example, the same printing identification is repeatedly used for a plurality of times).
In the above related art, in the process of generating the print identifier in the dictionary mapping table, a manual operation by a software developer is required, so that the generation efficiency of the print identifier in the dictionary mapping table is low.
Disclosure of Invention
The invention provides a device, a method and equipment for generating a printing identifier, which are used for overcoming the defect of low generation efficiency of the printing identifier in a dictionary mapping table in the prior art and achieving the purpose of improving the generation efficiency of the printing identifier.
In a first aspect, the present invention provides a device for generating a print identifier, which is applied to an electronic device, where the electronic device includes a macro definition script and a print identifier generation script, and the device includes:
the first processing module is used for acquiring the file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name; and adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name;
a second processing module, configured to generate a script through the print identifier, and obtain the file name included in the first macro definition statement in the C file and a target line number of the preset print function name in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
Optionally, the first processing module is configured to obtain, through the macro definition script, a file name of the C file to be debugged, and includes:
the first processing module is used for acquiring a storage path of the C file through the macro definition script; and the file name of the C file is extracted from the storage path.
Optionally, the first processing module is configured to add a first macro definition statement in the C file, and includes:
the first processing module is used for searching a first target C statement comprising a first preset character string in the C file; and the macro statement is used for adding the first macro definition statement before the target C statement, wherein the first macro definition statement and the target C statement are two adjacent C statements.
Optionally, the first macro definition statement includes a second preset character string, and the apparatus further includes:
the third processing module is used for judging whether the newly added C file comprises a second preset character string or not under the condition that the newly added C file is determined; and the macro definition statement is used for adding a second macro definition statement in the newly added C file under the condition that the judgment result indicates that the second preset character string is not included, wherein the second macro definition statement comprises the file name of the newly added C file and the second preset character string.
Optionally, the apparatus further comprises:
the fourth processing module is used for generating a printing identifier based on the file name and the target line number, then generating a script based on the printing identifier, and adding the printing identifier to a preset header file; and the preset header file is added to the C file.
Optionally, the apparatus further comprises:
a fifth processing module, configured to, after the preset header file is added to the C file, under a condition that it is detected that a line number of a print statement of a first C file in the C file is updated, generate a script based on the print identifier, and regenerate the print identifier corresponding to the print statement of the first C file.
Optionally, the print statement includes at least one parameter to be printed, and the apparatus further includes:
and the sixth processing module is used for counting the at least one parameter to be printed by precompiling macro statements to obtain the total quantity of the at least one parameter to be printed.
In a second aspect, the present invention provides a method for generating a print identifier, which is applied to an electronic device, where the electronic device includes a macro definition script and a print identifier generation script, and the method includes:
acquiring a file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name;
adding a first macro definition statement in the C file, wherein the first macro definition statement comprises a file name of the C file;
generating a script through the printing identifier, and acquiring the file name included in the first macro definition statement in the C file and a target line number of the preset printing function name in the C file;
and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
Optionally, the obtaining, by the macro definition script, a file name of the C file to be debugged includes:
acquiring a storage path of the C file through the macro definition script;
and extracting the file name of the C file from the storage path.
Optionally, the adding a first macro definition statement in the C file includes:
searching a first target C statement comprising a first preset character string in the C file;
adding the first macro definitional statement before the target C statement, wherein the first macro definitional statement and the target C statement are two adjacent C statements.
Optionally, the first macro definition sentence includes a second preset character string, and the method further includes:
under the condition that a newly added C file is determined, judging whether the newly added C file comprises a second preset character string or not;
and adding a second macro definition statement in the newly added C file under the condition that the judgment result indicates that the second preset character string is not included, wherein the second macro definition statement comprises the file name of the newly added C file and the second preset character string.
Optionally, after generating a print identifier based on the file name and the target line number, the method further includes:
generating a script based on the printing identification, and adding the printing identification to a preset header file;
and adding the preset header file in the C file.
Optionally, after the adding the preset header file in the C file, the method further includes:
and under the condition that the line number of the printing statement of the first C file in the C files is detected to be updated, generating a script based on the printing identifier, and regenerating the printing identifier corresponding to the printing statement of the first C file.
Optionally, the printing statement includes at least one parameter to be printed, and the method further includes:
and counting the at least one parameter to be printed by pre-compiling macro statements to obtain the total quantity of the at least one parameter to be printed.
In a third aspect, the present invention further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for generating a print identifier according to any one of the above aspects.
In a fourth aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method for generating a print identifier as described in any one of the above.
In a fifth aspect, the present invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the method for generating a print identifier as described in any one of the above.
According to the device, the method and the equipment for generating the printing identifier, the file name and the line number of the printing statement are acquired from the macro definition statement through the printing identifier generating script, the printing identifier is generated according to the file name and the line number, manual operation of software developers is not needed, and the generation efficiency of the printing identifier is improved.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a schematic flow chart of a method for generating a print identifier according to the present invention;
FIG. 2 is a schematic structural diagram of a device for generating a print identifier according to the present invention;
FIG. 3 is a second schematic structural diagram of a print identifier generating apparatus provided in the present invention;
fig. 4 is a schematic physical structure diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the related art, in the process of generating the print identifier in the dictionary mapping table, a manual operation by a software developer is required, so that the generation efficiency of the print identifier in the dictionary mapping table is low.
In order to improve the generation efficiency of the printing identifier, in the invention, the inventor thinks of designing two scripts (a macro definition script and a printing identifier generation script), adding a macro definition sentence in a C file through the macro definition script, acquiring a file name and a line number of the printing sentence from the macro definition sentence through the printing identifier generation script, and generating the printing identifier according to the file name and the line number without manual operation of a software developer, thereby improving the generation efficiency of the printing identifier.
The method for generating the print identifier according to the present invention will be described below with reference to specific embodiments.
Fig. 1 is a schematic flow chart of a method for generating a print identifier according to the present invention. As shown in fig. 1, the method includes:
step 101, a file name of a C file to be debugged is obtained through a macro definition script, wherein the C file comprises a preset printing function name.
Optionally, an execution subject of the method for generating a print identifier provided by the present invention is an electronic device, and may also be a device for generating a print identifier disposed on an electronic device.
For example, the electronic device may be a desktop computer, a notebook computer, or the like.
The means for generating the print identifier may be implemented, for example, by a combination of software and/or hardware.
The macro definition script is preset in the electronic device.
And searching C files in all subdirectories in the software project to be debugged through the macro definition script to obtain a file list, wherein the file list comprises all the C files to be debugged.
And acquiring the file name of the C file aiming at each C file in the file list through the macro definition script.
The preset print function name is a function name having a print function, and may be printf, LOG, or the like, for example.
Step 102, adding a first macro definition statement in the C file, wherein the first macro definition statement comprises a file name (of the C file).
And adding a first macro definition statement in each C file through the macro definition script.
The first macro definition statement is, for example: "# define FILE _ NAME FILE _1". Wherein, FILE _1 is the FILE name of the C FILE.
For example, in the case where there are 2C files, one of which has a file name of main and the other of which has a file name of Ab, a first macro definition sentence is added to one of the C files: # define FILE _ NAME main, add the first macro definition statement in another C-FILE: # define FILE _ NAME main.
Optionally, a FILE _ NAME defined in each C FILE exists, so that the FILE NAME and the target line number can be combined to obtain the print identifier by using the following codes in the macro extension of the C language:
#define__LOG_ID(filename,line)filename##_##line
#define_LOG_ID(filename,line)__LOG_ID(filename,line)
#define LOG_ID_LOG_ID(FILE_NAME,__LINE__)。
103, generating a script through the printing identifier, and acquiring a file name included in the first macro definition statement in the C file and a target line number of a preset printing function name in the C file.
And generating a script by printing the identifier for each C file, and scanning the C file to obtain a file name included in the first macro definition statement in the C file and a target line number of a preset printing function name in the C file.
Optionally, other PC software may also be set in the electronic device, and the PC software scans the C file to obtain a file name included in the first macro definition statement in the C file and a target line number of the preset print function name in the C file.
The preset print function name is contained in the print statement in the C file.
The number of target line numbers of the preset print function names in the C file is equal to the number of print statements including the preset print function names in the C file. For example, when the number of target line numbers is 10, it indicates that the preset print function name is included in 10 print sentences.
In one C file, the number of preset print function names may be 1 or more.
In the case where a plurality of preset print function names are included in the C file, the plurality of preset print function names are generally the same.
And 104, generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
Specifically, when the number of target line numbers is plural, the print identifier is generated for each target line number, the file name, and the target line number.
Alternatively, the print identifier may be generated based on the file name and the target line number in the following two ways.
In the mode 1, a script is generated by printing the identifier, and the file name and the target line number are spliced to obtain the printing identifier.
Mode 2, generating a script by printing the identifier to generate a preset character string;
and splicing the preset character string, the file name and the target line number according to a preset rule to obtain the printing identifier.
The preset rule is, for example, the arrangement order of the preset character string, the file name and the target line number.
The file name, object line number, and print identification are illustratively described below in connection with Table 1.
TABLE 1
Figure BDA0004004117490000091
In the method for generating the print identifier provided in the embodiment of fig. 1, a file name of a C file to be debugged is acquired through a macro definition script, and a first macro definition statement is added to the C file; and generating a script through the printing identifier, acquiring a file name included by a first macro definition statement in the C file and a target line number of a preset printing function name in the C file, and generating the printing identifier based on the file name and the target line number without manual operation of a software developer, thereby improving the generation efficiency of the printing identifier.
In some embodiments, obtaining, by the macro definition script, a file name of a C file to be debugged includes: and acquiring a storage path of the C file through the macro definition script, and extracting the file name of the C file from the storage path.
For example, the storage path of the C file is: d, extracting the File name main of the C File from the storage path through the macro definition script.
In the invention, the macro definition script is used for extracting the file name of the C file from the storage path of the C file, so that the efficiency of obtaining the file name can be improved, and the efficiency of generating the log file is further improved.
In some embodiments, adding a first macro definition statement in the C file includes: searching a first target C statement comprising a first preset character string in a C file through the macro definition script; and adding a first macro definition statement before the target C statement, wherein the first macro definition statement and the target C statement are two adjacent C statements.
Specifically, the first preset character string is include, and the target C statement is the first C statement including include.
In some embodiments, the first macro definition statement is added in the C file through the macro definition script, and the first macro definition statement is not required to be added manually by a software developer, so that the efficiency of adding the first macro definition statement in the C file is improved, and the efficiency of generating the log file is further improved.
In the invention, when the C file is added in the software project engineering, the macro definition sentence can be inserted into the added C file through the macro definition script.
Alternatively, the macro definition statement may be inserted into the newly added C file in the following two ways.
In mode 21, in some embodiments, the first macro definition statement includes a second preset character string (FILE _ NAME), and the method for generating a print identifier provided by the present invention further includes:
judging whether a second preset character string is included in the newly added C file or not under the condition that the newly added C file is determined through the macro definition script;
and under the condition that the judgment result indicates that the second preset character string is not included, adding a second macro definition sentence into the newly added C file, wherein the second macro definition sentence comprises the file name of the newly added C file and the second preset character string.
In the mode 22, the first macro definition sentence includes a second preset character string (FILE _ NAME), and the method for generating a print identifier provided by the present invention further includes:
aiming at a new software project after a C file is newly added, searching C files in all sub directories in the new software project through a macro definition script to obtain a file list, wherein the file list comprises all C files to be debugged and the newly added C file;
judging whether each C file in the file list comprises a second preset character string or not through the macro definition script; and under the condition that the second preset character string is not included in the C file, adding a second macro definition statement in the C file so as to insert the macro definition statement in the newly added C file.
In the invention, the macro definition sentences can be added into the newly added C file through the macro definition script, so that the addition of the macro definition sentences into the newly added C file has flexibility.
In some embodiments, after generating the print identifier based on the file name and the target line number, the method for generating the print identifier provided by the present invention further includes:
generating a script based on the printing identification, and adding the printing identification to a preset header file;
and adding a preset header file in the C file.
In some embodiments, after adding the preset header file to the C file, the method for generating the print identifier provided by the present invention further includes:
and under the condition that the line number of the printing statement of the first C file in the C files is detected to be updated, generating a script based on the printing identifier, and regenerating the printing identifier corresponding to the printing statement of the first C file.
Specifically, in the process of compiling the C file triggered by the preset project construction file, under the condition that the line number of the printing statement of the first C file in the C file is detected to be updated, generating a script based on the printing identifier, and regenerating the printing identifier corresponding to the printing statement of the first C file; the preset project construction file does not include a preset header file.
In the prior art, adding or deleting a print statement in any C file may cause all print identifiers to change due to the change of a line number. Therefore, in the case where the number of C files is small, the preset header file (logic _ gen.h file) is regenerated, and all C files are recompiled (i.e., debugged). When the number of C files is large, it is costly to regenerate the preset header file and recompile all the C files, for example, it takes a long time and occupies a large amount of resources of the processor.
Therefore, in order to avoid regenerating the preset header file and recompiling all the C files, integration with the preset project build file (e.g., makefile file) is required.
Core rule syntax of makefile:
goal 8230: dependent file \8230
Command 1
Command 2
…。
Here, the dependent file generally includes a C file, and a header file (i.e., an h file) associated with the C file. If the logic _ gen.h file is put into the dependent file, the addition or deletion of each printing statement will cause the change of the logic _ gen.h file, so that the triggering rule causes all the C files to be recompiled.
Therefore, in the invention, the method is integrated with the preset engineering construction file (such as the makefile) so that the preset engineering construction file does not comprise the preset header file, and when the condition that the row number of the printing statement of the first C file in the C file is updated is detected, the script is generated based on the printing identifier, and only the printing identifier corresponding to the printing statement of the first C file is generated again, so that the generation efficiency of the log identifier is improved.
In the related art, the lower computer also needs to send the number of at least one parameter to be printed included in the print statement to the upper computer.
In order to increase the number of the obtained at least one parameter to be printed, the method for generating the print identifier provided by the invention further comprises the following steps:
and counting at least one parameter to be printed in the printing sentence by pre-compiling the macro sentence to obtain the total quantity of the at least one parameter to be printed.
In the invention, the total number of at least one parameter to be printed in the printing statement can be directly obtained by pre-compiling the macro statement, so that the efficiency of obtaining the total number of the parameters to be printed is improved.
Alternatively, the total number of the at least one parameter to be printed may be derived by a precompiled macro in C language:
#define__COUNT_ARGS(_0,_1,_2,_3_n,...)_n
#define COUNT_ARGS(...)__COUNT_ARGS(__VA_ARGS__,3,2,1,0)
in the present invention, for example, in the case that the print statement is a log print interface, by the above-described embodiment, a printf print interface (printf function prototype) and the log print interface improved by the present invention can be unified, the details of the implementation of the bottom layer are completely shielded, the implementation of the bottom layer is completely completed by an automated macro and a script, and a software developer completely uses the log print interface in the present invention according to the conventional printf print interface.
The format of the printf printing interface is: int printf (const char format).
The format of the log print interface in the present invention is: # define LOG (FORMAT _ STRING.)
LogDisplay_pc(LOG_ID,COUNT_ARGS(,##__VA_ARGS__),##__VA_ARGS__)。
The following describes a generation apparatus of a print flag according to the present invention, and the generation apparatus of a print flag described below and the generation method of a print flag described above may be referred to in correspondence with each other.
Fig. 2 is a schematic structural diagram of a print identifier generating apparatus according to the present invention. As shown in fig. 2, the generation apparatus of the print flag includes:
a first processing module 210, configured to obtain, through the macro definition script, a file name of a C file to be debugged, where the C file includes a preset print function name; and the macro file is used for adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name;
a second processing module 220, configured to generate a script through the print identifier, and obtain the file name included in the first macro definition statement in the C file and a target line number of the preset print function name in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining log information of a printing statement corresponding to the target line number.
The generation device of the print identifier has the same beneficial effects as the generation of the print identifier, and the description is omitted here.
Optionally, the first processing module 210 is configured to obtain, through the macro definition script, a file name of a C file to be debugged, and includes:
the first processing module 210 is configured to obtain a storage path of the C file through the macro definition script; and the file name of the C file is extracted from the storage path.
Optionally, the first processing module 210 is configured to add a first macro definition statement in the C file, and includes:
the first processing module 210 is configured to search, in the C file, a first target C statement including a first preset character string; and the first macro statement is added before the target C statement, wherein the first macro statement and the target C statement are two adjacent C statements.
Fig. 3 is a second schematic structural diagram of a print identifier generating apparatus according to the present invention. As shown in fig. 3, the first macro definition sentence includes a second preset character string, and the apparatus for generating a print identifier further includes:
the third processing module 230 is configured to, under a condition that it is determined that a newly added C file exists, determine whether the newly added C file includes a second preset character string; and the macro definition statement is used for adding a second macro definition statement in the newly added C file under the condition that the judgment result indicates that the second preset character string is not included, wherein the second macro definition statement comprises the file name of the newly added C file and the second preset character string.
Optionally, the apparatus for generating a print identifier further comprises:
a fourth processing module 240, configured to generate a print identifier based on the file name and the target line number, generate a script based on the print identifier, and add the print identifier to a preset header file; and the preset header file is added to the C file.
Optionally, the apparatus for generating a print identifier further comprises:
a fifth processing module 250, configured to, after the preset header file is added to the C file, under a condition that it is detected that a line number of a print statement of a first C file in the C file is updated, generate a script based on the print identifier, and regenerate the print identifier corresponding to the print statement of the first C file.
Optionally, the print statement includes at least one parameter to be printed, and the apparatus for generating a print identifier further includes:
the sixth processing module 260 is configured to count the at least one parameter to be printed by precompiling a macro statement, so as to obtain the total number of the at least one parameter to be printed.
Fig. 4 is a schematic physical structure diagram of an electronic device provided in the present invention. As shown in fig. 4, the electronic device may include: a processor (processor) 410, a communication Interface 420, a memory (memory) 430 and a communication bus 440, wherein the processor 410, the communication Interface 420 and the memory 430 are communicated with each other via the communication bus 440. The processor 410 may invoke logic instructions in the memory 430 to perform a method of generating a print identification, the method comprising: acquiring a file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name; adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name; generating a script through the printing identifier, and acquiring the file name included in the first macro definition statement in the C file and a target line number of the preset printing function name in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
In addition, the logic instructions in the memory 430 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being storable on a non-transitory computer-readable storage medium, the computer program, when executed by a processor, being capable of executing the method for generating a print identifier provided by the above methods, the method comprising: acquiring a file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name; adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name; generating a script through the printing identifier, and acquiring the file name included in the first macro definition statement in the C file and a target line number of the preset printing function name in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program, when executed by a processor, implementing a method for generating a print identifier provided by the above methods, the method including: acquiring a file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name; adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name; generating a script through the printing identifier, and acquiring the file name included in the first macro definition statement in the C file and a target line number of the preset printing function name in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (11)

1. An apparatus for generating a print identifier, applied to an electronic device, where the electronic device includes a macro definition script and a print identifier generation script, the apparatus comprising:
the first processing module is used for acquiring the file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name; and the macro file is used for adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name;
a second processing module, configured to generate a script through the print identifier, and obtain the file name included in the first macro definition statement in the C file and a target line number of the preset print function name in the C file; and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining log information of a printing statement corresponding to the target line number.
2. The apparatus according to claim 1, wherein the first processing module is configured to obtain, through the macro definition script, a file name of a C file to be debugged, and includes:
the first processing module is used for acquiring a storage path of the C file through the macro definition script; and the file name of the C file is extracted from the storage path.
3. The apparatus of claim 1, wherein the first processing module is configured to add a first macro definition statement to the C file, and includes:
the first processing module is used for searching a first target C statement comprising a first preset character string in the C file; and the first macro statement is added before the target C statement, wherein the first macro statement and the target C statement are two adjacent C statements.
4. The apparatus according to any one of claims 1 to 3, wherein the first macro definition sentence includes a second preset character string therein, the apparatus further comprising:
the third processing module is used for judging whether the newly added C file comprises a second preset character string or not under the condition that the newly added C file is determined; and the macro definition statement is used for adding a second macro definition statement in the newly added C file under the condition that the judgment result indicates that the second preset character string is not included; and the second macro definition statement comprises the file name of the newly added C file and the second preset character string.
5. The apparatus of any one of claims 1 to 3, further comprising:
the fourth processing module is used for generating a printing identifier based on the file name and the target line number, then generating a script based on the printing identifier, and adding the printing identifier to a preset header file; and the preset header file is added to the C file.
6. The apparatus of claim 5, further comprising:
a fifth processing module, configured to, after the preset header file is added to the C file, under a condition that it is detected that a line number of a print statement of a first C file in the C file is updated, generate a script based on the print identifier, and regenerate the print identifier corresponding to the print statement of the first C file.
7. The apparatus according to any one of claims 1 to 3, wherein the printed statement includes at least one parameter to be printed, the apparatus further comprising:
and the sixth processing module is used for counting the at least one parameter to be printed by precompiling macro statements to obtain the total quantity of the at least one parameter to be printed.
8. A method for generating a print identifier is applied to an electronic device, wherein the electronic device comprises a macro definition script and a print identifier generation script, and the method comprises the following steps:
acquiring a file name of a C file to be debugged through the macro definition script, wherein the C file comprises a preset printing function name;
adding a first macro definition statement in the C file, wherein the first macro definition statement comprises the file name;
generating a script through the printing identifier, and acquiring the file name included in the first macro definition statement in the C file and a target line number of the preset printing function name in the C file;
and generating a printing identifier based on the file name and the target line number, wherein the printing identifier is used for determining the log information of the printing statement corresponding to the target line number.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of generating a print identifier according to claim 8 when executing the program.
10. A non-transitory computer-readable storage medium on which a computer program is stored, the computer program, when being executed by a processor, implementing the method for generating a print identifier according to claim 8.
11. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method of generating a printed marking according to claim 8.
CN202211627352.0A 2022-12-16 2022-12-16 Device, method and equipment for generating printing identification Pending CN115981578A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211627352.0A CN115981578A (en) 2022-12-16 2022-12-16 Device, method and equipment for generating printing identification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211627352.0A CN115981578A (en) 2022-12-16 2022-12-16 Device, method and equipment for generating printing identification

Publications (1)

Publication Number Publication Date
CN115981578A true CN115981578A (en) 2023-04-18

Family

ID=85958451

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211627352.0A Pending CN115981578A (en) 2022-12-16 2022-12-16 Device, method and equipment for generating printing identification

Country Status (1)

Country Link
CN (1) CN115981578A (en)

Similar Documents

Publication Publication Date Title
US11354225B2 (en) Automating identification of test cases for library suggestion models
US11093240B2 (en) Automating identification of code snippets for library suggestion models
US11494181B2 (en) Automating generation of library suggestion engine models
CN102804147B (en) Perform the code check executive system of the code check of ABAP source code
US10146532B2 (en) Apparatus and method for detecting code cloning of software
US11340896B2 (en) Library model addition
WO2008097816A2 (en) Direct access of language metadata
US20140298290A1 (en) Identification of code changes using language syntax and changeset data
CN112540862A (en) Interface document data generation method, device, equipment and storage medium
CN110543427A (en) Test case storage method and device, electronic equipment and storage medium
KR101696694B1 (en) Method And Apparatus For Analysing Source Code Vulnerability By Using TraceBack
CN117112060A (en) Component library construction method and device, electronic equipment and storage medium
CN116431476A (en) JVM fuzzy test method based on code context variation
CN108897588B (en) Routing method and routing device for communication between modules
CN117009231B (en) Automatic generation method and device for high-reliability unit test based on conversational large language model
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
CN111352631B (en) Interface compatibility detection method and device
CN112632333A (en) Query statement generation method, device, equipment and computer readable storage medium
CN112559344A (en) Remote mock testing method and system
CN115981578A (en) Device, method and equipment for generating printing identification
Chen et al. Hopper: Interpretative fuzzing for libraries
CN115599388A (en) API (application programming interface) document generation method, storage medium and electronic equipment
CN114489653A (en) Compiler-based data processing method, compiler-based data processing device and readable storage medium
CN113760291A (en) Log output method and device
CN107608875B (en) Localization processing method and device for static code

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