CN106776304A - Method based on printout information is controlled in multithreading exploitation under built-in Linux - Google Patents

Method based on printout information is controlled in multithreading exploitation under built-in Linux Download PDF

Info

Publication number
CN106776304A
CN106776304A CN201611100587.9A CN201611100587A CN106776304A CN 106776304 A CN106776304 A CN 106776304A CN 201611100587 A CN201611100587 A CN 201611100587A CN 106776304 A CN106776304 A CN 106776304A
Authority
CN
China
Prior art keywords
thread
printf
linux
print control
type information
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
CN201611100587.9A
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.)
Cloud Bird (shanghai) Energy Technology Co Ltd
Original Assignee
Cloud Bird (shanghai) Energy 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 Cloud Bird (shanghai) Energy Technology Co Ltd filed Critical Cloud Bird (shanghai) Energy Technology Co Ltd
Priority to CN201611100587.9A priority Critical patent/CN106776304A/en
Publication of CN106776304A publication Critical patent/CN106776304A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30076Arrangements for executing specific machine instructions to perform miscellaneous control operations, e.g. NOP
    • G06F9/3009Thread control instructions

Abstract

Method based on printout information is controlled in multithreading exploitation under built-in Linux of the invention, including:A) creates print control file, for receiving and storing thread name to be printed;B) creates record sheet, for storing Thread Id and thread name;C) defines global character pointer p, and print control file is mapped into global character pointer p;D) realizes printf functions again;E) outputs type information.The method that the present invention proposes dynamic control type information output in C language exploitation under a kind of built-in Linux, the method realizes printf functions again in the case of use habit and C standard printf function identicals is kept;When program is run, it is only necessary to thread name to be printed is input into print control file, it is possible to realize the function of dynamic control type information output.The method is convenient and swift, save remodified for the output of control type information, time of compiled code, effectively increase debugging efficiency and development efficiency.

Description

Method based on printout information is controlled in multithreading exploitation under built-in Linux
Technical field
The present invention relates to it is a kind of based under built-in Linux multithreading exploitation in control printout information method, more Specifically, more particularly to a kind of method based on printout information is controlled in multithreading exploitation under built-in Linux.
Background technology
It is crucial for code to become for the ease of tracking problem under current built-in Linux in C language exploitation debugging process Value checks, output of message etc., it will usually call the printf functions type informations to carry out debugging tracking.But when printf letters During number is for multiple threads, and developer can only be changed generation when needing the printf Debugging message for shielding some threads to export Code, corresponding printf functions is deleted or is commented out or is masked with macrodefinition, is then recompilated again, operation program, than It is cumbersome;When usage quantity is many in multithreading for printf functions, this drawback is just more obvious, and it can be wasted Developer's substantial amounts of time, used in writing above printf functions and annotation printf functions, seriously reduce development efficiency.
The content of the invention
The present invention is in order to overcome the shortcoming of above-mentioned technical problem, there is provided a kind of based on multithreading under built-in Linux The method that printout information is controlled in exploitation.
Method based on printout information is controlled in multithreading exploitation under built-in Linux of the invention, its feature exists In being realized by following steps:
A) creates print control file, creates the print control file for receiving and storing thread name to be printed, Linux After system operation, commissioning staff writes the thread name of pre-print using echo orders to the print control file;
B) creates record sheet, creates the record sheet for storing Thread Id and thread name, whenever having thread to initiate, first Judge whether the thread name is existing in record sheet, if existed, the corresponding ID of the title is updated;If no In the presence of then by thread name and Thread Id while being stored in record sheet;
C) defines global character pointer p, using internal memory mapping function mmap, by the thread name to be printed that is stored with step a) Print control file be mapped to global character pointer p;
D) realizes printf functions again, redefines a printf using the character different from printf, and make again The printf of definition enter to participate in standard printf functions enter to join it is identical;Then again by macrodefinition, by standard printf Replace with the title of the printf for redefining, with reach when using the printf for redefining with standard printf letters Number has identical interface and effect;
E) outputs type information, under linux system, during using the printf type information for redefining, all threads are equal The ID of this thread is obtained, and according to corresponding thread name in record sheet in ID finding steps a), then looked up complete in step c) Whether contain this thread name in the internal memory that office character pointer p is pointed to, if then printing out information, moved back if not Go out or return.
Method based on printout information is controlled in multithreading exploitation under built-in Linux of the invention, in step a) The title of the print control file of definition and address can be:/ home/printfctl, using echo orders to the print control File exports pre-print thread name form:Such as echo " taskname1 ">/ home/printfctl, to allow thread The thread type information of entitled taskname1, by echo " taskname N ">>/ home/printfctl increases name The thread output type information of referred to as tasknameN.
The beneficial effects of the invention are as follows:It is of the invention to be printed out based on control in multithreading exploitation under built-in Linux The method of information, it is proposed that a kind of method that dynamic control type information is exported in C language exploitation under built-in Linux, the party Method realizes printf functions again in the case of use habit and C standard printf function identicals is kept;Program is run When, it is only necessary to thread name to be printed is input into print control file, it is possible to realize that dynamic control type information is exported Function.The method is convenient and swift, save remodified for the output of control type information, time of compiled code, effectively Improve debugging efficiency and development efficiency.
Brief description of the drawings
Fig. 1 is of the invention based on the method flow that printout information is controlled in multithreading exploitation under built-in Linux Figure.
Specific embodiment
The invention will be further described with embodiment below in conjunction with the accompanying drawings.
As shown in figure 1, giving of the invention based on control printout information in multithreading exploitation under built-in Linux Method flow diagram, it is realized by following steps:
A) creates print control file, creates the print control file for receiving and storing thread name to be printed, Linux After system operation, commissioning staff writes the thread name of pre-print using echo orders to the print control file;
For example, the title of the print control file of definition and address can be:/ home/printfctl, using echo orders to The print control file exports pre-print thread name form:Such as echo " taskname1 ">/ home/printfctl, To allow thread name as the thread type information of taskname1, by echo " taskname N ">> /home/ Printfctl increases the thread output type information of entitled tasknameN.
B) creates record sheet, creates the record sheet for storing Thread Id and thread name, whenever thering is thread to initiate, First determine whether whether the thread name is existing in record sheet, if existed, the corresponding ID of the title is updated;Such as Fruit does not exist, then thread name and Thread Id are stored in into record sheet simultaneously;
There is no the concept of thread name, only Thread Id in Linux, the convenient identification pid of computer system, and mankind's convenient use Thread name, if the use of Thread Id one being bad memory, two is that per secondary program, startup is all dynamic to Thread Id;Therefore introduce note Record table is facilitating operation thread.
C) defines global character pointer p, using internal memory mapping function mmap, by the thread to be printed that is stored with step a) The print control file of title is mapped to global character pointer p;
D) realizes printf functions again, redefines a printf using the character different from printf, and make again The printf of definition enter to participate in standard printf functions enter to join it is identical;Then again by macrodefinition, by standard printf Replace with the title of the printf for redefining, with reach when using the printf for redefining with standard printf letters Number has identical interface and effect;
E) outputs type information, under linux system, during using the printf type information for redefining, all threads are equal The ID of this thread is obtained, and according to corresponding thread name in record sheet in ID finding steps a), then looked up complete in step c) Whether contain this thread name in the internal memory that office character pointer p is pointed to, if then printing out information, moved back if not Go out or return.
The critical data of certain thread is checked in running if desired, usable echo orders are to defined in step 1 File write-in thread name;For example:Check that an information for thread can use the echo that such as issues orders if just hoped " taskname1" >/ home/printoption, if it is desired to checking that multiple thread informations can be added such as using additional mode echo "tasknameN" >> /home/printoption。
Method beneficial effect body based on control printout information in multithreading exploitation under built-in Linux of the invention Now:
Beneficial effects of the present invention are as follows:
(1), by print control file write one or more different thread names, task names, can control certain or Certain several thread carries out type information output;Can change the next dynamic of control information and adjust printing in any time of program operation Information output.
(2), can cause debugging efforts become very efficiently, effectively improve software development efficiency.
(3), release process when, printf sentences can be retained in program code, it is not necessary to delete.
(4), on-site terminal is when needing to carry out malfunction elimination, the related letter that can be checked using this mode in terminal operating Breath, is easy to quickly position the source of trouble, improves problem investigation efficiency.
(5), scene operation is when going wrong, and can accomplish to retain scene, information is checked, without destorying the scene again Operation program.

Claims (2)

1. it is a kind of based under built-in Linux multithreading exploitation in control printout information method, it is characterised in that pass through Following steps are realized:
A) creates print control file, creates the print control file for receiving and storing thread name to be printed, Linux After system operation, commissioning staff writes the thread name of pre-print using echo orders to the print control file;
B) creates record sheet, creates the record sheet for storing Thread Id and thread name, whenever having thread to initiate, first Judge whether the thread name is existing in record sheet, if existed, the corresponding ID of the title is updated;If no In the presence of then by thread name and Thread Id while being stored in record sheet;
C) defines global character pointer p, using internal memory mapping function mmap, by the thread name to be printed that is stored with step a) Print control file be mapped to global character pointer p;
D) realizes printf functions again, redefines a printf using the character different from printf, and make again The printf of definition enter to participate in standard printf functions enter to join it is identical;Then again by macrodefinition, by standard printf Replace with the title of the printf for redefining, with reach when using the printf for redefining with standard printf letters Number has identical interface and effect;
E) outputs type information, under linux system, during using the printf type information for redefining, all threads are equal The ID of this thread is obtained, and according to corresponding thread name in record sheet in ID finding steps a), then looked up complete in step c) Whether contain this thread name in the internal memory that office character pointer p is pointed to, if then printing out information, moved back if not Go out or return.
2. it is according to claim 1 based under built-in Linux multithreading exploitation in control printout information method, It is characterized in that:The title of the print control file defined in step a) and address can be:/ home/printfctl, uses Echo orders export pre-print thread name form to the print control file:Such as echo " taskname1 "> /home/ Printfctl, to allow thread name as the thread type information of taskname1, by echo " taskname N ">> / Home/printfctl increases the thread output type information of entitled tasknameN.
CN201611100587.9A 2016-12-05 2016-12-05 Method based on printout information is controlled in multithreading exploitation under built-in Linux Pending CN106776304A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611100587.9A CN106776304A (en) 2016-12-05 2016-12-05 Method based on printout information is controlled in multithreading exploitation under built-in Linux

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611100587.9A CN106776304A (en) 2016-12-05 2016-12-05 Method based on printout information is controlled in multithreading exploitation under built-in Linux

Publications (1)

Publication Number Publication Date
CN106776304A true CN106776304A (en) 2017-05-31

Family

ID=58883481

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611100587.9A Pending CN106776304A (en) 2016-12-05 2016-12-05 Method based on printout information is controlled in multithreading exploitation under built-in Linux

Country Status (1)

Country Link
CN (1) CN106776304A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107656868A (en) * 2017-09-18 2018-02-02 上海斐讯数据通信技术有限公司 A kind of adjustment method and system that thread name is obtained using thread private data
CN112486424A (en) * 2019-09-12 2021-03-12 无锡江南计算技术研究所 Parallel printing order-preserving agent method for user-transparent operation cores

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5325530A (en) * 1993-01-29 1994-06-28 International Business Machines Corporation Controller for sequential programming tools executed in a parallel computing environment
CN101515251A (en) * 2009-03-31 2009-08-26 华为技术有限公司 Board-level platform debugging method, device and system
CN101916223A (en) * 2010-08-11 2010-12-15 无锡中星微电子有限公司 Program debugging method and system
CN105260315A (en) * 2015-11-13 2016-01-20 上海斐讯数据通信技术有限公司 Method for debugging log in embedded system process

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5325530A (en) * 1993-01-29 1994-06-28 International Business Machines Corporation Controller for sequential programming tools executed in a parallel computing environment
CN101515251A (en) * 2009-03-31 2009-08-26 华为技术有限公司 Board-level platform debugging method, device and system
CN101916223A (en) * 2010-08-11 2010-12-15 无锡中星微电子有限公司 Program debugging method and system
CN105260315A (en) * 2015-11-13 2016-01-20 上海斐讯数据通信技术有限公司 Method for debugging log in embedded system process

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107656868A (en) * 2017-09-18 2018-02-02 上海斐讯数据通信技术有限公司 A kind of adjustment method and system that thread name is obtained using thread private data
CN112486424A (en) * 2019-09-12 2021-03-12 无锡江南计算技术研究所 Parallel printing order-preserving agent method for user-transparent operation cores
CN112486424B (en) * 2019-09-12 2022-10-04 无锡江南计算技术研究所 User transparent arithmetic core parallel printing order-preserving proxy method

Similar Documents

Publication Publication Date Title
CN109086199B (en) Method, terminal and storage medium for automatically generating test script
CN102640151B (en) Transformed data recording method and system
US9009175B2 (en) System and method for database migration and validation
CN109375901A (en) Interface message management method, device, computer equipment and storage medium
CN106469140A (en) A kind of report generating system and its method
CN100373388C (en) Method for fast generating logical circuit
CN111177113B (en) Data migration method, device, computer equipment and storage medium
CN108776702A (en) A kind of data make a report on page user-defined visual configuration method
US20080052619A1 (en) Spell Checking Documents with Marked Data Blocks
CN103309849B (en) A kind of docx document creation based on OpenXML and amending method
CN108256716A (en) The method and apparatus of flow and/or atom flow is configured/performed based on table
CN110688145B (en) Android MVP code automatic generation method and device, medium and electronic equipment
CN106776304A (en) Method based on printout information is controlled in multithreading exploitation under built-in Linux
CN106407172A (en) XML (Extensible Markup Language)-based report generating method
CN108446115A (en) A kind of method and device of code reuse
CN106970758A (en) Electronic document operation processing method, device and electronic equipment
CN114047970A (en) Configuration method and system of AUTOSAR (automotive open system architecture) architecture software
CN112817592A (en) Automatic code generation method based on entity annotation
CN107329756A (en) Generation method, device, storage medium, processor and the terminal of program file
CN108959222A (en) List management system writes terminal, controlling terminal, method and medium
CN115509904A (en) Assertion generation method and device of interface test case
CN108845857A (en) A kind of icon management method and device based on cloud platform
CN115390936A (en) Unified verification method, device, equipment and storage medium
CN111143450B (en) Method and device for importing data
CN110532391B (en) Text part-of-speech tagging method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20170531

WD01 Invention patent application deemed withdrawn after publication