DE102009038177A1 - Tracing in a running computer system - Google Patents
Tracing in a running computer system Download PDFInfo
- Publication number
- DE102009038177A1 DE102009038177A1 DE102009038177A DE102009038177A DE102009038177A1 DE 102009038177 A1 DE102009038177 A1 DE 102009038177A1 DE 102009038177 A DE102009038177 A DE 102009038177A DE 102009038177 A DE102009038177 A DE 102009038177A DE 102009038177 A1 DE102009038177 A1 DE 102009038177A1
- Authority
- DE
- Germany
- Prior art keywords
- subroutine
- trace module
- exception handling
- instruction
- exception
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/362—Debugging of software
- G06F11/3636—Debugging of software by tracing the execution of the program
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/362—Debugging of software
- G06F11/3644—Debugging of software by instrumenting at runtime
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
- G06F9/4484—Executing subprograms
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Debugging And Monitoring (AREA)
- Executing Machine-Instructions (AREA)
Abstract
Die vorliegende Erfindung betrifft ein Verfahren zur dynamischen Aktivierung einer Ablaufverfolgung bezüglich eines auf einem Computersystem, das durch einen Betriebssystemkern betrieben wird, laufenden Unterprogramms, wobei das Unterprogramm eine Vielzahl von Instruktionen umfasst und sich in Maschinencode in einem Arbeitsspeicher des Computersystems befindet und wobei eine dieser Instruktionen oder eine Sequenz dieser Instruktionen eine Leeranweisung darstellt, die in Maschinencode eine Größe aufweist, die mindestens der Größe des Maschinencodes einer Sprunganweisung entspricht, und wobei das Verfahren umfasst: Laden des Maschinencodes eines Ablaufverfolgungsmoduls in den Arbeitsspeicher des Computersystems; Ersetzen des Maschinencodes der Leeranweisung des Unterprogramms in dem Arbeitsspeicher durch den Maschinencode einer Sprunganweisung, die ein Umlenken eines Programmkontrollflusses zu dem Ablaufverfolgungsmodul im Arbeitsspeicher ermöglicht; Umlenken, nach Aufruf des Unterprogramms durch ein aufrufendes Programm, des Programmkontrollflusses zu dem Ablaufverfolgungsmodul durch die Sprunganweisung; Registrieren eines Eintritts in das Unterprogramm durch das Ablaufverfolgungsmodul und Rückgabe des Programmkontrollflusses an das Unterprogramm.The present invention relates to a method for dynamically activating a trace with respect to a subroutine running on a computer system which is operated by an operating system kernel, the subroutine comprising a multiplicity of instructions and being located in machine code in a working memory of the computer system, and one of these instructions or a sequence of these instructions represents an idle instruction having a size in machine code that is at least equal to the size of the machine code of a jump instruction, the method comprising: loading the machine code of a trace module into the memory of the computer system; Replacing the machine code of the empty instruction of the subroutine in the working memory with the machine code of a jump instruction which enables a program control flow to be redirected to the tracing module in the working memory; Redirecting, after calling the subroutine by a calling program, the program control flow to the trace module by the jump instruction; Registering entry into the subroutine by the trace module and returning the program control flow to the subroutine.
Description
Die vorliegende Erfindung betrifft eine dynamisch aktivierbare Ablaufverfolgung eines Unterprogramms in einem laufenden Computersystem.The present invention relates to a dynamically activatable trace of a subroutine in a running computer system.
Unterprogramme, manchmal auch als Funktionen, Prozeduren, Routinen oder Subroutinen bezeichnet, stellen in sich abgeschlossene Gruppen von Instruktionen eines Programms dar, die aus dem laufenden Programm heraus aufgerufen werden können und nach Abarbeitung der in dem jeweiligen Unterprogramm befindlichen Instruktionen wieder zu der aufrufenden Stelle im Programm zurückkehren. Das Programm kann dabei das den Computer betreibende Betriebssystem, ein bestimmtes Modul dieses Betriebssystems, ein auf dem Computer unter Zuhilfenahme des Betriebssystems laufendes Anwendungsprogramm oder ein bestimmtes Modul dieses Anwendungsprogramms darstellen.Subprograms, sometimes referred to as functions, procedures, routines, or subroutines, represent self-contained sets of instructions of a program which can be called from the running program and, after execution of the instructions in the respective subroutine, return to the calling location in the program Return program. The program may represent the operating system operating the computer, a specific module of this operating system, an application program running on the computer with the aid of the operating system or a specific module of this application program.
Falls bei der Ausführung solcher Programme Fehler auftreten, ist es notwendig, die Ursache dieses Fehlers herauszufinden. Dies gilt besonders für die Entwicklungsphase eines Programms bzw. Programmmoduls, um möglichst viele Fehlerquellen frühzeitig zu erkennen und zu beseitigen, bevor das Programm bzw. Programmmodul fertiggestellt und ausgeliefert wird. Es ist aber auch für die spätere Anwendungsphase eines Programms bzw. Programmmoduls notwendig, in einer bestimmten Umgebung auftretende Fehlerursachen aufspüren und evtl. bereinigen zu können. Zu diesem Zweck wird die so genannte Ablaufverfolgung eingesetzt, die den Eintritt in ein bestimmtes Unterprogramm und den Austritt aus diesem Unterprogramm registriert, sodass beim Auftritt eines Fehlers im Ablauf eines Programms bzw. Programmmoduls festgestellt werden kann, bei welchem Unterprogramm der Fehler aufgetreten ist. Der Ein- bzw. Austritt kann dabei durch ein zeitliches Protokollieren bzw. Aufzeichnen, Hoch- bzw. Herunterzählen eines Zählers oder eine andere Maßnahme registriert werden, die eine Zuordnung zu dem jeweiligen Unterprogramm ermöglicht.If errors occur during the execution of such programs, it is necessary to find out the cause of this error. This applies in particular to the development phase of a program or program module, in order to recognize and eliminate as many sources of error as possible in good time, before the program or program module is completed and delivered. However, it is also necessary for the later application phase of a program or program module to detect error causes occurring in a specific environment and possibly be able to clean them up. For this purpose, the so-called tracing is used, which registers the entry into a specific subroutine and the exit from this subroutine, so that when an error occurs in the course of a program or program module can determine which subroutine the error has occurred. The entry or exit can be registered by a chronological logging or recording, counting up or down a counter or another measure that allows an assignment to the respective subroutine.
Um die Ablaufverfolgung eines Unterprogramms zu ermöglichen, ist es notwendig, dieses Unterprogramm zu instrumentieren. Dies kann dadurch erreicht werden, dass bereits bei der Programmerstellung spezielle Anweisungen in den Programmcode eingebracht werden, die später die Ablaufverfolgung ermöglichen. Damit ist eine Ablaufverfolgung allerdings nur für solche Unterprogramme eines Programms möglich, für die dies bereits während der Programmierung vorgesehen wurde und in denen sich somit die für die Ablaufverfolgung notwendigen Instruktionen bereits zur Kompilierzeit im Programmcode befinden.In order to enable the tracing of a subroutine, it is necessary to instrument this subroutine. This can be achieved by introducing special instructions into the program code already during the program creation which later enable the trace. However, a trace is only possible for such subroutines of a program for which this was already provided during the programming and in which thus the instructions necessary for the trace are already in the program code at compile time.
Es ist auch möglich, ein Unterprogramm nach Kompilierung des entsprechenden Programms bzw. Programmmoduls für eine Ablaufverfolgung zu instrumentieren. Für eine solche dynamische Instrumentierung ist es notwendig, den bereits im Arbeitsspeicher des Computersystems befindlichen Maschinencode des Programms zu manipulieren. Dabei muss beachtet werden, dass der Maschinencode eines kompilierten Programms bzw. Programmmoduls eine kohärente Bitfolge darstellt und daher zusätzliche Instruktionen nicht ohne Weiteres in den Maschinencode eingefügt werden können ohne dessen Integrität zu beschädigen.It is also possible to instrument a subroutine after compilation of the corresponding program or program module for a trace. For such dynamic instrumentation, it is necessary to manipulate the machine code of the program already resident in the main memory of the computer system. It should be noted that the machine code of a compiled program or program module represents a coherent bit sequence and therefore additional instructions can not be easily inserted into the machine code without damaging its integrity.
Um eine solche Beschädigung zu verhindern, schlägt der aus
Nachteilig ist bei diesem Verfahren jedoch, dass für den Zeitraum, indem die zu verdrängenden Instruktionen in den Pufferspeicher geschrieben werden und statt ihrer der Sprungbefehl eingefügt wird, die funktionale Integrität des Unterprogramms nicht gegeben ist. Da nach Beendigung des Ablaufverfolgungsprogramms alle vorgenommenen Veränderungen im Maschinencode wieder rückgängig gemacht werden müssen, also insbesondere die in dem Pufferspeicher befindlichen Instruktionen zurückgeschrieben werden müssen, ist auch für diesen Zeitraum die funktionale Integrität des Unterprogramms nicht gegeben. Eine derartige zeitweise Beschädigung der funktionalen Integrität kann jedoch zum Abbruch des Unterprogramms und auch des aufrufenden Programms führen. Außerdem kann durch das notwendige Hin- und Herschieben der verdrängten Instruktionen im Arbeitsspeicher das eigentliche Ablaufverhalten des Unterprogramms beeinträchtigt werden, wodurch die Aussagekraft der durch die Ablaufverfolgung gewonnenen Daten infrage gestellt ist. Ein weiterer Nachteil dieses Verfahrens liegt darin, dass im Falle einer beim Ablauf des Unterprogramms auftretenden Ausnahme, die nicht innerhalb des Unterprogramms behandelt werden kann, das Unterprogramm nicht regulär beendet wird, ohne dass diese Beendigung aufgezeichnet wird. Dadurch wird die eigentlich durch die Ablaufverfolgung bezweckte Fehleranalyse erschwert. Die Aufgabe der vorliegenden Erfindung ist es, eine verbesserte dynamisch aktivierbare Ablaufverfolgung eines auf einem Computersystem laufenden Unterprogramms zu ermöglichen.A disadvantage of this method, however, is that for the period in which the instructions to be displaced are written into the buffer memory and instead of the jump command is inserted, the functional integrity of the subroutine is not given. Since after completion of the trace program all changes made in the machine code must be reversed, ie in particular the instructions contained in the buffer memory must be written back, the functional integrity of the subroutine is not given for this period. However, such temporary damage to the functional integrity may lead to the abort of the subroutine and also of the calling program. In addition, the actual execution behavior of the subroutine can be impaired by the necessary switching back and forth of the displaced instructions in the main memory, whereby the significance of the data obtained by the trace is questioned. Another disadvantage of this method is that in the case of an exception occurring at the end of the subroutine, which is not within the scope of the invention Subroutine can not be handled, the subroutine will not shut down normally without this completion being recorded. This complicates the error analysis that is actually intended by the trace. The object of the present invention is to enable an improved dynamically activatable trace of a subroutine running on a computer system.
Diese Aufgabe wird durch den Gegenstand des Hauptanspruchs gelöst.This object is solved by the subject of the main claim.
Bevorzugte Ausgestaltungen der vorliegenden Erfindung sind Gegenstände der Unteransprüche.Preferred embodiments of the present invention are subject matters of the subclaims.
Der Erfindung geht von der Beobachtung aus, dass viele Unterprogramme Leeranweisungen, die aus einer Leerinstruktion oder einer Folge von Leerinstruktionen bestehen, beinhalten, die die eigentliche Funktion eines Unterprogramms nicht beeinflussen, aber aus anderen Gründen in das Unterprogramm eingefügt worden sind. Ein Grund für das Einfügen von Leeranweisungen liegt z. B. darin, den zeitlichen Ablauf eines Unterprogramms so zu beeinflussen, dass sichergestellt wird, dass bestimmte Zeitanforderungen an und durch das Unterprogramm, das Programm und/oder das Betriebssystem erfüllt werden. Das Einfügen von Leeranweisungen ist dabei eine gängige Maßnahme, da dadurch das Timing-Verhalten des Unterprogramms beeinflusst wird, nicht aber die von dem Unterprogramm verwalteten Register und Speicherwerte. Ein weiterer Grund für das Einfügen von Leeranweisungen liegt z. B. darin, den Maschinencode im Arbeitsspeicher so auszurichten, dass der spätere Zugriff optimiert wird. Zudem kann durch das Einfügen einer Leeranweisung das jeweilige Unterprogramm für eine spätere dynamische Aktualisierung vorzubereitet werden. So wird z. B. für Betriebssystemkomponenten, d. h. Unterprogrammen von Windows NT®, bei denen von Anfang an davon ausgegangen wird, dass sie später durch ein korrigiertes Unterprogramm, einen so genannten Patch, aktualisiert werden müssen, bereits bei der Programmierung am Anfang eines solchen Unterprogramms eine Leeranweisung eingefügt, die der Größe einer Sprunganweisung entspricht. Steht dann später ein Patch zur Verfügung, kann dieser in den Arbeitsspeicher geladen werden und der Programmkontrollfluss durch Überschreiben der Leeranweisung mit einer Sprunganweisung zu diesem Patch dynamisch umgelenkt werden (sog. „hot-patching”).The invention is based on the observation that many subroutines contain empty instructions consisting of an empty instruction or a sequence of empty instructions which do not affect the actual function of a subroutine but have been inserted into the subroutine for other reasons. One reason for inserting empty statements is z. Example, to influence the timing of a subroutine so that it is ensured that certain time requirements are met to and by the subroutine, the program and / or the operating system. The insertion of empty instructions is a common measure, as it affects the timing behavior of the subroutine, but not the registers and memory values managed by the subroutine. Another reason for inserting empty instructions is z. Example is to align the machine code in memory so that the subsequent access is optimized. In addition, by inserting an empty instruction, the respective subprogram can be prepared for later dynamic updating. So z. B. for operating system components, ie subroutines of Windows NT ® , which are assumed from the beginning that they must be updated later by a corrected subroutine, a so-called patch, already inserted in the programming at the beginning of such a subroutine an empty statement which corresponds to the size of a jump instruction. If a patch is available later, it can be loaded into the main memory and the program control flow can be dynamically redirected by overwriting the empty instruction with a jump instruction to this patch (so-called "hot-patching").
Der vorliegenden Erfindung liegt der Gedanke zugrunde, das Vorhandensein solcher Leeranweisungen im Code eines Unterprogramms zum Zwecke der Ablaufverfolgung auszunutzen. Dazu wird bei einem Unterprogramm, das sich in einem Arbeitsspeicher eines Computersystems in Maschinencode befindet und eine Leeranweisung beinhaltet, die aus einer Leerinstruktion oder einer Folge von Leerinstruktionen besteht, die Leeranweisung durch eine Sprunganweisung ersetzt, die bei Aufruf des Unterprogramms den Programmkontrollfluss zu einem Ablaufverfolgungsmodul umlenkt, das zuvor in den Arbeitsspeicher eingebracht worden ist. Das Ablaufverfolgungsmodul registriert den Eintritt in das Unterprogramm und gibt dann den Programmkontrollfluss an die Instruktion des Unterprogramms zurück, die der ersetzten Leeranweisung folgt.The present invention is based on the idea to exploit the presence of such empty statements in the code of a subroutine for the purpose of tracing. For this purpose, in a subroutine contained in a main memory of a computer system in machine code and containing an idle instruction consisting of a dummy instruction or a sequence of dummy instructions, the dummy instruction is replaced by a jump instruction which, upon invocation of the subroutine, redirects the program control flow to a trace module which has been previously placed in the main memory. The trace module registers entry to the subroutine and then returns the program control flow to the instruction of the subroutine following the replaced empty instruction.
Bevorzugterweise wird vor der Überschreibung der Leeranweisung sichergestellt, dass diese nicht Sprungziel einer in dem Unterprogramm enthaltenen Sprunganweisung ist. Dies wird im Allgemeinen nicht bei Unterprogrammen der Fall sein, die für die spätere dynamische Aktualisierung programmiert worden sind, kann aber durchaus der Fall sein, wenn die Leeranweisung aus Timing-Gründen eingefügt worden ist. Daher werden bevorzugterweise durch eine Management-Anwendung die im Arbeitsspeicher des Computersystems befindlichen Unterprogramme identifiziert, die eine Leeranweisung enthalten, die im Maschinencode eine Länge aufweist, die mindestens einer Länge des Maschinencodes einer Sprunganweisung entspricht und die nicht Ziel einer im Unterprogramm befindlichen Sprunganweisung ist. Die Management-Anwendungen kann solche Unterprogramme z. B. dadurch identifizieren, dass sie die im Arbeitsspeicher befindlichen Unterprogramme mit einer Liste von Unterprogrammen vergleicht, für die bekannt ist, dass sie eine geeignete Leeranweisung enthalten und auch an welcher Stelle sie diese enthalten. Die Management-Anwendung kann solche Unterprogramme z. B. aber auch dadurch identifizieren, indem sie deren im Arbeitsspeicher befindlichen Maschinencode analysiert. Befindet sich eine Leeranweisung mit ausreichender Länge nicht am Anfang sondern erst an späterer Stelle eines Unterprogramms, dürfen auch die vor der Leeranweisung vorkommenden Instruktionen nicht Ziel einer Sprunganweisung sein. In diesem Zusammenhang wird darauf hingewiesen, dass bei einem Unterprogramm, bei dem sich eine geeignete Leeranweisung am Anfang befindet, der Eintritt in dieses Unterprogramm exakt registriert werden kann, wohingegen dies bei einem Unterprogramm, bei dem sich eine geeignete Leeranweisung erst später im Code befindet, der Eintritt in das Unterprogramm verzögert registriert wird. Trotzdem können die dadurch gewonnen Informationen wertvolle Dienste bei der Fehleranalyse leisten.Preferably, before overwriting the dummy instruction, it is ensured that it is not a jump target of a jump instruction contained in the subroutine. This will generally not be the case with subroutines that have been programmed for the later dynamic update, but may well be the case if the dummy instruction has been inserted for timing reasons. Therefore, preferably, a management application identifies the subprograms residing in the main memory of the computer system which contain an idle instruction having a length in the machine code which corresponds to at least a length of the machine code of a jar instruction and which is not the target of a jar instruction located in the subroutine. The management applications can such subroutines z. B. by comparing the in-memory subroutines with a list of subroutines that are known to contain a suitable empty statement and also where they contain them. The management application can such subroutines z. B. but also by analyzing their memory in machine memory code. If an empty instruction of sufficient length is not at the beginning but rather at a later point in a subprogram, then the instructions occurring before the empty instruction must not be the target of a jump instruction. In this regard, it should be noted that in a subroutine having a suitable empty instruction at the beginning, entry into this subroutine can be accurately registered, whereas in a subroutine where a suitable empty instruction is later in the code, the entry into the subroutine is delayed registered. Nevertheless, the information gained thereby can provide valuable services in fault analysis.
Gemäß einer bevorzugten Ausführungsform der vorliegenden Erfindung wird der Maschinencode eines bereits im Arbeitsspeicher befindlichen Unterprogramms zur Laufzeit des zugehörigen Programms durch Ersetzen einer im Unterprogramm befindlichen Leeranweisung durch eine Sprunganweisung, die direkt oder indirekt auf ein Ablaufverfolgungsmodul verweist, das sich ebenfalls im Maschinencode im Arbeitsspeicher befindet, für eine dynamische Ablaufverfolgung durch das Ablaufverfolgungsmodul instrumentiert. Das Ablaufverfolgungsmodul registriert einen Eintritt in das Unterprogramm und manipuliert den dem Unterprogramm zugeordneten Eintrag in einem Aufrufstapel derart, dass die zugehörige Rücksprungadresse durch eine Adresse einer vom Ablaufverfolgungsmodul bereitgestellten Austrittsroutine ersetzt wird. Zudem wird ein Hilfsstapelspeicher generiert, der die vom Aufrufstapelspeicher verdrängte ursprüngliche Rücksprungadresse aufnimmt und von der Austrittsroutine nach deren Beendigung zum korrekten Rücksprung in das das Unterprogramm aufrufende Programm ermöglicht.According to a preferred embodiment of the present invention, the machine code of an already in-memory subroutine at runtime of the associated program by replacing a subroutine in the empty instruction by a jump instruction that refers directly or indirectly to a trace module, which is also in the machine code in Memory is instrumented for a dynamic trace by the trace engine. The trace module registers entry into the subroutine and manipulates the entry associated with the subroutine in a call stack such that the associated return address is replaced with an address of an exit routine provided by the trace module. In addition, an auxiliary stack is generated, which receives the displaced from the call stack memory original return address and allows the exit routine after the completion of the correct return to the program calling the subroutine.
In einer bevorzugten Ausführungsform der vorliegenden Erfindung wird durch das Ablaufverfolgungsmodul nicht nur der Eintritt in ein Unterprogramm registriert, sondern auch der Austritt aus diesem. Dazu wird die bei Aufruf des Unterprogramms in einem Aufrufstapel abgelegte Rücksprungadresse durch eine Adresse ersetzt, die ein Umlenken des Programmkontrollflusses zu einer Austrittsroutine des Ablaufverfolgungsmoduls ermöglicht. Dadurch wird nach Abarbeitung der in dem Unterprogramm befindlichen Instruktionen der Programmkontrollfluss zu der Austrittsroutine umgelenkt, die den Austritt aus dem Unterprogramm registriert und anschließend den Programmkontrollfluss an die in einem Hilfsstapel gespeicherte ursprüngliche Rücksprungadresse weiterleitet.In a preferred embodiment of the present invention, not only the entry into a subroutine is registered by the trace module, but also the exit from it. For this purpose, the return address stored in a call stack when the subprogram is called up is replaced by an address which allows the program control flow to be redirected to an exit routine of the trace module. As a result, after execution of the instructions located in the subroutine, the program control flow is diverted to the exit routine, which registers the exit from the subroutine and then forwards the program control flow to the original return address stored in an auxiliary stack.
In einer bevorzugten Ausführungsform der vorliegenden Erfindung berücksichtigt das Ablaufverfolgungsmodul auch das Auftreten von Ausnahmen sowie deren Behandlung. Dazu wird bei Aufruf eines Unterprogramms eine von dem Ablaufverfolgungsmodul bereitgestellte Ausnahmebehandlungsfunktion registriert. Registrieren bedeutet in diesem Zusammenhang, dass eine Information bezüglich der Ausnahmebehandlungsfunktion an einer bekannten Stelle abgelegt wird. Wird durch eine aufgetretene Ausnahme eine nicht-reguläre Beendigung des Unterprogramms notwendig, wird dies durch die Ausnahmebehandlungsfunktion des Ablaufverfolgungsmoduls registriert.In a preferred embodiment of the present invention, the trace module also takes into account the occurrence of exceptions and their treatment. For this purpose, when a subroutine is called, an exception handling function provided by the trace module is registered. Register means in this context that information regarding the exception handling function is stored in a known location. If a non-regular termination of the subroutine is necessary due to an exception that has occurred, this is registered by the exception handling function of the trace module.
Bevorzugterweise wird dazu eine in einem obersten Eintrag in einer Ausnahmebehandlungsregistrierungskette, die Adressen bzw. Zeiger zu im Zusammenhang mit aufgerufenen Unterprogrammen registrierten Ausnahmebehandlungsfunktionen enthält, gespeicherte Adresse durch die Adresse der von dem Ablaufverfolgungsmodul bereitgestellten Ausnahmebehandlungsfunktion ersetzt und stattdessen in einem Hilfsstapel gespeichert. Bei Auftreten einer Ausnahme wird die Ausnahmebehandlungsfunktion des Ablaufverfolgungsmoduls mittels der im Eintrag der Ausnahmebehandlungsregistrierungskette gespeicherten Adresse aufgerufen, die wiederum die ursprünglich registrierte Ausnahmebehandlungsfunktion mittels der in dem Hilfsstapel gespeicherten Adresse aufruft. Die Ausnahmebehandlungsfunktion des Ablaufverfolgungsmoduls sorgt dabei dafür, dass bei einer durch die aufgetretene Ausnahme verursachten Abwicklung des Aufrufstapels keine nicht mehr benötigten Einträge in dem Hilfsstapel bestehen bleiben.Preferably, for this purpose, a stored address in a top entry in an exception handler registration chain containing addresses or pointers to exception handling functions registered in connection with called subroutines is replaced with the address of the exception handler provided by the trace module and stored instead in an auxiliary stack. When an exception occurs, the exception handling function of the trace module is called by the address stored in the exception handler registration chain entry, which in turn calls the originally registered exception handler function using the address stored in the helper stack. The exception handling function of the trace module ensures that in the case of a handling of the call stack caused by the exception that has occurred, no entries no longer required remain in the auxiliary stack.
Bevorzugterweise veranlasst die Ausnahmebehandlungsfunktion des Ablaufverfolgungsmoduls nach ihrem Aufruf eine vorübergehende Registrierung einer weiteren Ausnahmebehandlungsfunktion, die als Aufräum- und Protokollfunktion fungiert. Wird durch die aufgetretene Ausnahme eine Abwicklung des Aufrufstapels verursacht, wird auf diese weitere Ausnahmebehandlungsfunktion zugegriffen, die die Abwicklung des Hilfsstapels vornimmt und gegebenenfalls registriert.Preferably, the exception handler function of the trace module, after being called, causes a temporary registration of another exception handler that acts as a cleanup and logger. If the occurrence of the exception causes the call stack to be processed, this additional exception handling function is accessed, which carries out the handling of the auxiliary stack and, if necessary, registers it.
Weitere Vorteile sowie bevorzugte Ausführungsformen der vorliegenden Erfindung ergeben sich im Folgenden unter Bezugnahme auf die beiliegenden Zeichnungen. Die Zeichnungen sowie die nachfolgende detaillierte Beschreibung sind nicht dazu gedacht, den Schutzbereich der in den Patentansprüchen definierten Erfindung zu begrenzen, sondern das Verständnis der Merkmale und Vorteile der Erfindung zu erleichtern.Further advantages and preferred embodiments of the present invention will become apparent hereinafter with reference to the accompanying drawings. The drawings as well as the following detailed description are not intended to limit the scope of the invention defined in the claims but to facilitate an understanding of the features and advantages of the invention.
Dabei zeigen die Zeichnungen im Einzelnen:The drawings show in detail:
Die Binärfolge des Maschinencodes
Um einem aufgerufenen Unterprogramm einen Rücksprung zu dem aufrufenden Programm zu ermöglichen, wird üblicherweise ein Aufrufstapel verwendet. Ein Aufrufstapel stellt eine dynamische Datenstruktur dar, die Information über aktive Unterprogramme eines laufenden Computerprogramms speichert. Wird ein Unterprogramm aufgerufen, wird eine geeignete Rücksprungadresse auf den Aufrufstapel gelegt. Nach Beendigung des Unterprogramms wird die Rücksprungadresse wieder von dem Aufrufstapel entfernt und für einen Rücksprung verwendet.
Segment
An dieser Stelle wird angemerkt, dass
In dem Aufrufstapelspeicher
Das Unterprogramm UPX
Das Unterprogramm UPX
Die ersten Instruktionen
Um den Programmablauf eines Unterprogramms zu verfolgen, welches bereits in einen Arbeitsspeicher eines laufenden Computersystems in Maschinencode geladen worden ist, wird eine Leeranweisung in dem Maschinencode des zu verfolgenden Unterprogramms durch eine Sprunganweisung ersetzt, die den Programmkontrollfluss bei Aufruf des Unterprogramms auf ein in den Arbeitsspeicher eingebrachtes Ablaufverfolgungsmodul umlenkt. Diese Umlenkung kann direkt erfolgen, indem das Ablaufverfolgungsmodul als Sprungziel der Sprunganweisung definiert wird, oder auch indirekt über eine weitere Anweisung, wie oben anhand der Kurzsprung/Langsprung-Kombination dargestellt. Aus Gründen einer einfachen Darstellung des Sachverhalts wird im Folgenden zumeist von einer Sprunganweisung gesprochen, die den Programmkontrollfluss umlenkt, ohne zwischen direkter und indirekter Umlenkung zu unterscheiden. Für den Fachmann ist jedoch klar, dass sowohl eine direkte als auch eine indirekte Umlenkung im Einklang mit der vorliegenden Erfindung ist.In order to track the program flow of a subroutine which has already been loaded into a working memory of a running computer system in machine code, an empty instruction in the machine code of the subroutine to be tracked is replaced by a jump instruction which, upon invocation of the subroutine, places the program control flow into a memory inserted into the main memory Trace module redirects. This redirection can be done directly by defining the trace module as the jump destination of the jump instruction, or indirectly via another instruction, as shown above with reference to the short jump / long jump combination. For the sake of a simple presentation of the facts, the following is usually referred to as a jump instruction which redirects the program control flow without distinguishing between direct and indirect diversion. However, it will be apparent to those skilled in the art that both direct and indirect deflection are in accordance with the present invention.
In
Die Eintrittsroutine ER
Zudem sorgt das Ablaufverfolgungsmodul AVM
An dieser Stelle wird allgemein angemerkt, dass sich die hier im Zusammenhang mit der vorliegenden Erfindung beschriebenen Techniken auch für eine Multithreading-Umgebung eignen. In einer solchen Umgebung ist es bevorzugt, dass nur eine einzige Leerinstruktion durch die Sprunginstruktion, die den Kontrollfluss zum Ablaufverfolgungsmodul umlenkt, verdrängt wird, um Probleme im Zusammenhang mit sogenannten „preempted threads” zu vermeiden. In diesem Fall wird bevorzugterweise die oben dargestellte Kurzsprung/Langsprung-Kombination verwendet, da die Länge einer einzigen Instruktion üblicherweise nicht ausreicht, um bis zu dem Ablaufverfolgungsmodul zu springen. In
In
Die Instruktionen
Daraufhin werden die Instruktionen
Daraufhin werden die Instruktionen
Die Instruktionen
Es wird wiederum darauf hingewiesen, dass die in die Unterprogramme UPX
Im Zusammenhang mit den
Ausnahmen zeigen Probleme an, die während der Ausführung eines Programms bzw. Unterprogramms auftreten können. Typische Ausnahmen zeigen z. B. den Versuch, durch Null zu teilen, auf eine nicht vorhandene Speicheradresse zuzugreifen oder andere Problemsituationen an, die bei der Abarbeitung des Programms bzw. Unterprogramms auftreten. Ausnahmen können durch speziell dafür vorgesehene Ausnahmebehandlungsfunktionen behandelt werden. Nach einer erfolgreichen Behandlung einer Ausnahme kann dabei die unterbrochene Programmausführung entweder an einer Stelle innerhalb des Unterprogramms aufgenommen werden, in dem die Ausnahme aufgetreten ist, oder an einer anderen stabilen Stelle im Programmcode, was zu einer kontrollierten, nicht-regulären Beendigung des Unterprogramms führt. Kann keine Ausnahmebehandlungsfunktion die aufgetretene Ausnahme behandeln, folgt zumeist ein Absturz des Programms.Exceptions indicate problems that occur during the execution of a program or Subprogram can occur. Typical exceptions show z. Example, the attempt to divide by zero, to access a non-existent memory address or other problem situations that occur during the execution of the program or subroutine. Exceptions can be handled by special exception handling functions. Upon successful handling of an exception, the interrupted program execution may be taken either at a location within the subroutine in which the exception occurred, or at some other stable location in the program code, resulting in a controlled, non-regular termination of the subroutine. If no exception handling function can handle the exception that has occurred, it is usually followed by a crash of the program.
Jedes Unterprogramm eines Programms kann eine spezielle Ausnahmebehandlungsfunktion definieren, die Anweisungen darüber enthält, wie beim Auftreten bestimmter Ausnahmen weiter zu verfahren ist. Nicht jedes Unterprogramm muss notwendigerweise eine solche Ausnahmebehandlungsfunktion aufweisen und nicht jede Ausnahmebehandlungsfunktion enthält üblicherweise Anweisungen für jede denkbare auftretende Ausnahme.Each subprogram of a program can define a special exception handler that contains instructions on how to proceed when certain exceptions occur. Not every subroutine must necessarily have such an exception handling function, and not every exception handling function usually contains instructions for every conceivable exception.
Nach Aufruf eines Unterprogramms wird, sofern vorhanden, die entsprechende Ausnahmebehandlungsfunktion des Unterprogramms registriert, d. h. deren Adresse an einem bekannten, dafür vorgesehenen Ort abgelegt. Die Registrierungen von Ausnahmebehandlungsfunktionen verschiedener Unterprogramme können an diesem Ort als Kette von Ausnahmebehandlungsregistrierungen abgelegt sein. Tritt eine Ausnahme bei der Abarbeitung dieses Unterprogramms auf, wird auf die zugehörige registrierte Ausnahmebehandlungsfunktion mittels der gespeicherten Adresse zugegriffen. Ist die Ausnahmebehandlungsfunktion jedoch nicht in der Lage die aufgetretene Ausnahme erfolgreich zu behandeln, wird überprüft, ob eine andere zuvor von einem anderen Unterprogramm registrierte Ausnahmebehandlungsfunktion diese Ausnahme behandeln kann.When a subroutine is called, the corresponding exception handling function of the subroutine is registered, if any, d. H. their address stored in a known, designated place. The registrations of exception handling functions of various subroutines may be stored at this location as a chain of exception handling registrations. If an exception occurs during the execution of this subroutine, the associated registered exception handling function is accessed by means of the stored address. However, if the exception handler fails to successfully handle the exception that has occurred, it checks to see if another exception handler previously registered by another subprogram can handle this exception.
Grundsätzlich kann nach einer erfolgreichen Ausnahmebehandlung entweder die Ausführung des Programms innerhalb des Unterprogramms, in dem die Ausnahme aufgetreten ist fortgesetzt werden, oder an einer anderen durch die erfolgreiche Ausnahmebehandlungsfunktion bestimmten Stelle. In letzterem Fall wird zumeist der Aufrufstapel bis zu dem Eintrag abgewickelt, der dem Unterprogramm entspricht, der die erfolgreiche Ausnahmebehandlungsfunktion registriert hat. Diese Form der Ausnahmebehandlung über eine Kette von registrierten Ausnahmebehandlungsfunktionen wird auch als strukturierte Ausnahmebehandlung bezeichnet.In principle, after a successful exception handling, either the execution of the program can be continued within the subprogram in which the exception occurred, or at another location determined by the successful exception handling function. In the latter case, the call stack is usually handled up to the entry corresponding to the subroutine that registered the successful exception handling function. This form of exception handling via a chain of registered exception handling functions is also referred to as structured exception handling.
Bei der dynamisch aktivierten Ablaufverfolgung von Unterprogrammen könnte eine derartige strukturierte Ausnahmebehandlung bei Abwicklung einer oder mehrerer Einträge bzw. Aufrufrahmen des Aufrufstapels von ablaufverfolgten Unterprogrammen dazu führen, dass die Kohärenz zwischen Aufrufstapel und Hilfsstapel nicht mehr gegeben ist, da Einträge bzw. Hilfsrahmen zu Unterprogrammen im Hilfsstapelspeicher stehen bleiben könnten, die nach Abwicklung des Aufrufstapels nicht mehr aktiv sind. Die folgende mit Bezug auf
Dazu stellt das Ablaufverfolgungsmodul gemäß einer bevorzugten Ausführungsform der vorliegenden Erfindung eine eigenen Ausnahmebehandlungsfunktion bereit, die jeweils vor Eintritt eines zu verfolgenden Unterprogramms registriert sowie nach regulärer Beendigung desselben deregistriert wird. Um eine Registrierung mit Hilfe eines eigenen Aufrufrahmens für das Ablaufverfolgungsmodul im Aufrufstapel und damit deren negative Konsequenz für Zugriffe auf durch Aufrufstapelzeiger-relative Offsets adressierte Parameter durch das zu verfolgende Unterprogramm zu vermeiden, wird eine bereits bestehende Registrierung einer Ausnahmebehandlungsfunktion angepasst. Diese bestehende Registrierung entspricht dabei der Ausnahmebehandlungsfunktion, auf die im Fall einer nicht innerhalb des verfolgten Unterprogramms bzw. durch deren Ausnahmebehandlungsfunktion behandelbaren Ausnahme als Nächstes zugegriffen würde. Wird eine Ausnahmebehandlungsregistrierungskette verwendet, entspricht diese bestehende Registrierung dementsprechend dem obersten Glied bzw. Eintrag in der Ausnahmebehandlungsregistrierungskette. Die Anpassung besteht darin, die Adresse der Ausnahmebehandlungsfunktion dieser bestehenden Registrierung durch die Adresse der von dem Ablaufverfolgungsmodul bereitgestellten Ausnahmebehandlungsfunktion zu ersetzen. Die Adresse der ursprünglichen Ausnahmebehandlungsfunktion wird in einem dem zu verfolgenden Unterprogramm zugeordneten Eintrag bzw. Hilfsrahmen in einem Hilfsstapelspeicher abgelegt, zusammen mit der Adresse der veränderten Registrierung.For this purpose, according to a preferred embodiment of the present invention, the trace module provides its own exception handling function, which is registered in each case before entry of a subroutine to be tracked and deregistered after regular termination thereof. In order to avoid registration by means of its own call frame for the trace module in the call stack, and thus its negative consequence for accesses to parameters addressed by call stack pointer relative offsets by the subroutine to be followed, an existing registration of an exception handling function is adapted. This existing registration corresponds to the exception handling function that would be accessed next in the event of an exception that is not within the tracked subroutine or exception handling function. Accordingly, if an exception handling registration chain is used, this existing registration corresponds to the topmost member or entry in the exception handling registration chain. The adaptation consists of replacing the address of the exception handling function of this existing registration with the address of the exception handling function provided by the trace module. The address of the original exception handling function is stored in an auxiliary stack in an entry or subframe associated with the subroutine to be followed, along with the address of the changed registry.
Tritt allerdings in Schritt
Bei diesem Vorgehen wird eine Adresse bzw. ein Zeiger zu dem Eintrag in der Ausnahmebehandlungsregistrierungskette, der die Ausnahmebehandlungsfunktion eines Unterprogramms registriert und somit deren Adresse enthält, in dem Aufrufrahmen dieses Unterprogramms gespeichert. Für das Ablaufverfolgungsmodul wird jedoch bevorzugterweise kein eigener Aufrufrahmen erstellt, damit das Verhalten des zu verfolgenden Unterprogramms sowie die Laufzeitumgebung des Programms so wenig wie möglich durch die dynamisch aktivierte Ablaufverfolgung beeinflusst werden. Zudem sollen bevorzugterweise Probleme bei Zugriffen auf durch Aufrufstapelzeiger-relative Offsets adressierte Parameter vermieden werden. Deshalb wird in einer bevorzugten Ausführungsform der vorliegenden Erfindung die Ausnahmebehandlungsfunktion EXC_AVM des Ablaufverfolgungsmoduls AVM dadurch registriert, dass die Adresse in einem bereits bestehenden obersten Eintrag in der Ausnahmebehandlungsregistrierungskette durch die Adresse von EXC_AVM ersetzt wird. Die Adresse der ursprünglich im obersten Eintrag registrierten Ausnahmebehandlungsfunktion wird stattdessen in einem Hilfsrahmen abgelegt. In this procedure, an address or pointer to the entry in the exception handling registration chain which registers the exception handling function of a subroutine and thus contains its address is stored in the call frame of this subroutine. However, the trace module preferably does not create its own call frame, so that the behavior of the subroutine to be tracked and the runtime environment of the program are as little affected by the dynamically activated trace as possible. In addition, it is preferable to avoid problems in accessing parameters addressed by call stack pointer relative offsets. Therefore, in a preferred embodiment of the present invention, the exception handling function EXC_AVM of the trace module AVM is registered by replacing the address in an already existing top entry in the exception handling registration chain with the address of EXC_AVM. The address of the exception handling function originally registered in the top entry is instead stored in a subframe.
In der in
Ist die Adresse der Ausnahmebehandlungsfunktion EXC_AVM noch nicht im obersten Eintrag der Ausnahmebehandlungsregistrierungskette eingetragen, wird in Schritt
Wird in Schritt
Eine Ausnahmebehandlungsfunktion hat allgemein folgende Möglichkeiten, mit einer aufgetretenen Ausnahme umzugehen: (a) Erfolgreiche Behandlung der Ausnahme und Rückkehr zu dem Unterprogramm, bei dem die Ausnahme aufgetreten ist; (b) Erfolgreiche Behandlung der Ausnahme mit Abwicklung zumindest des Aufrufrahmens des Unterprogramms, bei dem die Ausnahme aufgetreten ist; und (c) keine Behandlung der Ausnahme. Im Rahmen der hier vorgestellten Ablaufverfolgung ist vor allem interessant, wie sich die Fälle (a) bis (c) auf die Kohärenz zwischen Aufrufstapel und Hilfsstapel auswirken.An exception handling function generally has the following capabilities to deal with an exception that has occurred: (a) successfully handle the exception and return to the subroutine in which the exception occurred; (b) successful handling of the exception, with at least the call-frame of the sub-program in which the exception occurred; and (c) no treatment of the exception. Of particular interest in the context of the trace presented here is how cases (a) to (c) affect the coherence between the call stack and the auxiliary stack.
Der Fall (a) hat keine Auswirkungen auf den Aufrufstapel und den Hilfsstapel, d. h. die Kohärenz zwischen beiden ist gewährleistet. Im Fall (c) wird anhand der Ausnahmebehandlungsregistrierungskette weiter nach einer geeigneten Ausnahmebehandlungsfunktion gesucht, d. h. die Kohärenz zwischen Aufrufstapel und Hilfsstapel ist zu diesem Zeitpunkt ebenfalls nicht gefährdet. Wird später eine geeignete Ausnahmebehandlungsfunktion gefunden, die eine Abwicklung des Aufrufstapels veranlasst, wird die in der Ausnahmebehandlungsregistrierungskette registrierte Ausnahmebehandlungsfunktion EXC_AVM automatisch erneut aufgerufen und kann dadurch eine entsprechende Abwicklung des Hilfsstapels vornehmen, so dass die Kohärenz zwischen Aufrufstapel und Hilfsstapel ebenfalls erhalten bleibt.Case (a) has no effect on the call stack and the auxiliary stack; H. the coherence between the two is guaranteed. In case (c), the exception handler registration chain continues to search for an appropriate exception handling function, i. H. The coherence between the call stack and the auxiliary stack is also not endangered at this time. If a suitable exception handling function is subsequently found which causes the call stack to be processed, the exception handling function EXC_AVM registered in the exception handling registration chain is automatically called again and can thus carry out a corresponding handling of the auxiliary stack, so that the coherency between call stack and auxiliary stack is also preserved.
Anders verhält es sich im Fall (b), wenn eine ursprüngliche Ausnahmebehandlungsfunktion indirekt über die in der Ausnahmebehandlungsregistrierungskette registrierte Ausnahmebehandlungsfunktion EXC_AVM aufgerufen wird. Veranlasst diese ursprüngliche Ausnahmebehandlungsfunktion eine Abwicklung des Aufrufstapels, wird die in der Ausnahmebehandlungsregistrierungskette registrierte Ausnahmebehandlungsfunktion EXC_AVM nicht nochmals aufgerufen, da die ursprüngliche Ausnahmebehandlungsfunktion davon ausgeht, dass sie selbst in dem entsprechenden Eintrag in der Ausnahmebehandlungsregistrierungskette registriert ist und keine Kenntnis von der Registrierung der Ausnahmebehandlungsfunktion EXC_AVM in diesem Eintrag hat. Daher würde im Fall (b) der Aufrufstapel abgewickelt und die Ausführung des Programms an einer von der ursprünglichen Ausnahmebehandlungsfunktion vorgesehenen Stelle wieder aufgenommen, ohne dass der Hilfsstapel entsprechend abgewickelt wurde. Um dies zu verhindern, sieht eine bevorzugte Ausführungsform der vorliegenden Erfindung vor, eine weitere von dem Ablaufverfolgungsmodul AVM zur Verfügung gestellte Ausnahmebehandlungsfunktion EXC_AVM2 in der Ausnahmebehandlungsregistrierungskette durch das Ablaufverfolgungsmodul AVM zu registrieren, bevor die ursprüngliche Ausnahmebehandlungsfunktion aufgerufen wird. Dies hat zur Folge, dass bei einer durch die ursprünglichen Ausnahmebehandlungsfunktion veranlassten Abwicklung die Ausnahmebehandlungsfunktion EXC_AVM2 aufgerufen wird, die eine entsprechende Abwicklung des Hilfsstapels bewirkt. The situation is different in case (b) when an original exception handler function is invoked indirectly via the exception handling function EXC_AVM registered in the exception handling enrollment chain. If this original exception handling function causes the call stack to be handled, the EXC_AVM exception handling function registered in the exception handler registration chain is not called again because the original exception handler assumes that it is itself registered in the corresponding entry in the exception handling enrollment chain and is not aware of the registration of the EXC_AVM exception handling function this entry has. Therefore, in case (b), the call stack would be handled and the execution of the program resumed at a location provided by the original exception handling function without the auxiliary stack being appropriately handled. To prevent this, a preferred embodiment of the present invention provides for registering another exception handling function EXC_AVM2 provided by the trace module AVM in the exception handling registration chain by the trace module AVM before calling the original exception handling function. As a result, in a transaction initiated by the original exception handling function, the exception handling function EXC_AVM2 is called, which effects a corresponding execution of the auxiliary stack.
Schritt
Ist die Ausnahmebehandlungsfunktion EXC_UPV in der Lage, die aufgetretene Ausnahme so zu behandeln, dass eine Rückkehr zum Unterprogramm UPX möglich ist, behandelt die Ausnahmebehandlungsfunktion EXC_UPV die Ausnahme dementsprechend in Schritt
Ist die Ausnahmebehandlungsfunktion EXC_UPV in der Lage, die aufgetretene Ausnahme so zu behandeln, dass eine Abwicklung des Aufrufstapels erforderlich wird, wird in Schritt
Ist die Ausnahmebehandlungsfunktion EXC_UPV nicht in der Lage, die aufgetretene Ausnahme erfolgreich zu behandeln, wird zur Ausnahmebehandlungsfunktion EXC_AVM zurückgekehrt, die die Deregistrierung der Ausnahmebehandlungsfunktion EXC_AVM2 veranlasst und die Kontrolle an das System zurückgibt. Es wird dann die nächste Ausnahmebehandlungsfunktion entsprechend dem nächsten Eintrag in der Ausnahmebehandlungsregistrierungskette aufgerufen und überprüft, ob diese den aufgetretenen Fehler behandeln kann.If the EXC_UPV exception handling function fails to handle the exception that has occurred successfully, it returns to the EXC_AVM exception handling function, which causes deregistration of the EXC_AVM2 exception handler function and returns control to the system. It then calls the next exception handler according to the next entry in the exception handling registration chain and checks if it can handle the error that has occurred.
Den Ausnahmebehandlungsfunktionen kann dabei durch Setzen eines Abwicklungsflags AW mitgeteilt werden, dass es sich nicht mehr um die Phase des Suchens nach einer geeigneten Ausnahmebehandlungsfunktion handelt, sondern eine Abwicklung der jeweiligen Aufrufrahmen und Hilfsrahmen stattfinden soll.The exception handling functions can be informed by setting a handling flag AW that it is no longer the phase of searching for a suitable exception handling function but a handling the respective call frame and subframe.
Bevorzugterweise umfasst das Ablaufverfolgungsmodul
Die vorliegende Erfindung kann sowohl im Nutzermodus als auch im Betriebssystemkernmodus implementiert werden. In
Um das Arbeiten mit Funktionsnamen (anstatt Adressen) zu ermöglichen, kann die Managementanwendung
Soll eine wie oben beschriebene dynamisch aktivierte Ablaufverfolgung beendet werden, müssen alle mit Hilfe des Ablaufverfolgungsmoduls AVM durchgeführten Änderungen rückgängig gemacht werden. Soll darüber hinaus das Ablaufverfolgungsmodul AVM als Ganzes sicher entfernt werden, muss sichergestellt werden, dass alle ablaufverfolgten Unterprogramme beendet wurden und kein Sprung mehr zu dem Ablaufverfolgungsmodul AVM aussteht. Dazu kann es notwendig sein, sämtliche erstellten Hilfsstapelspeicher zu untersuchen. Eine sichere Entfernung des Ablaufverfolgungsmoduls AVM ist erst dann möglich, wenn alle Speicher leer sind, d. h. keine Einträge mehr beinhalten und somit keine Sprünge zum Ablaufverfolgungsmodul AVM mehr ausstehen.If a dynamically activated trace as described above is to be ended, all changes made with the aid of the trace module AVM must be reversed. In addition, if the trace module AVM as a whole is to be safely removed, it must be ensured that all run-track subroutines have been terminated and no longer jump to the trace module AVM pending. For this it may be necessary to examine all created auxiliary stacks. A safe removal of the trace module AVM is only possible when all memory is empty, ie no longer contain entries and thus no more jumps to the trace module AVM longer.
Die vorliegende Erfindung ermöglicht eine dynamische Aktivierung einer Ablaufverfolgung von Unterprogrammen, die sich bereits im Hauptspeicher eines Computersystems befinden. Bevorzugte Ausführungsformen der vorliegenden Erfindung ermöglichen die Registrierung des Eintritts in ein Unterprogramm, des Austritts aus diesem Unterprogramm sowie der Abwicklung eines dem Unterprogramm zugeordneten Aufrufrahmens im Falle einer nicht-regulären Beendigung des Unterprogramms aufgrund des Auftretens einer nicht behandelbaren Ausnahme.The present invention enables dynamic activation of a trace of subroutines already residing in the main memory of a computer system. Preferred embodiments of the present invention allow the registration of the entry into a subroutine, the exit from this subroutine as well as the handling of a call frame associated with the subroutine in the event of a non-regular termination of the subroutine due to the occurrence of an unhandleable exception.
Ein derartige erfindungsgemäße dynamisch aktivierbare Ablaufverfolgung bietet zahlreiche Vorteile. Im folgenden sind nur einige Anwendungsbeispiele genannt:
- (a) Auf einem Multi-User-System (bspw. Microsoft Windows Terminal Server) dauert der Aufruf von Webseiten ungewöhnlich lange: Es verstreichen mehrere Sekunden, bevor der Aufbau der jeweiligen Webseite im Browser beginnt. Da mehrere Benutzer auf dem System arbeiten, sollte die Analyse des Fehlers keine Unterbrechung des Betriebs (etwa durch Systemneustart) erfordern. Die Analyse eines derartigen Fehlverhaltens könnte wie folgt ablaufen: Zunächst wird mithilfe einer erfindungsgemäßen dynamisch aktivierbaren Ablaufverfolgung der Browser so instrumentiert, dass alle Systemaufrufe (inklusive deren Ausführungszeiten) protokolliert werden. Die Analyse des Protokolls ergibt, dass ein bestimmter Systemaufruf überdurchschnittlich lange dauert – wobei es sich um einen IOCTL (NtDeviceloControlFile) handelt. Die Betrachtung des Aufrufstapels, welcher zu diesem Aufruf führte, ergibt, dass der IOCTL von der DNS-Bibliothek initiiert wurde. Ausgehend von dieser Information werden nun die DNS-Einstellungen und die Verfügbarkeit der DNS-Servers geprüft, was zu der Erkenntnis führt, das der sekundäre DNS-Server zwar erreichbar ist, ein Verbindungsversuch zum primären DNS-Server jedoch stets zu einem Timeout führt. Ein Tausch von primärem und sekundärem DNS-Server behebt das ursprüngliche Problem.
- (b) Ein System wurde von einer neuartigen Schadware befallen, deren Funktionsweise noch unbekannt ist. Um ein entsprechendes Erkennungs- oder Beseitigungs-Werkzeug erstellen zu können, gilt es daher zunächst, das Verhalten der Schadware zu analysieren. Hierzu kann ein Vergleich zwischen einem unbefallenem und einem befallenem System vorgenommen werden: Zwei identische Computersysteme, wovon eines der Systeme mit der Schadware infiziert worden ist, werden mithilfe einer erfindungsgemäßen dynamisch aktivierbaren Ablaufverfolgung derart instrumentiert, dass die Abläufe im System detailliert protokolliert werden. Nachdem auf beiden Systemen die gleichen Aktionen durchgeführt worden sind, kann durch Vergleich der Protokolle ermittelt werden, wie und in welchem Ausmaß die Schadware das Verhalten beeinflusst hat.
- (c) Um automatisch Schadware erkennen zu können, muss eine Sicherheitssoftware bestimmte Vorgänge im Betriebssystem auf verdächtige Aktionen hin überwachen: Werden bspw. kritische Systemeinstellungen geändert, so kann die Sicherheitssoftware zunächst überprüfen, ob es sich bei dem durchführenden Programm um Schadware oder unverdächtige Software handelt. Mithilfe einer erfindungsgemäßen dynamisch aktivierbaren Ablaufverfolgung kann eine Sicherheitssoftware beispielsweise den Aufruf bestimmter Funktionen in Bibliotheken oder im Betriebssystemkern überwachen und ggf. protokollieren, um eine solche Überprüfung durchzuführen. Sobald ein Verdacht vorliegt, dass es sich bei einem Programm um Schadware handelt, kann der Benutzer gewarnt werden oder es können konkrete Aktionen – beispielsweise das Terminieren des verdächtigten Programms – veranlasst werden.
- (d) Ein Entwickler eines Programms, etwa einer Anwendung oder eines Gerätetreibers, möchte den Code auf Ressourcen-Lecks (z. B. Speicher und Handles) überprüfen. Statt der manuellen Instrumentierung des Codes kann hierzu eine erfindungsgemäße dynamisch aktivierbare Ablaufverfolgung eingesetzt werden, um alle Aufrufe von Ressourcen-Akquisitions- sowie Freigabe-Funktionen zu protokollieren. Nach erfolgter Ausführung der zu untersuchenden Anwendung kann somit auf Basis des Protokolls ermittelt werden, welche Ressourcen akquiriert, jedoch nicht freigegeben wurden, also ein Leck darstellen. Statt den gesamten Code auf Lecks zu untersuchen, kann der Entwickler ausgehend von diesem Ergebnis die Analyse so auf jene Code-Stellen beschränken, welche sich mit den betroffenen Ressourcen befassen.
- (e) Um ein Verständnis für ein System oder eine bestimmte Funktion eines Systems aufzubauen, kann eine visuelle Darstellung des Verhaltens – etwa in Form von UML Sequenz-Diagrammen oder Aufruf-Graphen – dienlich sein. Eine erfindungsgemäße dynamisch aktivierbare Ablaufverfolgung kann genutzt werden, um die zu einer derartigen Visualisierung benötigten Daten zu gewinnen. Typischerweise möchte man zu einem Zeitpunkt nur bestimmte Aspekte eines Systems untersuchen, nicht das Gesamtsystem. Eine erfindungsgemäße Ablaufverfolgung ermöglicht genau diesen Sachverhalt durch die Fähigkeit zur Laufzeit die Ablaufverfolgung für ausgewählte Bereiche des Systems an- bzw. abzuschalten. Als Beispiel sei ein Web-Browser als System gegeben, von dem man wissen möchte, welche Funktionen daran beteiligt sind, eine Web-Seite zu laden und anzuzeigen. Um das herauszufinden, wird die Ablaufverfolgung für alle Funktionen des Browsers aktiviert, eine Web-Seite geladen und die Ablaufverfolgung wieder deaktiviert. Die aufgezeichneten Daten beschreiben nun den Kontrollfluss durch das System, der notwendig war, um die Web-Seite zu laden und anzuzeigen. Im Weiteren kann die Ablaufverfolgung nun so eingegrenzt werden, dass nur diejenigen Funktionen instrumentiert werden, die beispielsweise für die Netzwerkkommunikation notwendig sind.
- (a) On a multi-user system (for example, Microsoft Windows Terminal Server), it takes an unusually long time to access web pages: several seconds elapse before the web page starts to build in the browser. Because multiple users are working on the system, the analysis of the error should not require any interruption of operation (such as system reboot). The analysis of such a misconduct could proceed as follows: First, the browser is instrumented using a dynamically activatable trace according to the invention so that all system calls (including their execution times) are logged. The analysis of the log shows that a particular system call takes a longer than average time - which is an IOCTL (NtDeviceloControlFile). Considering the call stack that resulted in this call indicates that the IOCTL was initiated by the DNS library. Based on this information, the DNS settings and the availability of the DNS servers are now checked, which leads to the realization that the secondary DNS server is reachable, but a connection attempt to the primary DNS server always results in a timeout. An exchange of primary and secondary DNS server fixes the original problem.
- (b) A system has been attacked by a novel malware whose operation is still unknown. In order to be able to create a corresponding detection or removal tool, it is therefore necessary first to analyze the behavior of the damaged product. For this purpose, a comparison can be made between an untrained and an infested system: Two identical computer systems, of which one of the systems has been infected with the damaged goods, are instrumented by means of a dynamically activatable trace according to the invention in such a way that the processes in the system are logged in detail. After the same actions have been taken on both systems, it can be determined by comparing the logs how and to what extent the malware affected the behavior.
- (c) To automatically detect malware, security software must monitor certain operations in the operating system for suspicious actions: For example, if critical system settings are changed, the security software can first verify that the executing program is malware or unsuspected software , By means of a dynamically activatable trace according to the invention, a security software can monitor, for example, the call of certain functions in libraries or in the operating system kernel and, if necessary, log to carry out such a check. Once suspected that a program is malware, the user can be warned or specific actions can be taken, such as scheduling the suspected program.
- (d) A developer of a program, such as an application or device driver, wants to check the code for resource leaks (eg, memory and handles). Instead of the manual instrumentation of the code, a dynamically activatable trace according to the invention can be used for this purpose in order to log all calls of resource acquisition and release functions. After the execution of the application to be examined can thus be determined on the basis of the protocol, which resources were acquired, but were not released, so represent a leak. Instead of examining the entire code for leaks, based on this result, the developer can limit the analysis to those code locations that deal with the resources involved.
- (e) To build an understanding of a system or a particular function of a system, a visual representation of the behavior, such as UML sequence diagrams or invocation graphs, may be useful. A dynamically activatable trace according to the invention can be used to obtain the data required for such a visualization. Typically, one would like to examine only certain aspects of a system at a time, not the entire system. A tracing according to the invention enables precisely this state of affairs through the ability to Run time to turn tracing on or off for selected areas of the system. As an example, consider a web browser as a system that you want to know about which functions are involved in loading and displaying a web page. To find out, the trace is enabled for all features of the browser, a web page is loaded and the trace is disabled again. The recorded data now describes the control flow through the system that was necessary to load and display the web page. Furthermore, the trace can now be limited so that only those functions are instrumented that are necessary, for example, for network communication.
Die vorliegende Erfindung wurde mit Bezug auf mit ihr übereinstimmende bevorzugte technische Ausführungsformen beschrieben. Es ist für den einschlägigen Fachmann offensichtlich, dass verschiedene Modifikationen, Variationen und Verbesserungen der vorliegenden Erfindung angesichts der obigen Lehre innerhalb des Bereichs der angefügten Ansprüche durchgeführt werden können, ohne von dem Grundgedanken und dem angestrebten Schutzbereich der Erfindung abzuweichen. Dementsprechend wird festgestellt, dass die Erfindung nicht durch spezielle anschauliche Ausführungsformen beschränkt ist, sondern lediglich durch den Schutzbereich der Patentansprüche.The present invention has been described with reference to preferred technical embodiments consistent therewith. It will be apparent to those skilled in the art that various modifications, variations and improvements of the present invention may be made in light of the above teachings within the scope of the appended claims without departing from the spirit and intended scope of the invention. Accordingly, it is to be understood that the invention is not limited by any particular illustrative embodiments, but only by the scope of the claims.
ZITATE ENTHALTEN IN DER BESCHREIBUNG QUOTES INCLUDE IN THE DESCRIPTION
Diese Liste der vom Anmelder aufgeführten Dokumente wurde automatisiert erzeugt und ist ausschließlich zur besseren Information des Lesers aufgenommen. Die Liste ist nicht Bestandteil der deutschen Patent- bzw. Gebrauchsmusteranmeldung. Das DPMA übernimmt keinerlei Haftung für etwaige Fehler oder Auslassungen.This list of the documents listed by the applicant has been generated automatically and is included solely for the better information of the reader. The list is not part of the German patent or utility model application. The DPMA assumes no liability for any errors or omissions.
Zitierte PatentliteraturCited patent literature
- US 7047521 B2 [0006] US 7047521 B2 [0006]
Claims (18)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| DE102009038177.5A DE102009038177B4 (en) | 2009-08-20 | 2009-08-20 | Tracing in a running computer system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| DE102009038177.5A DE102009038177B4 (en) | 2009-08-20 | 2009-08-20 | Tracing in a running computer system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| DE102009038177A1 true DE102009038177A1 (en) | 2011-03-24 |
| DE102009038177B4 DE102009038177B4 (en) | 2019-05-23 |
Family
ID=43603193
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| DE102009038177.5A Active DE102009038177B4 (en) | 2009-08-20 | 2009-08-20 | Tracing in a running computer system |
Country Status (1)
| Country | Link |
|---|---|
| DE (1) | DE102009038177B4 (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112433945A (en) * | 2020-11-26 | 2021-03-02 | 百富计算机技术(深圳)有限公司 | Method and device for dynamically tracking program and electronic equipment |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7047521B2 (en) | 2001-06-07 | 2006-05-16 | Lynoxworks, Inc. | Dynamic instrumentation event trace system and methods |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5628016A (en) * | 1994-06-15 | 1997-05-06 | Borland International, Inc. | Systems and methods and implementing exception handling using exception registration records stored in stack memory |
| US7512935B1 (en) * | 2001-02-28 | 2009-03-31 | Computer Associates Think, Inc. | Adding functionality to existing code at exits |
| US6966057B2 (en) * | 2001-03-30 | 2005-11-15 | Intel Corporation | Static compilation of instrumentation code for debugging support |
| US7389494B1 (en) | 2003-11-14 | 2008-06-17 | Sun Microsystems, Inc. | Mechanism for statically defined trace points with minimal disabled probe effect |
| US7519944B2 (en) * | 2004-11-05 | 2009-04-14 | International Business Machines Corporation | Computer method and system for executing post-processing logic depending on function exit type |
| US20070006167A1 (en) * | 2005-05-31 | 2007-01-04 | Chi-Keung Luk | Optimizing binary-level instrumentation via instruction scheduling |
-
2009
- 2009-08-20 DE DE102009038177.5A patent/DE102009038177B4/en active Active
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7047521B2 (en) | 2001-06-07 | 2006-05-16 | Lynoxworks, Inc. | Dynamic instrumentation event trace system and methods |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112433945A (en) * | 2020-11-26 | 2021-03-02 | 百富计算机技术(深圳)有限公司 | Method and device for dynamically tracking program and electronic equipment |
Also Published As
| Publication number | Publication date |
|---|---|
| DE102009038177B4 (en) | 2019-05-23 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| DE69510572T2 (en) | Method and device for run-time error checking using dynamic program modification | |
| DE60010420T2 (en) | Automatic regression testing of workstation software | |
| DE69232761T2 (en) | METHOD AND DEVICE FOR CHANGING DYNAMIC ASSIGNABLE OBJECT CODE FILES | |
| DE69533005T2 (en) | Byte code program interpreter, method and arrangement with pretest of data type restrictions | |
| DE69813160T2 (en) | Object heap analysis method to demonstrate memory leaks and other runtime information | |
| DE60130840T2 (en) | Apparatus and method for cataloging symbolic data for use in performance analysis of computer programs | |
| DE69932371T2 (en) | Movable instrumentation tags for testing and troubleshooting a computer program | |
| DE69600995T2 (en) | TROUBLESHOOTING IN SPECULATIVE COMMANDS | |
| DE69909945T2 (en) | Method and arrangement for correlating profile data dynamically generated by an optimized executable program with source code instructions | |
| DE69604347T2 (en) | Determination of the dynamic properties of programs | |
| DE69814174T2 (en) | JAVA RUNTIME SYSTEM WITH CHANGED CONSTANT COLLECTION | |
| EP0674784B1 (en) | Process for testing at least one class of an object-oriented program on a computer | |
| DE60021066T2 (en) | Checking a software package | |
| DE69618221T2 (en) | MECHANISM FOR MAINTENANCE OF OBJECT-ORIENTED "METHODS" THAT DOES NOT REQUIRE AN INTERRUPTION OF THE COMPUTER SYSTEM | |
| EP3872661A1 (en) | Analysis of a container instance of an operating system | |
| DE69128908T2 (en) | Method for executing mandatory commands in a computer | |
| DE69807021T2 (en) | Method and device for implementing multiple return points | |
| US6735774B1 (en) | Method and apparatus for system call management | |
| EP1010070B1 (en) | Method for converting an object code into a programme code | |
| DE102009038177B4 (en) | Tracing in a running computer system | |
| DE10393511T5 (en) | Program development support device, program execution device, compilation method, and diagnostic method | |
| DE102018127317B3 (en) | METHOD AND DEVICES FOR COMPUTER-IMPLEMENTED GENERATION OF AN EXECUTABLE PROGRAM CODE AND FOR EXECUTING AN EXECUTABLE PROGRAM CODE | |
| DE102023201815A1 (en) | Method for testing a computer program | |
| DE69032835T2 (en) | Procedure state descriptor system for digital data processors | |
| EP3759594A1 (en) | Method for executing a computer program in a computer network, in particular in order to control a microscope |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| OP8 | Request for examination as to paragraph 44 patent law | ||
| R016 | Response to examination communication | ||
| R016 | Response to examination communication | ||
| R016 | Response to examination communication | ||
| R016 | Response to examination communication | ||
| R016 | Response to examination communication | ||
| R018 | Grant decision by examination section/examining division | ||
| R020 | Patent grant now final |