TWI498727B - Method and system for debugging - Google Patents

Method and system for debugging Download PDF

Info

Publication number
TWI498727B
TWI498727B TW098145393A TW98145393A TWI498727B TW I498727 B TWI498727 B TW I498727B TW 098145393 A TW098145393 A TW 098145393A TW 98145393 A TW98145393 A TW 98145393A TW I498727 B TWI498727 B TW I498727B
Authority
TW
Taiwan
Prior art keywords
error
mode
keyword
segment
file
Prior art date
Application number
TW098145393A
Other languages
Chinese (zh)
Other versions
TW201122809A (en
Inventor
I Hsiang Huang
Original Assignee
Tatung Co
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 Tatung Co filed Critical Tatung Co
Priority to TW098145393A priority Critical patent/TWI498727B/en
Publication of TW201122809A publication Critical patent/TW201122809A/en
Application granted granted Critical
Publication of TWI498727B publication Critical patent/TWI498727B/en

Links

Landscapes

  • Debugging And Monitoring (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Description

一種除錯方法及系統Method and system for debugging

本發明是有關於一種除錯方法,且特別是有關於一種利用解析錯誤訊息的方式來自動找到錯誤點並進行修正的除錯方法及系統。The present invention relates to a debugging method, and more particularly to a debugging method and system for automatically finding an error point and correcting it by means of parsing an error message.

一般的軟體僅可取得已經過編譯的二進位可執行檔,通常只有軟體的作者或著作權所有者等才能夠擁有程式的原始碼。而開放原始碼(Open Source)軟體則為自由再散布,並且可以衍生著作,方便了溝通和分享程式碼。The general software can only obtain the binary executable file that has been compiled. Usually, only the author or copyright owner of the software can own the source code of the program. Open Source software is free to redistribute, and can be derived from books, which facilitates communication and sharing of code.

在開發開放原始碼軟體時,由於開放原始碼系統可能經過多人的修改,因此除錯的機會亦會相對地較多。而一般當編譯發生錯誤時,工程師需以人工手動的方式來進行除錯,此舉不僅費時又容易產生拼字錯誤等的問題,在除錯上還要逐行檢查,相當不便。In the development of open source software, since the open source code system may be modified by many people, the chances of debugging will be relatively large. Generally, when an error occurs in the compilation, the engineer needs to perform manual debugging to debug. This is not only time-consuming but also prone to spelling errors, etc. It is quite inconvenient to check the debugging line by line.

本發明提供一種除錯方法及系統,可自動解析錯誤訊息來找到錯誤處進而自動進行修正。The invention provides a debugging method and system, which can automatically parse an error message to find an error and automatically correct it.

本發明提出一種除錯方法,適用於對程式碼檔案進行除錯。首先,自訊息記錄檔擷取錯誤訊息。接著,依據匹配規則,解析錯誤訊息,而取得發生錯誤的檔案名稱、錯誤型態以及錯誤碼段。其中匹配規則是依據程式碼檔案所使用的編譯器而建立。之後,依據檔案名稱及錯誤型態,自核心來源碼尋找與錯誤碼段對應的正確碼段。然後,藉由錯誤型態來決定修改模式。最後,依據修改模式,以正確碼段來修正檔案名稱對應的程式碼檔案。The invention provides a debugging method suitable for debugging a code file. First, an error message is retrieved from the message log file. Then, according to the matching rule, the error message is parsed, and the file name, the error type, and the error code segment in which the error occurred are obtained. The matching rules are established based on the compiler used by the code file. Then, based on the file name and the error type, the source code source is used to find the correct code segment corresponding to the error code segment. Then, the modification mode is determined by the error pattern. Finally, according to the modification mode, the code file corresponding to the file name is corrected by the correct code segment.

在本發明之一實施例中,上述在自核心來源碼尋找與錯誤碼段對應的正確碼段的步驟之後,更包括開啟檔案名稱對應的程式碼檔案。In an embodiment of the present invention, after the step of searching for the correct code segment corresponding to the error code segment from the source code, the method further includes opening the code file corresponding to the file name.

在本發明之一實施例中,上述錯誤型態包括未宣告型態、未定義型態以及路徑不存在型態其中之一。而上述修改模式包括置換模式與插入模式。若錯誤型態為路徑不存在型態,則判定修改模式為置換模式。另外,若錯誤型態為未宣告型態或未定義型態,則判定修改模式為插入模式。In an embodiment of the invention, the error type includes one of an undeclared type, an undefined type, and a path nonexistent type. The above modification modes include a replacement mode and an insertion mode. If the error type is a path non-existent type, it is determined that the modification mode is the replacement mode. In addition, if the error type is an undeclared type or an undefined type, it is determined that the modified mode is the insert mode.

在本發明之一實施例中,上述依據修改模式,以正確碼段修正檔案名稱對應的程式碼檔案的步驟中,當修改模式為插入模式時,將正確碼段插入至程式碼檔案,其中正確碼段的位置在錯誤碼段的位置之前;另一方面,當修改模式為置換模式時,以正確碼段置換錯誤碼段。In an embodiment of the present invention, in the step of modifying the code file corresponding to the file name by using the correct code segment according to the modification mode, when the modification mode is the insert mode, the correct code segment is inserted into the code file, where the correct The position of the code segment is before the position of the error code segment; on the other hand, when the modification mode is the replacement mode, the error code segment is replaced with the correct code segment.

在本發明之一實施例中,上述當修改模式為置換模式時,更包括若要刪除錯誤碼段,則用空集合來作為正確碼段,以在置換模式時,利用空集合來置換錯誤碼段。In an embodiment of the present invention, when the modification mode is the replacement mode, if the error code segment is to be deleted, the empty set is used as the correct code segment, so that the error code is replaced by the empty set in the replacement mode. segment.

在本發明之一實施例中,上述匹配規則包括第一關鍵字、第二關鍵字、第三關鍵字以及第四關鍵字。而上述依據匹配規則,解析錯誤訊息的步驟,首先辨識第一關鍵字,以依據第一關鍵字將錯誤訊息分為第一片段與第二片段。之後,於第一片段中,依據第二關鍵字取出檔案名稱。接著,於第二片段中,依據第三關鍵字及第四關鍵字而分別取出錯誤碼段及錯誤型態。In an embodiment of the present invention, the foregoing matching rule includes a first keyword, a second keyword, a third keyword, and a fourth keyword. The step of parsing the error message according to the matching rule first identifies the first keyword to divide the error message into the first segment and the second segment according to the first keyword. Then, in the first segment, the file name is extracted according to the second keyword. Next, in the second segment, the error code segment and the error pattern are respectively extracted according to the third keyword and the fourth keyword.

本發明另提出一種除錯系統,適用於對程式碼檔案進行除錯。在此,除錯系統包括擷取模組、解析模組以及修正模組。擷取模組用以自訊息記錄檔中擷取錯誤訊息。解析模組用以依據匹配規則,解析錯誤訊息,而取得發生錯誤的檔案名稱、錯誤型態以及錯誤碼段。其中匹配規則是依據程式碼檔案所使用的編譯器而建立。並且,解析模組會依據檔案名稱及錯誤型態,自核心來源碼(kernel source)尋找與錯誤碼段對應的正確碼段。修正模組用以藉由錯誤型態決定修改模式,再依據修改模式,以正確碼段修正檔案名稱對應的程式碼檔案。The invention further provides a debugging system suitable for debugging a code file. Here, the debugging system includes a capture module, an analysis module, and a correction module. The capture module is used to retrieve an error message from the message log file. The parsing module is configured to parse the error message according to the matching rule, and obtain the file name, the error type, and the error code segment in which the error occurred. The matching rules are established based on the compiler used by the code file. Moreover, the parsing module searches for the correct code segment corresponding to the error code segment from the kernel source according to the file name and the error type. The correction module is used to determine the modification mode by the error type, and then correct the code file corresponding to the file name with the correct code segment according to the modification mode.

在本發明之一實施例中,上述修正模組更包括開啟檔案名稱對應的程式碼檔案。另外,修正模組更包括決定修改模式為插入模式或是置換模式。若錯誤型態為路徑不存在型態,則修正模組判定修改模式為置換模式;若錯誤型態為未宣告型態或未定義型態,則修正模組判定修改模式為插入模式。In an embodiment of the invention, the correction module further includes a code file corresponding to the file name. In addition, the correction module further includes determining whether the modification mode is an insertion mode or a replacement mode. If the error type is a path non-existent type, the correction module determines that the modification mode is the replacement mode; if the error type is an undeclared type or an undefined type, the correction module determines that the modification mode is the insertion mode.

在本發明之一實施例中,上述修正模組於修改模式為插入模式時,將正確碼段插入至程式碼檔案,其中正確碼段的位置在錯誤碼段的位置之前。並且,修正模組於修改模式為置換模式時,以正確碼段置換錯誤碼段。In an embodiment of the invention, the correcting module inserts the correct code segment into the code file when the modified mode is the insert mode, wherein the correct code segment is located before the position of the error code segment. Moreover, when the modification mode is the replacement mode, the correction module replaces the error code segment with the correct code segment.

在本發明之一實施例中,上述匹配規則包括第一關鍵字、第二關鍵字、第三關鍵字以及第四關鍵字。而解析模組辨識錯誤訊息中的第一關鍵字,以依據第一關鍵字將錯誤訊息分為第一片段與第二片段。並且,解析模組會於第一片段中,依據第二關鍵字取出檔案名稱,而於第二片段中,依據第三關鍵字及第四關鍵字而分別取出錯誤碼段及錯誤型態。In an embodiment of the present invention, the foregoing matching rule includes a first keyword, a second keyword, a third keyword, and a fourth keyword. The parsing module identifies the first keyword in the error message to divide the error message into the first segment and the second segment according to the first keyword. Moreover, the parsing module extracts the file name according to the second keyword in the first segment, and extracts the error code segment and the error pattern according to the third keyword and the fourth keyword in the second segment.

基於上述,本發明依據程式碼檔案所使用的編譯器而建立一套匹配規則。據此,一旦在編譯時發生錯誤,便可自訊息記錄檔中取出錯誤訊息,利用上述匹配規則而進一步解析錯誤訊息以找出發生錯誤的地方,並且進一步自動進行修正。據此,大幅節省了修改程式碼檔案的時間,亦增加了除錯的便利性。Based on the above, the present invention establishes a set of matching rules based on the compiler used by the code file. Accordingly, once an error occurs during compilation, the error message can be retrieved from the message log file, and the error message can be further parsed by the above matching rule to find out where the error occurred, and the correction is further automatically performed. As a result, the time for modifying the code file is greatly saved, and the convenience of debugging is also increased.

為讓本發明之上述特徵和優點能更明顯易懂,下文特舉實施例,並配合所附圖式作詳細說明如下。The above described features and advantages of the present invention will be more apparent from the following description.

為了使本發明之內容更為明瞭,以下特舉實施例作為本發明確實能夠據以實施的範例。In order to clarify the content of the present invention, the following specific examples are given as examples in which the present invention can be implemented.

圖1是依照本發明一實施例之除錯方法的流程圖。請參照圖1,在步驟S105中,自訊息記錄檔擷取錯誤訊息。在進行編譯時,可將所產生的訊息導向至一訊息記錄檔。據此,一旦在編譯時發生錯誤,便能自訊息記錄檔中取出錯誤訊息來進行解析,藉以找出錯誤點所在。1 is a flow chart of a method of debugging in accordance with an embodiment of the present invention. Referring to FIG. 1, in step S105, an error message is retrieved from the message record file. When compiling, the generated message can be directed to a message log file. Accordingly, once an error occurs during compilation, the error message can be retrieved from the message log file for parsing to find out the error point.

接著,在步驟S110中,依據匹配規則來解析錯誤訊息,而取得發生錯誤的檔案名稱、錯誤型態以及錯誤碼段。在此,由於錯誤訊息具有固定格式,因此可依據程式碼檔案所使用的編譯器來建立匹配規則。例如,匹配規則包括四組關鍵字(第一關鍵字、第二關鍵字、第三關鍵字及第四關鍵字)。利用第一關鍵字將錯誤訊息分為第一片段與第二片段,再分別利用第二關鍵字、第三關鍵字及第四關鍵字來分別取出檔案名稱、錯誤碼段及錯誤型態。Next, in step S110, the error message is parsed according to the matching rule, and the file name, the error type, and the error code segment in which the error occurred are obtained. Here, since the error message has a fixed format, the matching rule can be established according to the compiler used by the code file. For example, the matching rule includes four sets of keywords (a first keyword, a second keyword, a third keyword, and a fourth keyword). The error message is divided into a first segment and a second segment by using the first keyword, and the second keyword, the third keyword, and the fourth keyword are respectively used to respectively extract the file name, the error code segment, and the error pattern.

以GUN編譯器套裝(GNU Compiler Collection,GCC)為例。錯誤訊息格式例如為「<檔案名稱>:error:…<錯誤型態>…<錯誤碼段>…」或者為「<檔案名稱>:error:…<錯誤碼段>…<錯誤型態>…」。據此,解析錯誤訊息時,可先於錯誤訊息中辨識第一關鍵字「:error:」,將第一關鍵字「:error:」的左方設定為第一片段,將「:error:」的右方設定為第二片段。而在劃分出第一片段與第二片段之後,在第一片段中,利用第二關鍵字(例如「/」與「.」)而取得檔案名稱。另外,在第二片段中,分別利用第三關鍵字(例如「"」、「""」、「/」與「.」)與第四關鍵字(例如「undeclared」或「undefined」或是「No such」)來取得錯誤碼段及錯誤型態。Take the GNU Compiler Collection (GCC) as an example. The error message format is, for example, "<file name>:error:...<error type>...<error code segment>..." or "<file name>:error:...<error code segment>...<error type>... "." Accordingly, when parsing the error message, the first keyword ":error:" can be identified in the error message, and the left side of the first keyword ":error:" is set as the first segment, and ":error:" is set. The right side is set to the second segment. After the first segment and the second segment are divided, in the first segment, the file name is obtained by using the second keyword (for example, "/" and "."). In addition, in the second segment, the third keyword (for example, "", """, "/", and ".") and the fourth keyword (for example, "undeclared" or "undefined" or " No such") to get the error code segment and the error pattern.

舉例來說,假設錯誤訊息為「include/asm/irq.h:4:27:error:asm/arch/irqs.h:No such file or directory」。藉由上述方式可取得檔案名稱「include/asm/irq.h」、錯誤碼段「asm/arch/irqs.h」以及錯誤型態「No such file or directory」。For example, suppose the error message is "include/asm/irq.h:4:27:error:asm/arch/irqs.h:No such file or directory". By the above method, the file name "include/asm/irq.h", the error code segment "asm/arch/irqs.h", and the error type "No such file or directory" can be obtained.

之後,在步驟S115中,依據檔案名稱及錯誤型態,自核心來源碼(kernel source)尋找與錯誤碼段對應的正確碼段。以上述錯誤訊息「include/asm/irq.h:4:27:error:asm/arch/irqs.h:No such file or directory」而言,其錯誤型態為路徑不存在,也就是說可能在asm/arch/此路徑之下並沒有irqs.h,或者是根本不存在asm/arch/此路徑。據此,搜尋核心來源碼的編譯描述檔(Makefile),而獲得目標平台架構ARCH的設定為ARM平台,藉此搜尋到irqs.h正確置放處而得到正確碼段「asm/arch-s3c2410/irqs.h」。之後,即可開啟檔案名稱對應的程式碼檔案(也就是「include/asm/irq.h」)來進行後續的修改。Then, in step S115, according to the file name and the error type, the correct code segment corresponding to the error code segment is searched from the kernel source. In the above error message "include/asm/irq.h:4:27:error:asm/arch/irqs.h:No such file or directory", the error type is that the path does not exist, that is, it may be Asm/arch/ There is no irqs.h under this path, or there is no such path asm/arch/. According to this, the core to the source code of the compiled description file (Makefile), and the target platform architecture ARCH is set to the ARM platform, thereby searching for the correct placement of irqs.h and getting the correct code segment "asm/arch-s3c2410/ Irqs.h". After that, you can open the code file corresponding to the file name (that is, "include/asm/irq.h") for subsequent modification.

然後,在步驟S120中,藉由錯誤型態來決定修改模式(置換模式或插入模式)。例如,錯誤型態可能是未宣告型態「undeclared」或未定義型態「undefined」或者路徑不存在型態「No such file or directory」。若錯誤型態為路徑不存在型態,則決定修改模式為置換模式。另外,若錯誤型態為未宣告型態或未定義型態,則決定修改模式為插入模式。Then, in step S120, the modification mode (replacement mode or insertion mode) is determined by the error pattern. For example, the error pattern may be an undeclared type "undeclared" or an undefined type "undefined" or a path non-existent type "No such file or directory". If the error type is a path non-existent type, it is decided to modify the mode to the replacement mode. In addition, if the error type is undeclared or undefined, it is decided to modify the mode to insert mode.

最後,在步驟S125中,依據修改模式,以正確碼段來修正檔案名稱對應的程式碼檔案。也就是說,當修改模式為插入模式時,將正確碼段插入至程式碼檔案中之錯誤碼段的位置之前。而當修改模式為置換模式時,便以正確碼段來置換錯誤碼段。例如,以上述錯誤訊息「include/asm/irq.h:4:27:error:asm/arch/irqs.h:No such file or directory」而言,其修正模式則為置換模式。也就是說,直接以正確碼段「asm/arch-s3c2410/irqs.h」來置換掉程式碼檔案中的錯誤碼段「asm/arch/irqs.h」。Finally, in step S125, according to the modification mode, the code file corresponding to the file name is corrected by the correct code segment. That is, when the modification mode is the insert mode, the correct code segment is inserted before the position of the error code segment in the code file. When the modification mode is the replacement mode, the error code segment is replaced with the correct code segment. For example, in the above error message "include/asm/irq.h:4:27:error:asm/arch/irqs.h:No such file or directory", the correction mode is the replacement mode. In other words, replace the error code segment "asm/arch/irqs.h" in the code file with the correct code segment "asm/arch-s3c2410/irqs.h".

值得注意的是,倘若要刪除錯誤碼段,則可用空集合來作為正確碼段,以在置換模式時,利用空集合來置換錯誤碼段。It is worth noting that if the error code segment is to be deleted, an empty set can be used as the correct code segment to replace the error code segment with the empty set in the replacement mode.

以下再舉另一錯誤訊息「networking/interface.c:822:error:`ARPHRD_INFINIBAND' undeclared here(not in a function)」來進行說明。此錯誤訊息在經由匹配規則的解析之後,得到檔案名稱「networking/interface.c」、錯誤碼段「ARPHRD_INFINIBAND」以及錯誤型態「undeclared here(not in a function)」。接著,依據「ARPHRD_INFINIBAND」在核心來源碼進行搜尋,而在「include/linux/if_arp.h」中找到「ARPHRD_INFINIBAND」的定義所在,進一步得到正確碼段為「#define ARPHRD_INFINIBAND 32」。然後,開啟檔案名稱對應的程式碼檔案,也就是「networking/interface.c」。由於錯誤型態為未宣告型態,其適用於插入模式,因此便將正確碼段「#define ARPHRD_INFINIBAND 32」插入至「networking/interface.c」中「ARPHRD_INFINIBAND」使用之前。接著關閉「networking/interface.c」,並且清除上次編譯時所產生的檔案,以對修改後的程式碼檔案重新進行編譯。The following error message "networking/interface.c:822:error:`ARPHRD_INFINIBAND' undeclared here(not in a function)" is explained. After the error message is parsed by the matching rule, the file name "networking/interface.c", the error code segment "ARPHRD_INFINIBAND", and the error pattern "undeclared here (not in a function)" are obtained. Next, search for the source code based on "ARPHRD_INFINIBAND", and find the definition of "ARPHRD_INFINIBAND" in "include/linux/if_arp.h", and further get the correct code segment as "#define ARPHRD_INFINIBAND 32". Then, open the code file corresponding to the file name, which is "networking/interface.c". Since the error type is undeclared, it applies to the insert mode, so the correct code segment "#define ARPHRD_INFINIBAND 32" is inserted before "ARPHRD_INFINIBAND" in "networking/interface.c". Then close "networking/interface.c" and clear the file generated during the last compilation to recompile the modified code file.

本發明另提出一種除錯系統,適用於對程式碼檔案進行除錯。圖2是依照本發明一實施例之除錯系統的方塊圖。請參照圖2,除錯系統200包括擷取模組210、解析模組220以及修正模組230。The invention further provides a debugging system suitable for debugging a code file. 2 is a block diagram of a debug system in accordance with an embodiment of the present invention. Referring to FIG. 2 , the debug system 200 includes a capture module 210 , an analysis module 220 , and a correction module 230 .

擷取模組210用以自訊息記錄檔擷取錯誤訊息。解析模組220用以依據匹配規則,解析錯誤訊息,而取得發生錯誤的檔案名稱、錯誤型態以及錯誤碼段。其中匹配規則是依據程式碼檔案所使用的編譯器而建立。並且,解析模組220會依據檔案名稱及錯誤型態,自核心來源碼尋找與錯誤碼段對應的正確碼段。The capture module 210 is configured to retrieve an error message from the message record file. The parsing module 220 is configured to parse the error message according to the matching rule, and obtain the file name, the error type, and the error code segment in which the error occurred. The matching rules are established based on the compiler used by the code file. Moreover, the parsing module 220 searches for the correct code segment corresponding to the error code segment from the core source code according to the file name and the error type.

具體而言,假設匹配規則包括第一關鍵字、第二關鍵字、第三關鍵字以及第四關鍵字。解析模組220可辨識錯誤訊息中的第一關鍵字,以依據第一關鍵字將錯誤訊息分為第一片段與第二片段。並且,解析模組220會於第一片段中,依據第二關鍵字取出檔案名稱,而於第二片段中,依據第三關鍵字及第四關鍵字而分別取出錯誤碼段及錯誤型態。Specifically, it is assumed that the matching rule includes a first keyword, a second keyword, a third keyword, and a fourth keyword. The parsing module 220 can identify the first keyword in the error message to divide the error message into the first segment and the second segment according to the first keyword. In addition, the parsing module 220 extracts the file name according to the second keyword in the first segment, and extracts the error code segment and the error pattern according to the third keyword and the fourth keyword in the second segment.

修正模組230用以藉由錯誤型態決定修改模式,再依據修改模式,以正確碼段修正檔案名稱對應的程式碼檔案。另外,更可利用修正模組230來開啟檔案名稱對應的程式碼檔案。而修正模組230還可依據錯誤型態來決定修改模式為插入模式或是置換模式。若錯誤型態為未宣告型態或未定義型態,則修正模組230判定修改模式為插入模式,以將正確碼段插入至程式碼檔案,其中正確碼段的位置在錯誤碼段的位置之前。而若錯誤型態為路徑不存在型態,則修正模組230判定修改模式為置換模式,而以正確碼段來置換錯誤碼段。The correction module 230 is configured to determine the modification mode by the error type, and then correct the code file corresponding to the file name with the correct code segment according to the modification mode. In addition, the correction module 230 can be used to open the code file corresponding to the file name. The correction module 230 can also determine whether the modification mode is the insertion mode or the replacement mode according to the error type. If the error type is an undeclared type or an undefined type, the correction module 230 determines that the modification mode is the insertion mode to insert the correct code segment into the code file, wherein the position of the correct code segment is at the position of the error code segment. prior to. If the error pattern is a path non-existent type, the correction module 230 determines that the modification mode is the replacement mode, and replaces the error code segment with the correct code segment.

綜上所述,本發明在編譯時將所產生的訊息儲存至訊息記錄檔,並且依據程式碼檔案所使用的編譯器而建立一套匹配規則。據此,一旦在編譯時發生錯誤,便可自訊息記錄檔中取出錯誤訊息,再利用上述匹配規則而進一步解析錯誤訊息以找出發生錯誤的地方,並且進一步自動進行修正。據此,大幅節省了修改程式碼檔案的時間,亦增加了除錯的便利性。In summary, the present invention stores the generated message into the message record file at compile time, and establishes a set of matching rules according to the compiler used by the code file file. Accordingly, once an error occurs during compilation, the error message can be retrieved from the message log file, and the error message can be further parsed using the above matching rule to find out where the error occurred, and the correction is further automatically performed. As a result, the time for modifying the code file is greatly saved, and the convenience of debugging is also increased.

雖然本發明已以實施例揭露如上,然其並非用以限定本發明,任何所屬技術領域中具有通常知識者,在不脫離本發明之精神和範圍內,當可作些許之更動與潤飾,故本發明之保護範圍當視後附之申請專利範圍所界定者為準。Although the present invention has been disclosed in the above embodiments, it is not intended to limit the invention, and any one of ordinary skill in the art can make some modifications and refinements without departing from the spirit and scope of the invention. The scope of the invention is defined by the scope of the appended claims.

S105~S125‧‧‧本發明一實施例之除錯方法各步驟S105~S125‧‧‧ steps of the debugging method of an embodiment of the present invention

200‧‧‧除錯系統200‧‧‧Debug system

210‧‧‧擷取模組210‧‧‧Capture module

220‧‧‧解析模組220‧‧‧analysis module

230‧‧‧修正模組230‧‧‧correction module

圖1是依照本發明一實施例之除錯方法的流程圖。1 is a flow chart of a method of debugging in accordance with an embodiment of the present invention.

圖2是依照本發明一實施例之除錯系統的方塊圖。2 is a block diagram of a debug system in accordance with an embodiment of the present invention.

S105~S125...本發明一實施例之除錯方法各步驟S105~S125. . . Steps of the debugging method according to an embodiment of the present invention

Claims (10)

一種除錯方法,適用於對一程式碼檔案進行除錯,該除錯方法包括:自一訊息記錄檔擷取一錯誤訊息;依據一匹配規則,解析該錯誤訊息,而取得發生錯誤的一檔案名稱、一錯誤型態以及一錯誤碼段,其中該匹配規則是依據該程式碼檔案所使用的一編譯器而建立,該錯誤型態包括一未宣告型態、一未定義型態以及一路徑不存在型態其中之一;依據該檔案名稱及該錯誤型態,自一核心來源碼尋找與該錯誤碼段對應的一正確碼段;藉由該錯誤型態決定一修改模式,其中該修改模式包括一置換模式與一插入模式,而藉由該錯誤型態決定該修改模式的步驟,包括:若該錯誤型態為該路徑不存在型態,則判定該修改模式為該置換模式;以及若該錯誤型態為該未宣告型態或該未定義型態,則判定該修改模式為該插入模式;以及依據該修改模式,以該正確碼段修正該檔案名稱對應的程式碼檔案。 A debugging method is suitable for debugging a code file. The debugging method includes: extracting an error message from a message record file; parsing the error message according to a matching rule, and obtaining an error file a name, an error type, and an error code segment, wherein the matching rule is established according to a compiler used by the code file, the error type including an undeclared type, an undefined type, and a path There is no one of the types; according to the file name and the error type, a correct code segment corresponding to the error code segment is searched from a core source; a modification mode is determined by the error pattern, wherein the modification The mode includes a permutation mode and an insertion mode, and the step of determining the modification mode by the error pattern comprises: determining that the modification mode is the permutation mode if the error type is that the path does not exist; If the error type is the undeclared type or the undefined type, determining that the modified mode is the insert mode; and according to the modified mode, repairing the correct code segment The file name of the corresponding code file. 如申請專利範圍第1項所述之除錯方法,其中在自該核心來源碼尋找與該錯誤碼段對應的該正確碼段的步驟之後,更包括:開啟該檔案名稱對應的程式碼檔案。 The debugging method of claim 1, wherein after the step of searching for the correct code segment corresponding to the error code segment from the core source, the method further comprises: opening a code file corresponding to the file name. 如申請專利範圍第1項所述之除錯方法,其中依據該修改模式,以該正確碼段修正該檔案名稱對應的程式碼檔案的步驟,包括:當該修改模式為該插入模式時,將該正確碼段插入至該程式碼檔案,其中該正確碼段的位置在該錯誤碼段的位置之前;以及當該修改模式為該置換模式時,以該正確碼段置換該錯誤碼段。 The debugging method of claim 1, wherein the step of modifying the code file corresponding to the file name by the correct code segment according to the modification mode comprises: when the modification mode is the insertion mode, The correct code segment is inserted into the code file, wherein the correct code segment is located before the location of the error code segment; and when the modification mode is the replacement mode, the error code segment is replaced with the correct code segment. 如申請專利範圍第3項所述之除錯方法,其中當該修改模式為該置換模式時,更包括:若要刪除該錯誤碼段,則用一空集合來作為該正確碼段,以在該置換模式時,利用該空集合來置換該錯誤碼段。 The debugging method of claim 3, wherein when the modification mode is the replacement mode, the method further comprises: if the error code segment is to be deleted, using an empty set as the correct code segment, In the replacement mode, the empty code set is used to replace the error code segment. 如申請專利範圍第1項所述之除錯方法,更包括:在該程式碼檔案編譯發生錯誤時,儲存該錯誤訊息至該訊息記錄檔。 The method for debugging according to the first aspect of the patent application includes: storing the error message to the message log file when an error occurs in the code file compilation. 如申請專利範圍第1項所述之除錯方法,其中該匹配規則包括一第一關鍵字、一第二關鍵字、一第三關鍵字以及一第四關鍵字,其中依據該匹配規則,解析該錯誤訊息的步驟,包括:辨識該第一關鍵字,以依據該第一關鍵字將該錯誤訊息分為一第一片段與一第二片段;於該第一片段中,依據該第二關鍵字取出該檔案名稱;以及於該第二片段中,依據該第三關鍵字及該第四關鍵字 而分別取出該錯誤碼段及該錯誤型態。 The method for debugging according to claim 1, wherein the matching rule includes a first keyword, a second keyword, a third keyword, and a fourth keyword, wherein the matching rule is used according to the matching rule. The step of the error message includes: identifying the first keyword to divide the error message into a first segment and a second segment according to the first keyword; and in the first segment, according to the second key Word extracting the file name; and in the second segment, according to the third keyword and the fourth keyword The error code segment and the error pattern are respectively taken out. 一種除錯系統,適用於對一程式碼檔案進行除錯,該除錯系統包括:一擷取模組,自一訊息記錄檔中擷取一錯誤訊息;一解析模組,依據一匹配規則,解析該錯誤訊息,而取得發生錯誤的一檔案名稱、一錯誤型態以及一錯誤碼段,其中該匹配規則是依據該程式碼檔案所使用的一編譯器而建立,且該錯誤型態包括一未宣告型態、一未定義型態以及一路徑不存在型態其中之一,並且,依據該檔案名稱及該錯誤型態,自一核心來源碼尋找與該錯誤碼段對應的一正確碼段;以及一修正模組,藉由該錯誤型態決定一修改模式,其中該修改模式包括一置換模式與一插入模式,若該錯誤型態為該路徑不存在型態,則該修正模組判定該修改模式為該置換模式;若該錯誤型態為該未宣告型態或該未定義型態,則該修正模組判定該修改模式為該插入模式;之後,該修正模組依據該修改模式,而以該正確碼段修正該檔案名稱對應的程式碼檔案。 A debugging system, configured to debug a code file, the debugging system comprising: a capture module, extracting an error message from a message record file; and an analysis module, according to a matching rule, Parsing the error message, and obtaining a file name, an error type, and an error code segment in which the error occurred, wherein the matching rule is established according to a compiler used by the code file, and the error type includes one One of the undeclared type, an undefined type, and a path nonexistent type, and, according to the file name and the error type, source code from a core to find a correct code segment corresponding to the error code segment And a correction module, wherein the modification mode includes a modification mode, wherein the modification mode includes a replacement mode and an insertion mode, and if the error type is that the path does not exist, the correction module determines The modification mode is the replacement mode; if the error type is the undeclared type or the undefined type, the correction module determines that the modification mode is the insertion mode; afterwards, the modification Group according to the modification mode, and code segments to correct the correction code file corresponding to the file name. 如申請專利範圍第7項所述之除錯系統,其中該修正模組更包括開啟該檔案名稱對應的程式碼檔案。 The debugging system of claim 7, wherein the correction module further comprises opening a code file corresponding to the file name. 如申請專利範圍第7項所述之除錯系統,其中該修正模組於該修改模式為該插入模式時,將該正確碼段插入至該程式碼檔案,其中該正確碼段的位置在該錯誤碼段的位置之前;並且,該修正模組於該修改模式為該置換模式 時,以該正確碼段置換該錯誤碼段。 The debugging system of claim 7, wherein the correction module inserts the correct code segment into the code file when the modification mode is the insertion mode, wherein the correct code segment is located at the The position of the error code segment is before; and the correction module is in the modification mode in the modification mode The error code segment is replaced with the correct code segment. 如申請專利範圍第7項所述之除錯系統,其中該匹配規則包括一第一關鍵字、一第二關鍵字、一第三關鍵字以及一第四關鍵字,而該解析模組辨識該錯誤訊息中的該第一關鍵字,以依據該第一關鍵字將該錯誤訊息分為一第一片段與一第二片段;並且,於該第一片段中,依據該第二關鍵字取出該檔案名稱;於該第二片段中,依據該第三關鍵字及該第四關鍵字而分別取出該錯誤碼段及該錯誤型態。The debugging system of claim 7, wherein the matching rule includes a first keyword, a second keyword, a third keyword, and a fourth keyword, and the parsing module recognizes the The first keyword in the error message, the error message is divided into a first segment and a second segment according to the first keyword; and, in the first segment, the second keyword is taken out according to the second keyword The file name; in the second segment, the error code segment and the error pattern are respectively extracted according to the third keyword and the fourth keyword.
TW098145393A 2009-12-28 2009-12-28 Method and system for debugging TWI498727B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW098145393A TWI498727B (en) 2009-12-28 2009-12-28 Method and system for debugging

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW098145393A TWI498727B (en) 2009-12-28 2009-12-28 Method and system for debugging

Publications (2)

Publication Number Publication Date
TW201122809A TW201122809A (en) 2011-07-01
TWI498727B true TWI498727B (en) 2015-09-01

Family

ID=45046358

Family Applications (1)

Application Number Title Priority Date Filing Date
TW098145393A TWI498727B (en) 2009-12-28 2009-12-28 Method and system for debugging

Country Status (1)

Country Link
TW (1) TWI498727B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI579721B (en) * 2016-06-13 2017-04-21 崑山科技大學 Approach to construct personal coding activity models

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6647544B1 (en) * 1998-11-30 2003-11-11 International Business Machines Corporation Method and system for debugging hybrid source code
US7340726B1 (en) * 2003-08-08 2008-03-04 Coverity, Inc. Systems and methods for performing static analysis on source code
US7516445B2 (en) * 2005-06-30 2009-04-07 Microsoft Corporation Locating source code when stopping in a debugger
US20090138847A1 (en) * 2007-03-09 2009-05-28 Objective Interface Systems Optimized code generation by eliminating unused virtual function

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6647544B1 (en) * 1998-11-30 2003-11-11 International Business Machines Corporation Method and system for debugging hybrid source code
US7340726B1 (en) * 2003-08-08 2008-03-04 Coverity, Inc. Systems and methods for performing static analysis on source code
US7516445B2 (en) * 2005-06-30 2009-04-07 Microsoft Corporation Locating source code when stopping in a debugger
US20090138847A1 (en) * 2007-03-09 2009-05-28 Objective Interface Systems Optimized code generation by eliminating unused virtual function

Also Published As

Publication number Publication date
TW201122809A (en) 2011-07-01

Similar Documents

Publication Publication Date Title
US10698682B1 (en) Computerized software development environment with a software database containing atomic expressions
US10146532B2 (en) Apparatus and method for detecting code cloning of software
JP6287549B2 (en) Method and apparatus for porting source code
CN106843840B (en) Source code version evolution annotation multiplexing method based on similarity analysis
CN106919612B (en) Processing method and device for online structured query language script
CN107346284B (en) Application program detection method and detection device
CA2500422A1 (en) Annotated automaton encoding of xml schema for high performance schema validation
US10248409B1 (en) Limiting the effects of source code patches on corresponding native-code patches
US20080209393A1 (en) System and method to automatically detect incompatible licensing models
WO2014082422A1 (en) Method and device for code change detection
TWI498727B (en) Method and system for debugging
CN118013526A (en) Binary vulnerability data set construction method and device based on LLM multi-source heterogeneous information fusion
CN105138364B (en) A kind of method and device of terminal system upgrading
Anderson et al. Supporting analysis of SQL queries in PHP AiR
CN115391785A (en) Method, device and equipment for detecting risks of software bugs
Brewer et al. Thirty Years Is Long Enough: Getting Beyond C.
CN111796832B (en) Hot patch file generation method, device, equipment and storage medium
CN110543456B (en) Method and device for quickly reading oasis file and computer readable storage medium
Bartels et al. Formal modeling and verification of low-level software programs
Zaytsev Recovery, convergence and documentation of languages
CN112632107A (en) Retrieval method, retrieval device, storage medium and electronic equipment
KR20040096259A (en) System and method for source code checking
CN111090671B (en) Method and device for eliminating difference between empty character string and invalid character string in database
CN111930413B (en) Automatic patch generation method, device and system
Bajaj Analyzing, Understanding, and Improving Predicted Variable Names in Decompiled Binary Code