CN104035829A - Lock debugging method and module - Google Patents

Lock debugging method and module Download PDF

Info

Publication number
CN104035829A
CN104035829A CN201410225366.9A CN201410225366A CN104035829A CN 104035829 A CN104035829 A CN 104035829A CN 201410225366 A CN201410225366 A CN 201410225366A CN 104035829 A CN104035829 A CN 104035829A
Authority
CN
China
Prior art keywords
lock
mistake
suffix
prefix
module
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.)
Granted
Application number
CN201410225366.9A
Other languages
Chinese (zh)
Other versions
CN104035829B (en
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.)
Opzoon Technology Co Ltd
Original Assignee
Opzoon 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 Opzoon Technology Co Ltd filed Critical Opzoon Technology Co Ltd
Priority to CN201410225366.9A priority Critical patent/CN104035829B/en
Publication of CN104035829A publication Critical patent/CN104035829A/en
Application granted granted Critical
Publication of CN104035829B publication Critical patent/CN104035829B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention relates to a computer technology, and provides a lock debugging method and module. The method includes the steps that a first prefix fixed in length is added into a data structure of a lock; when the lock is generated, a specific value is assigned to the field where the first prefix of the lock is located, and the specific value and the code name of the lock are correspondingly stored; when errors happen to the lock, whether the value of the field where the first prefix of the lock is located is equal to the stored specific value or not is judged, and if the value of the field where the first prefix of the lock is located is equal to the stored specific value, it is judged that the errors are errors of the lock. According to the lock debugging method and module, mainly, the prefix used for verification is added into the data structure of the lock so that whether the data structure of the lock is damaged or not can be judged when the errors occur, and therefore the abnormity caused by the errors of the lock and the abnormity caused by memory errors can be effectively differentiated.

Description

A kind of method and module of debugging lock
Technical field
The present invention relates to computer technology, be specifically related to a kind of method and module of debugging lock.
Background technology
Lock is the basic interface that various operating system all provides, and it is used for ensureing the correctness of polycaryon processor tasks carrying.In the use, lock is matching used, has the latching operation of adding just must, to there being unlocking operation, still there is no release if locked, and will cause so serious Deadlock.Due to improper use, may cause the data structure of lock destroyed, this just causes adding latching operation simultaneously.Therefore in the use procedure of lock, need to know where locked and there is no release, judge that whether this lock is destroyed simultaneously.
Prior art scheme increases a line number conventionally in the interface locking, in the time of deadlock, search the code locking of corresponding lock, find corresponding line number, thereby know that concrete which position has locked, and then finds out by looking into the method for code the place that there is no release.
But prior art scheme is only to be looked for and specifically added lock position by interpolation line number, the situation can only debug deadlock time, in the time that lock is destroyed, can not detects this situation in this scheme, thereby can not correctly handle it.
Summary of the invention
(1) technical matters solving
For the deficiencies in the prior art, the invention provides a kind of method and module of debugging lock, it mainly adds one section of prefix for verification in the data structure of lock, judge and occur that whether the data structure of the lock when wrong is destroyed, then can effectively distinguish the abnormal of the mistake of lock self and lock that EMS memory error causes.
(2) technical scheme
For realizing above object, the present invention is achieved by the following technical programs:
A method of debugging lock, is characterized in that, the method comprises:
In the data structure of lock, add the first fixing prefix of length;
While generating lock, compose a particular value to described the first prefix place field, and the code name corresponding stored of described particular value and lock;
While locking out existing mistake, judge whether this value that is locked in described the first prefix place field equates with the particular value of storage, judge that if equate this mistake belongs to the mistake of lock self.
Preferably, the method also comprises: in the data structure of lock, add the first fixing suffix of length; Call while locking, deposit the function name of the function that locks used in described the first suffix; While locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, find the used function that locks by this content that is locked in described the first suffix storage.
Preferably, the length of described the first prefix is fixed as 4 bytes.
Preferably, the method also comprises: in the data structure of lock, add the second fixing suffix of length; Call while locking, deposit call statement place line number in described the second suffix; While locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, find call statement position by this content that is locked in described the second suffix storage.
Preferably, the method also comprises: lock out existing when wrong, unequal with the particular value of storage if this is locked in described first value of prefix place field, use the method that internal memory detects to locate errors present.
A module of debugging lock, is characterized in that, this module comprises:
The first prefix adding device, for adding the first fixing prefix of length in the data structure of lock;
Assignment storage unit, in the time generating lock, composes a particular value to described the first prefix place field, and the code name corresponding stored of described particular value and lock;
Wrong identification unit, in the time locking out existing mistake, judges whether this value that is locked in described the first prefix place field equates with the particular value of storage, judges that this mistake belongs to the mistake of lock self if equate.
Preferably, described module also comprises: the first suffix adding device, for add the first fixing suffix of length in the data structure of lock; Function name storage unit, for calling while locking, deposits the function name of the function that locks used in described the first suffix; Function is searched unit, in the time locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, finds the used function that locks by this content that is locked in described the first suffix storage.
Preferably, the length of described the first prefix is fixed as 4 bytes.
Preferably, described module also comprises: the second suffix adding device, for add the second fixing suffix of length in the data structure of lock; Line number storage unit, for calling while locking, deposits call statement place line number in described the second suffix; Statement positioning unit, in the time locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, finds call statement position by this content that is locked in described the second suffix storage.
Preferably, described module also comprises: mistake processing unit, for lock out existing when wrong, unequal with the particular value of storage if this is locked in described first value of prefix place field, use the method that internal memory detects to locate errors present.
(3) beneficial effect
The present invention at least has following beneficial effect:
The present invention by increasing the first fixing prefix of a segment length in the data structure of lock, and compose a particular value in the time generating lock described the first prefix place field, and store accordingly, for the data structure of lock is carried out to verification, judge that whether the related data of lock is destroyed.
In terms of existing technologies, it is before carrying out mistake processing, first distinguish mistake and the lock that causes of EMS memory error abnormal of locking self, thus can carry out again corresponding processing determining in the not in-problem situation of lock self, thereby the having higher success rate of its processing in general.
Certainly, implement arbitrary product of the present invention or method and might not need to reach above-described all advantages simultaneously.
Brief description of the drawings
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, accompanying drawing to required use in embodiment or description of the Prior Art being done to one below simply introduces, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the process flow diagram of a kind of method of debugging lock in one embodiment of the invention;
Fig. 2 is the data structure schematic diagram that has added the lock of the first prefix magic, the first suffix name and the second suffix line in one embodiment of the invention;
Fig. 3 is the structured flowchart of a kind of module of debugging lock in one embodiment of the invention.
Embodiment
For making object, technical scheme and the advantage of the embodiment of the present invention clearer, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiment.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment 1
The embodiment of the present invention has proposed a kind of method of debugging lock, and referring to Fig. 1, the method comprises:
Step 101: add the first fixing prefix of length in the data structure of lock;
Step 102: while generating lock, compose a particular value to described the first prefix place field, and the code name corresponding stored of described particular value and lock;
Step 103: while locking out existing mistake, judge whether this value that is locked in described the first prefix place field equates with the particular value of storage, judge that if equate this mistake belongs to the mistake of lock self.
That is to say, it is mainly in the data structure of lock, to increase the first fixing prefix of a segment length, and compose a particular value in the time generating lock described the first prefix place field, and store accordingly, for the data structure of lock is carried out to verification, whether the related data that judges lock is destroyed, then can effectively distinguish the abnormal of the mistake of lock self and the lock that causes of EMS memory error.Preferably get the length that 4 bytes are described the first prefix (corresponding particular value can be just the such numerical value of 0x5AA59527 or 0x12345678), it both can reach enough checking precisions, be unlikely to again to take too many space, and adapt with general translation and compiling environment, be easy to realize.
Preferably, judge the wrong mistake that does not belong to lock self, when namely this value that is locked in described the first prefix place field is whether unequal with the particular value of storage, locating errors present by the method that internal memory detects.That is to say, if verification is not passed through, the data structure of explanation lock is destroyed, need to from internal memory, find the operation that may destroy its data, thereby needs the method that uses storage to detect.Such design is the same with said method, can effectively distinguish the abnormal of the mistake of lock self and the lock that causes of EMS memory error, can also further process for type of error on this basis, thereby compare prior art and have higher power and the treatment effeciency of being processed into.
Preferably, on the basis of such scheme, then give in the data structure of lock and increase the first fixing suffix of a segment length, it is mainly used in the function name of storing all functions in the time calling lock, and occurs when wrong location call function fast at lock self.Certainly, also can increase again the second fixing suffix of a segment length here, for store the line number of call statement in the time calling lock.Above 2 are all conducive in the time that mistake appears in lock self, calling station be located fast, are convenient to efficiently carrying out of bad debug.
Combine above-mentioned the first prefix magic, the first suffix name and the second suffix line field lock data structure as shown in Figure 2, be equivalent to like this go expansion by being locked into.It mainly completes by following process:
In the time generating lock, pay a special value to the magic field of lock, such as the numerical value of 0x5aa59527 or 0x12345678 and so on, be 0 by name and line field assignment simultaneously.When calling while locking, by character string copy function strncpy (name, _ _ FUNCTION__, 63) function name is copied in the structure of lock, wherein _ _ FUNCTION__ representative function name, ensure corresponding correct function name by compiler, in this example the corresponding function command that calls lock.Meanwhile, add line number to line field line=__LINE__, wherein _ _ LINE__ represents line number, ensures corresponding concrete line number by compiler, in this example the corresponding local line number of calling lock.
In the time there is lock wrong, first find magic field, look at the particular value set before being whether, if not, illustrate that the related data of lock is destroyed, need to locate by the method for internal memory detection.If magic does not have destroyed, so by checking name and line field, concrete function and concrete line number just can be found.Then by reading code, just can find wrong place.
Under the scheme of prior art, it is only to look for and specifically add lock position by adding line number, if thereby each to be locked in the local line number that locks in different files be the same, scheme has not just had effect so.And in embodiments of the present invention, it further locates again the position of the statement that locks with function name, not only more accurate, and also locating speed is also faster.
On the whole, use said method can effectively find that the fundamental cause of the problem of locking is that mistake and the EMS memory error of distinguishing lock itself causes the abnormal of lock.Simultaneously, for the problem of lock, can find fast concrete function name and line number, namely can be fast with source code correspondence on, therefore relatively easy in the use, efficiency is higher.
Embodiment 2
The embodiment of the present invention has proposed a kind of module of debugging lock, and referring to Fig. 3, this module comprises:
The first prefix adding device 301, for adding the first fixing prefix of length in the data structure of lock;
Assignment storage unit 302, in the time generating lock, composes a particular value to described the first prefix place field, and the code name corresponding stored of described particular value and lock;
Wrong identification unit 303, in the time locking out existing mistake, judges whether this value that is locked in described the first prefix place field equates with the particular value of storage, judges that this mistake belongs to the mistake of lock self if equate.
Preferably, described module also comprises: the first suffix adding device, for add the first fixing suffix of length in the data structure of lock; Function name storage unit, for calling while locking, deposits the function name of the function that locks used in described the first suffix; Function is searched unit, in the time locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, finds the used function that locks by this content that is locked in described the first suffix storage.It is conducive in the time that mistake appears in lock self, calling station be located fast, is convenient to efficiently carrying out of bad debug.
Preferably, the length of described the first prefix is fixed as 4 bytes.It both can reach enough checking precisions, was unlikely to again to take too many space, and adapted with general translation and compiling environment, was easy to realize.
Preferably, described module also comprises: the second suffix adding device, for add the second fixing suffix of length in the data structure of lock; Line number storage unit, for calling while locking, deposits call statement place line number in described the second suffix; Statement positioning unit, in the time locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, finds call statement position by this content that is locked in described the second suffix storage.It is similarly conducive in the time that mistake appears in lock self, calling station be located fast, is convenient to efficiently carrying out of bad debug.
Preferably, described module also comprises: mistake processing unit, for lock out existing when wrong, unequal with the particular value of storage if this is locked in described first value of prefix place field, use the method that internal memory detects to locate errors present.It can effectively distinguish the abnormal of the mistake of lock self and the lock that causes of EMS memory error, can also further process for type of error on this basis, thereby compare prior art and have higher power and the treatment effeciency of being processed into.
Described module is for carrying out the method for debugging lock as described in Example 1, thereby it has corresponding structure, function and beneficial effect.
In sum, the present invention proposes a kind of method and module of debugging lock, can locate efficiently concrete which file, which code has locked, but there is no release, can effectively judge the situation whether lock is destroyed simultaneously.It mainly adds one section of prefix for verification in the data structure of lock, judges and occurs that whether the data structure of the lock when wrong is destroyed, then can effectively distinguish the abnormal of the mistake of lock self and lock that EMS memory error causes.
It should be noted that, in this article, relational terms such as the first and second grades is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply and between these entities or operation, have the relation of any this reality or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby the process, method, article or the equipment that make to comprise a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or be also included as the intrinsic key element of this process, method, article or equipment.The in the situation that of more restrictions not, the key element being limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
Above embodiment only, in order to technical scheme of the present invention to be described, is not intended to limit; Although the present invention is had been described in detail with reference to previous embodiment, those of ordinary skill in the art is to be understood that: its technical scheme that still can record aforementioned each embodiment is modified, or part technical characterictic is wherein equal to replacement; And these amendments or replacement do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (10)

1. a method of debugging lock, is characterized in that, the method comprises:
In the data structure of lock, add the first fixing prefix of length;
While generating lock, compose a particular value to described the first prefix place field, and the code name corresponding stored of described particular value and lock;
While locking out existing mistake, judge whether this value that is locked in described the first prefix place field equates with the particular value of storage, judge that if equate this mistake belongs to the mistake of lock self.
2. method according to claim 1, is characterized in that, the method also comprises:
In the data structure of lock, add the first fixing suffix of length;
Call while locking, deposit the function name of the function that locks used in described the first suffix;
While locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, find the used function that locks by this content that is locked in described the first suffix storage.
3. method according to claim 1, is characterized in that, the length of described the first prefix is fixed as 4 bytes.
4. according to the method described in any one in claims 1 to 3, it is characterized in that, the method also comprises:
In the data structure of lock, add the second fixing suffix of length;
Call while locking, deposit call statement place line number in described the second suffix;
While locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, find call statement position by this content that is locked in described the second suffix storage.
5. according to the method described in any one in claims 1 to 3, it is characterized in that, the method also comprises: lock out existing when wrong, unequal with the particular value of storage if this is locked in described first value of prefix place field, use the method that internal memory detects to locate errors present.
6. a module of debugging lock, is characterized in that, this module comprises:
The first prefix adding device, for adding the first fixing prefix of length in the data structure of lock;
Assignment storage unit, in the time generating lock, composes a particular value to described the first prefix place field, and the code name corresponding stored of described particular value and lock;
Wrong identification unit, in the time locking out existing mistake, judges whether this value that is locked in described the first prefix place field equates with the particular value of storage, judges that this mistake belongs to the mistake of lock self if equate.
7. module according to claim 6, is characterized in that, described module also comprises:
The first suffix adding device, for adding the first fixing suffix of length in the data structure of lock;
Function name storage unit, for calling while locking, deposits the function name of the function that locks used in described the first suffix;
Function is searched unit, in the time locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, finds the used function that locks by this content that is locked in described the first suffix storage.
8. method according to claim 1, is characterized in that, module according to claim 6, is characterized in that, the length of described the first prefix is fixed as 4 bytes.
9. according to the module described in any one in claim 6 to 8, it is characterized in that, described module also comprises:
The second suffix adding device, for adding the second fixing suffix of length in the data structure of lock;
Line number storage unit, for calling while locking, deposits call statement place line number in described the second suffix;
Statement positioning unit, in the time locking out existing mistake, if this mistake is determined the mistake that belongs to lock self, finds call statement position by this content that is locked in described the second suffix storage.
10. according to the module described in any one in claim 6 to 8, it is characterized in that, described module also comprises: mistake processing unit, for in the time locking out existing mistake, if this be locked in described first value of prefix place field and the particular value of storage unequal, the method location errors present that uses internal memory to detect.
CN201410225366.9A 2014-05-26 2014-05-26 A kind of method and module for debugging lock Active CN104035829B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410225366.9A CN104035829B (en) 2014-05-26 2014-05-26 A kind of method and module for debugging lock

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410225366.9A CN104035829B (en) 2014-05-26 2014-05-26 A kind of method and module for debugging lock

Publications (2)

Publication Number Publication Date
CN104035829A true CN104035829A (en) 2014-09-10
CN104035829B CN104035829B (en) 2018-01-12

Family

ID=51466603

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410225366.9A Active CN104035829B (en) 2014-05-26 2014-05-26 A kind of method and module for debugging lock

Country Status (1)

Country Link
CN (1) CN104035829B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6922821B1 (en) * 2001-11-15 2005-07-26 Cypress Semiconductor Corp. System and a method for checking lock step consistency between an in circuit emulation and a microcontroller while debugging process is in progress
CN101403979A (en) * 2008-10-27 2009-04-08 成都市华为赛门铁克科技有限公司 Locking method for self-spinning lock and computer system
US7526422B1 (en) * 2001-11-13 2009-04-28 Cypress Semiconductor Corporation System and a method for checking lock-step consistency between an in circuit emulation and a microcontroller
CN101425677A (en) * 2008-08-13 2009-05-06 曲娜 Anti-fraud induction motor protector
CN101820368A (en) * 2010-04-08 2010-09-01 华为技术有限公司 Ethernet link failure detection method and device
CN103293949A (en) * 2013-06-08 2013-09-11 杭州和利时自动化有限公司 On-off output channel redundancy fault-tolerant control method and redundancy on-off output channels

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7526422B1 (en) * 2001-11-13 2009-04-28 Cypress Semiconductor Corporation System and a method for checking lock-step consistency between an in circuit emulation and a microcontroller
US6922821B1 (en) * 2001-11-15 2005-07-26 Cypress Semiconductor Corp. System and a method for checking lock step consistency between an in circuit emulation and a microcontroller while debugging process is in progress
CN101425677A (en) * 2008-08-13 2009-05-06 曲娜 Anti-fraud induction motor protector
CN101403979A (en) * 2008-10-27 2009-04-08 成都市华为赛门铁克科技有限公司 Locking method for self-spinning lock and computer system
CN101820368A (en) * 2010-04-08 2010-09-01 华为技术有限公司 Ethernet link failure detection method and device
CN103293949A (en) * 2013-06-08 2013-09-11 杭州和利时自动化有限公司 On-off output channel redundancy fault-tolerant control method and redundancy on-off output channels

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张予现等: "一种链状数据结构细粒度自动加锁方法", 《小型微型计算机系统》 *

Also Published As

Publication number Publication date
CN104035829B (en) 2018-01-12

Similar Documents

Publication Publication Date Title
Pham et al. Detection of recurring software vulnerabilities
CN109359468B (en) Vulnerability detection method, device and equipment
US7861305B2 (en) Method and system for hardware based program flow monitor for embedded software
US8645761B2 (en) Precise fault localization
DeFreez et al. Path-based function embedding and its application to specification mining
Ding et al. Towards learning (dis)-similarity of source code from program contrasts
CN100562859C (en) The method and apparatus of the operational scheme of test procedure
CN105701410A (en) Information, device and system for obtaining information in source codes
CN110866258A (en) Method for quickly positioning bug, electronic device and storage medium
CN105183789A (en) File merging method and system based on git source code confliction
CN114462044A (en) UEFI (unified extensible firmware interface) firmware vulnerability static detection method and device based on taint analysis
Ding et al. Contrastive learning for source code with structural and functional properties
Kanda et al. Extraction of product evolution tree from source code of product variants
KR102124049B1 (en) Apparatus for processing security event using block chain and smart contract and method therefor
CN104504336A (en) Method and device for preventing embedded system from being maliciously debugged online
Liu et al. Control-Flow Checking Using Branch Sequence Signatures
US20220284109A1 (en) Backdoor inspection apparatus, backdoor inspection method, and non-transitory computer readable medium
CN104035829A (en) Lock debugging method and module
CN103514402A (en) Intrusion detection method and device
So et al. SmartFix: Fixing Vulnerable Smart Contracts by Accelerating Generate-and-Verify Repair using Statistical Models
CN110727597A (en) Method for completing use case based on log troubleshooting invalid codes
CN103778114A (en) System and method for file recovery
WO2020053264A1 (en) Binary software composition analysis
CN101661399B (en) Method for modular software removal
CN115310087A (en) Website backdoor detection method and system based on abstract syntax tree

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PP01 Preservation of patent right
PP01 Preservation of patent right

Effective date of registration: 20180528

Granted publication date: 20180112