Abstract:
Disclosed is a method of tracing a program that comprises: providing a relational database data structure defining a plurality of fields configured to store program trace information; executing a program comprising a plurality of functions including calling a function from the program; extracting first trace data of the function and storing the first trace data in a portion of the plurality of fields; and after executing the program, extracting second trace data associated with the first trace data and storing the second trace data in remaining portions of the plurality of fields.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This U.S. non-provisional patent application claims priority under 35 U.S.C. §119 to Korean Patent Application No. 10-2007-0006640 filed on Jan. 22, 2007, the entire contents of which are hereby incorporated by reference. 
       BACKGROUND 
       [0002]    The present invention disclosed herein relates to a program trace and more particularly, to a method of tracing a program for solving the bottleneck phenomenon that affects program performance. 
         [0003]    Conventional software trace and profilers do not provide a satisfactory function of optimizing software. As used herein, a trace analyzes relational information of a function that is executed by a program in order to solve the bottleneck phenomenon with respect to the function during execution of a program. The profiling is listing characteristics of a program based on trace data that is collected to execute a program trace. For example, the program profiling can include generating a listing including a maximum execution time of a program, a function name having the longest execution time in a program, and the like. 
         [0004]    In general, gprof of GNU (GNU stands for “GNU&#39;s Not Unix,” refer to a web site: www.gnu.org) is used for the program profiling. The gprof of GNU can provide overall profile information such as the execution time of respective functions executed by a program, the execution weight of a child function of the respective functions, a function call number, and the like. The gprof of GNU is disclosed in greater detail in a web site, “www.cs.utah.edu/dept/old/texinfo/as/gprof.html”. 
         [0005]    Further, a program of showing a program trace using simulation can include SocDesigner of ARM (Acorn RISC Machine: ARM Holdings, Inc.) (refer to a web site: www.arm.com). The SocDesigner of ARM can provide profile information in a similar level to the gprof of GNU. 
         [0006]    Meanwhile, ETM (Embedded Trace Macrocell) of ARM extracts instructions really executed at the hardware level and reproduces execution of a program using the extracted instructions. But the ETM of ARM does not support the trace browsing of a function call unit, and provides profile information in a lower level than that of the gprof of GNU. 
         [0007]    In order to optimize program performance more effectively, there can be required function of browsing a call trace of a program execution function, displaying information related to program execution activation history and profiling, displaying information related to the history and profiling of a program path, providing information related to a parent function of a program execution function, and the like. CallStack means information related to the order of functions that are called while a program is executed. 
       SUMMARY OF THE INVENTION 
       [0008]    In accordance with the present invention, there is provided a program tracing and profiling method using a relational database. 
         [0009]    One aspect of the present invention is to provide a method of tracing a program that comprises providing a relational database data structure defining a plurality of fields configured to store program trace information; executing a program comprising a plurality of functions including calling a function from the program; extracting first trace data of the function and storing the first trace data in a portion of the plurality of fields; and after the executing the program, extracting second trace data associated with the function using the first trace data and storing the second trace data in remaining portions of the plurality of fields. 
         [0010]    The first trace data can comprise a name, a start time, and an end time associated with the called function. 
         [0011]    The plurality of fields of the relational database can comprise an activity ID and a set of information related to the activity ID including a function ID, a start time, a continuation time, a first child function activity ID, a first sibling function activity ID, a next activity ID, and a parent function activity ID. 
         [0012]    The second trace data can comprise the first sibling function activity ID and the next activity ID. 
         [0013]    The remaining portions of the plurality of fields can comprise the first sibling function activity ID and the next activity ID. 
         [0014]    The method can further comprise designating the called function in the activity ID; and outputting start, end, and continuation times associated with the activity ID and start, end and continuation times of a child function that the function indicated by the activity ID calls. 
         [0015]    The method can further comprise recursively displaying information of child functions associated with the activity ID up to a predetermined depth. 
         [0016]    The depth indicates calls and returns between the called function and child functions. 
         [0017]    The method can further comprise: tracing activity of the called function as a function to be browsed using one or more of: a previous activity of the function to be browsed, a next activity of the function to be browsed, an activity of a parent function of the function to be browsed, an activity of an Nth child function of the function to be browsed, an activity of the function to be browsed that a parent function of the function to be browsed calls prior to the function, and an activity of the function to be browsed that a parent function of the function to be browsed calls next after the function. 
         [0018]    The method can further comprise: designating a program path by providing at least one of a start function ID and an end function ID of the program path, a function ID that the program path passes, and a function ID that no program path passes; and displaying a start time, an end time, and a continuation time of function IDs corresponding to the program path. 
         [0019]    The program path can comprise path functions between the start function and the end function indicated by the start function ID and the end function ID, respectively. 
         [0020]    The path functions can comprise a first function called by the start function, a (N−1)th function called by the first function, and an Nth function called from the (N−1)th function. 
         [0021]    The method can further comprise recursively displaying functions corresponding to the program path up to a predetermined depth. 
         [0022]    The depth can indicate calls and returns between the functions. 
         [0023]    The method can further comprise providing at least one of a previous activity and a next activity of the program path to trace activity of the program path. 
         [0024]    The method can further comprise establishing at least one trace parameter corresponding to at least one of: an activation number range of the activity ID, a time range of the activity ID, an activity included in a program path, an activity having a specific function as a descendant function, and an activity having a specific function as an ancestor function; and outputting activation start, end and continuation times of the activity ID and activation history information of a parent function of the activity ID based on the established at least one trace parameter. The descendant function can be a function that a child function calls and the ancestor function is a function that a parent function calls. 
         [0025]    The method can further comprise establishing at least one program path trace parameter including: an activity number range of a specific function, and a specific time interval; and outputting activation start, end and continuation times of the program path according to the at least one trace parameter. 
         [0026]    The method can further comprise outputting a call number and an execution time of each parent function associated with the activity ID. 
         [0027]    The method can further comprise designating a time and an activity ID for generating a CallStack and outputting the CallStack. 
         [0028]    The CallStack can be a call order of the activity ID. 
     
    
     
       BRIEF DESCRIPTION OF THE FIGURES 
         [0029]    Non-limiting and non-exhaustive embodiments in accordance with aspects of the present invention will be described with reference to the following figures, wherein like reference numerals refer to like parts throughout the various figures unless otherwise specified. In the figures: 
           [0030]      FIG. 1  is a graph showing variation of execution time of a first function # 1 , a second function # 2 , and a third function # 3  that are executed in a program. 
           [0031]      FIG. 2  is a flow diagram showing an embodiment of an execution path of first to fourth functions Fun_A, Fun_B, Fun_C, Fun_D, and Fun_E that are executed in a program. 
           [0032]      FIG. 3  is a block diagram showing an embodiment of a relational database data structure comprising a plurality of fields according to aspects of the present invention. 
           [0033]      FIG. 4A  shows an exemplary program. 
           [0034]      FIG. 4B  is a block diagram showing the call relationship of functions in a program illustrated in  FIG. 4A . 
           [0035]      FIG. 4C  is a table showing the call relationships of functions in  FIG. 4B  that are stored using the relational database. 
           [0036]      FIG. 4D  is a timing diagram for describing the call relationship of functions according to the relational database. 
           [0037]      FIG. 5  is a diagram showing an embodiment of an output from a trace according to aspects of the present invention. 
           [0038]      FIG. 6  is a diagram showing another embodiment of an output from a trace according to aspects of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS 
       [0039]    Preferred embodiments in accordance with aspects of the present invention will be described below in more detail with reference to the accompanying drawings, showing a flash memory device as an example for illustrating structural and operational features by the invention. The present invention can, however, be embodied in different forms and should not be construed as limited to the embodiments set forth herein. Like reference numerals refer to like elements throughout the accompanying figures. 
         [0040]    It will be understood that, although the terms first, second, etc. are be used herein to describe various elements, these elements should not be limited by these terms. These terms are used to distinguish one element from another, but not to imply a required sequence of elements. For example, a first element can be termed a second element, and, similarly, a second element can be termed a first element, without departing from the scope of the present invention. As used herein, the term “and/or” includes any and all combinations of one or more of the associated listed items. 
         [0041]    The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the singular forms “a,” “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises,” “comprising,” “includes” and/or “including,” when used herein, specify the presence of stated features, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and/or groups thereof. 
         [0042]      FIG. 1  is a graph showing variations in execution times of a first function # 1 , a second function # 2 , and a third function # 3  that are executed in a program. 
         [0043]    Referring to  FIG. 1 , a conventional trace program does not provide history information that is illustrated in  FIG. 1 . For example, a first function # 1  can require an execution time that is increased as compared with the execution time of the same function after the 50 th  execution. It is necessary to analyze the reason for this increase because the increase could indicate a cause of a program bottleneck. But, no conventional trace program provides information for analyzing such a cause. 
         [0044]    Further, 77 th  activity of a second function # 2  requires an execution time longer than those of other activities of function # 2 . Accordingly, it is necessary to browse (or analyze) the 77 th  activity of the second function # 2  in detail in order to attempt to determine the cause of the variation. 
         [0045]      FIG. 2  is a flow diagram showing an execution path of first to fourth functions Fun_A, Fun_B, Fun_C, Fun_D, and Fun_E that are executed in a program, which could be any type of computer program. 
         [0046]    Referring to  FIG. 2 , the program can execute a first function Fun_A in step S 01 . In step S 02 , the procedure goes to step S 03  (Fun_B) or S 04  (Fun_C) according to a first condition COND # 1 . In step S 05 , the procedure goes to step  06  (Fun_D) or  07  (Fun_E) according to a second condition COND # 2 . 
         [0047]    If a first function Fun_A, a second function Fun_B, a fourth function Fun_D, and a fifth Fun_E are executed according to the first and second conditions COND # 1  and COND# 2 , a conventional trace program does not provide history and summarized profile information with respect to a path that consists of the first function Fun_A, third function Fun_C, fourth function Fun_D, and fifth function Fun_E, as is marked by a dotted line in  FIG. 2 . 
         [0048]    Furthermore, in order to analyze a program, information is required which is related to a parent function, for example, CallStack information generated at any time or calling any function during program execution. However, no conventional trace program supports such a function. This is because performing a trace that calls all functions in a program would generate an excessive amount of information. Thus, it would be difficult to process and analyze such information effectively using conventional approaches. 
         [0049]    Accordingly, the present invention is directed to a method of tracing or profiling any program using a relational database. 
         [0050]      FIG. 3  is a block diagram showing an embodiment of a relational database data structure comprising a plurality of fields according to an aspect of the present invention. 
         [0051]    Referring to  FIG. 3 , the relational database RDB data structure can include a plurality of fields, including activity ID  10 , function ID  20 , start time  30 , continuation time  40 , first child function activity ID  50 , first sibling function activity ID  60 , next activity ID  70 , and parent function activity ID  80 . Each of these fields is configured to store a value corresponding to the field name. 
         [0052]    The activity ID  10  is a number indicating a position of a function in a list of program function, e.g., as ordered according to the start time of execution of each listed function. The function ID  20  is a value that identifies a function activated (or executed) in the program, e.g., each activated function can have a unique function ID  20 . Thus, a function ID will be associated with an activity ID. 
         [0053]    The start time  30  is a time value indicating when the function indicated by the activity ID  10  commences, and the continuation time  40  is a time value indicating a time difference between a start time of the function associated with the activity ID  10  and an end time thereof, i.e., it&#39;s a duration in time of the executed function. The first child function activity ID  50  indicates an activity ID  10  of a firstly called function of the function indicated by the current activity ID  10 , which is referred to as a parent function relative to the child function. The first sibling function activity ID  60  is an activity ID  10  indicating another function that is called by the parent function immediately after the first child function. The next activity ID  70  indicates an activity ID  10  of a next execution of a function indicated by the current activity ID  10  after the current execution thereof. The parent function activity ID  80  indicates an activity ID  10  of a function that calls the function indicated by the current activity ID  10 . 
         [0054]    Herein, a parent function indicates a function that calls any function, a child function indicates a called function, and a sibling function indicates a function that is called from or by the same parent function. 
         [0055]    The moment when a specific function is called from a different function, indicates that the specific function is activated. Therefore, the same function is capable of being repeatedly activated, so that it is possible to indicate each activity of the same function individually. 
         [0056]    A relational database RDB is a database that is capable of expressing data in a table, and is structured for a user and a programmer to communicate with each other without limitation. 
         [0057]    The relational database is a database using the relationship model, and applies the mathematic relationship concept. In case of a conventional CODASYL (COnference on DAta SYstem Language) database, there is used a pointer for correlating data mutually on the basis of one principle, which is that one record is processed at a time. On the other hand, the relational database is capable of freely accessing items in row and column directions without using the above-described pointer. Further, it is possible for a user to split and join a table freely and to add or change contents without affecting other items. Structural simplicity that enables smooth communications between the end-user and the programmer is an advantage of the relational database. 
         [0058]      FIG. 4A  shows an exemplary program, and  FIG. 4B  is a block diagram showing the call relationship of functions in a program illustrated in  FIG. 4A .  FIG. 4C  is an exemplary table showing the call relationship of the functions in  FIG. 4B  that are stored using the relational database, and  FIG. 4D  is a timing diagram for describing the call relationship of functions according to the relational database. 
         [0059]    Referring to  FIGS. 4A to 4D , an activity ID of a main function F 0  is ‘1’, an activity ID of an A function F 1  is ‘2’, an activity ID of a B function F 2  is ‘3’, an activity ID of a C function F 3  is ‘4’, an activity ID of a D function F 4  is ‘5’, an activity ID of a B function F 5  is ‘6’, and an activity ID of an E function F 6  is ‘7’. 
         [0060]    Referring to  FIG. 4C , at time  0 , a program  100  (see  FIG. 4A ) can execute the main function F 0 . The main function F 0  starts at time  0  and is retained until time  85 . At time  5 , the main function F 0  calls the A function F 1 . First child function activity ID of the main function F 0  is ‘2’. That is, the A function F 1  is the first child function of the main function F 0 , which is a parent function of the A function F 1 . 
         [0061]    First child function activity ID of the A function F 1  is ‘3’. That is, the B function F 2  is a first child function of the A function F 1 . First sibling function activity ID of the A function F 1  is ‘5’. In other words, a D function F 4  is a first sibling function of the A function F 1  (also see, for example,  FIG. 4A ). 
         [0062]    At time  0 , the A function F 1  calls the B function F 2 , which commences at time  10  and has a continuation time of 10. First child function activity ID is ‘4’. That is, a C function F 3  is a first sibling function of the B function F 2 . The A function F 1  is a parent function of the B function F 2 . 
         [0063]    At time  20 , the B function F 2  returns to the A function F 1 . At time  25 , the A function F 1  calls the C function F 3 . The C function F 3  commences at time  25  and has a continuation time of 10. The A function F 1  is a parent function of the C function F 3 . 
         [0064]    At time  35 , the C function F 3  returns to the A function F 1 . At time  40 , the A function F 1  returns to the main function F 0 . At time  45 , the main function F 0  calls the D function F 4 . At time  50 , the D function F 4  calls the B function F 5 . 
         [0065]    The B function F 5  starts at time  50  and has a continuation time of 10. First sibling function activity ID of the B function F 5  is ‘7’. That is, an E function F 6  is a first sibling function of the B function F 5 . The D function F 4  is a parent function of the B function F 5 . 
         [0066]    At time  60 , the B function F 5  returns to the D function F 4 . At time  65 , the D function F 4  calls the E function F 6 , which starts at time  65  and has a continuation time of 10. The D function F 4  is a parent function of the E function F 6 . 
         [0067]    At time  75 , the E function F 6  returns to the D function F 4 . At time  80 , the D function F 4  returns to the main function F 0 . The program  100  is ended. 
         [0068]    Activity ID  10  commences at time  0  with the first function, and numbers are assigned to the activity ID  10  sequentially with each subsequent function activation. When the next activity ID  70  is null, this means that the function indicated by function ID  20  corresponding to the activity ID  10  is not activated after the current activation. In a timing diagram of  FIG. 4D , as an example, a horizontal axis indicates a time axis, and a vertical axis indicates depth. The depth indicates that calls and returns between functions are expressed vertically. That is, the depth is increased by ‘1’ when any function is called and decreased by ‘1’ when it returns. 
         [0069]    Accordingly, it is possible to solve the program bottleneck by browsing a function call trace and a program path and by providing a parent function and CallStack information for a specific point in time. 
         [0070]      FIG. 5  is a diagram showing an embodiment of an output from a trace according to aspects of the present invention. 
         [0071]    Referring to  FIGS. 3 to 5 , using a program trace method in accordance with aspects of the present invention, it is possible to browse a function call trace and to output function activity history information and history profiling information of a program path. A program path has a start and an end and comprises a set of functions that execute or activate therebetween. 
         [0072]    In  FIG. 5 , a first column indicates a start time of an activated function, and a second column indicates an end time of an activated function. A third column indicates a continuation (or execution) time of an activated function, and a fourth column indicates child and parent functions of an activated function. 
         [0073]    As understood from  FIG. 5 , in case of the present invention, it is possible to appoint or determine an activity ID  10  of a function ‘HTaskRd’. The depth is assigned a value of ‘4’ for an output of execution information for the function ‘HTaskRd’. 
         [0074]    The execution information of the function ‘HTaskRd’ can include the start and continuation times of the activity ID  10 , the call and continuation times of all child functions called in the activity ID  10 , and the like. Further, the execution information of the function can be generated for a depth of 4, and output recursively for the indicated depth. 
         [0075]    In accordance with aspects of the present invention, it is possible to browse ‘next activity’, ‘previous activity’, ‘activity of an Nth child function’, ‘activity of a parent function’, ‘activity of a function called after a function that a parent function shows’, ‘activity of a function called prior to a parent function’, and the like, which are related to currently displayed activity ID. 
         [0076]    Further, it is possible to output function activity history profiling information according to established conditions. For example, it is possible to establish limitations associated with an activity, such as limiting the trace to a specific time interval, an activity number range of a specific function, and activity in a specific program path. 
         [0077]    Based upon established conditions, it is possible to output activity history information of a specific function (or its summarized information) in a table form and history profiling information of a program path. 
         [0078]    Furthermore, it is possible to establish output conditions of a program path identically to function activity history profiling information. For example, it is possible to define a program path and to output activity history and summarized information of the program path. 
         [0079]    The program path can be defined by a start function and an end function, and a specific function (a path function) can be selectively incorporated between the start and end functions. 
         [0080]      FIG. 6  is a diagram showing another embodiment of an output from a trace of a program path according to aspects of the present invention. 
         [0081]    Referring to  FIG. 6 , the program trace method can browse a program path and provide CallStack information at a specific point in time. A first column indicates a start time of an activated function, and a second column indicates an end time of an activated function. A third column indicates a continuation (or execution) time of an activated function, and a fourth column indicates child and parent functions of an activated function. 
         [0082]    Continuing to refer to  FIG. 6 , a program path is defined by a start function ‘ATInt’ and an end function ‘ReadOpenHost’. It is possible to output the start function ‘ATInt’, the end function ‘ReadOpenHost’, and path functions between the start and end functions ‘ATInt’ and ‘ReadOpenHost’ by browsing a specific activation point in time ‘516’ of the program path. Further, it is possible to recursively output the start function ‘ATInt’, the end function ‘ReadOpenHost’, and the start, end and continuation time of path functions between the start and end functions ‘ATInt’ and ‘ReadOpenHost’. 
         [0083]    The program trace method can provide information of a parent function. That is, the program trace method can enumerate all functions calling a specific function and output how often the specific function is called from each function, a total of execution time of each parent function, and the like. 
         [0084]    The program trace method can output CallStack information at a specific activation point in time of a specific function or at a specific time, and the CallStack can include the call order of activated functions. 
         [0085]    As set forth above, it is possible to improve program performance by browsing a function call trace and a program path and solving program bottlenecks using a parent function and CallStack information for a specific time. 
         [0086]    In this embodiment, a descendant function can be used, which is a function that a child function calls, and an ancestor function can be used, which is a function that a parent function calls. 
         [0087]    As will be appreciated by those skilled in the art, various embodiments of a program trace method in accordance with aspects of the present invention can be implemented or embodied in software, hardware, firmware, or a combination thereof. To the extent necessary, software implementing the program trace method can be stored in or on any form of known or hereafter developed memory or store media, and can be executed by one or more computer processors known in the art or hereafter developed. Those skilled in the art will readily appreciate that the program trace method is not inherently restricted to narrowly defined technical embodiments or implementations. 
         [0088]    The above-disclosed subject matter is to be considered illustrative, and not restrictive, and the appended claims are intended to cover all modifications, enhancements, and other embodiments, which fall within the true spirit and scope of the present invention. Thus, to the maximum extent allowed by law, the scope of the present invention is to be determined by the broadest permissible interpretation of the following claims and their equivalents, and shall not be restricted or limited by the foregoing detailed description.