Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
gc_fragments.cpp File Reference
#include "gc_fragments.h"
#include "sym_file.h"
#include "gc.h"
#include "MetroNubUtils.h"
#include <string.h>

Go to the source code of this file.

Classes

struct  CodeLocation
struct  CodeLocationCache
struct  CodeFragment

Functions

static CodeFragment ** find_fragment (char *codeAddr)
void GC_register_fragment (char *dataStart, char *dataEnd, char *codeStart, char *codeEnd, const FSSpec *fragmentSpec)
void GC_unregister_fragment (char *dataStart, char *dataEnd, char *codeStart, char *codeEnd)
int GC_address_to_source (char *codeAddr, char symbolName[256], char fileName[256], UInt32 *fileOffset)

Variables

static const kCodeLocationCacheSize = 256
static CodeFragmenttheFragments = NULL

Function Documentation

static CodeFragment** find_fragment ( char *  codeAddr) [static]

Definition at line 143 of file gc_fragments.cpp.

{
       CodeFragment** link = &theFragments;
       CodeFragment* fragment = *link;
       while (fragment != NULL) {
              if (codeAddr >= fragment->mCodeStart && codeAddr < fragment->mCodeEnd)
                     return link;
              link = &fragment->mNext;
              fragment = *link;
       }
       return NULL;
}

Here is the caller graph for this function:

int GC_address_to_source ( char *  codeAddr,
char  symbolName[256],
char  fileName[256],
UInt32 fileOffset 
)

Definition at line 190 of file gc_fragments.cpp.

{
       CodeFragment** link = find_fragment(codeAddr);
       if (link != NULL) {
              CodeFragment* fragment = *link;
              // always move this fragment to the head of the list, to speed up searches.
              if (theFragments != fragment) {
                     *link = fragment->mNext;
                     fragment->mNext = theFragments;
                     theFragments = fragment;
              }
              // see if this is a cached location.
              CodeLocation* location = fragment->mLocations.findLocation(codeAddr);
              if (location != NULL) {
                     ::strcpy(symbolName, location->mSymbolName);
                     ::strcpy(fileName, location->mFileName);
                     *fileOffset = location->mFileOffset;
                     return 1;
              }
              sym_file* symbols = fragment->mSymbols;
              if (symbols != NULL) {
                     if (get_source(symbols, UInt32(codeAddr - fragment->mCodeStart), symbolName, fileName, fileOffset)) {
                            // save this location in the per-fragment cache.
                            fragment->mLocations.saveLocation(codeAddr, symbolName, fileName, *fileOffset);
                            return 1;
                     }
              }
       }
       return 0;
}

Here is the call graph for this function:

void GC_register_fragment ( char *  dataStart,
char *  dataEnd,
char *  codeStart,
char *  codeEnd,
const FSSpec fragmentSpec 
)

Definition at line 156 of file gc_fragments.cpp.

{
       // register the roots.
       GC_add_roots(dataStart, dataEnd);

       // create an entry for this fragment.
       CodeFragment* fragment = new CodeFragment(dataStart, dataEnd,
                                                 codeStart, codeEnd,
                                                 fragmentSpec);
       if (fragment != NULL) {
              fragment->mNext = theFragments;
              theFragments = fragment;
       }
}

Here is the call graph for this function:

void GC_unregister_fragment ( char *  dataStart,
char *  dataEnd,
char *  codeStart,
char *  codeEnd 
)

Definition at line 173 of file gc_fragments.cpp.

{
       // try not to crash when running under the MW debugger.
       if (!AmIBeingMWDebugged()) {
              CodeFragment** link = find_fragment(codeStart);
              if (link != NULL) {
                     CodeFragment* fragment = *link;
                     *link = fragment->mNext;
                     delete fragment;
              }
       }

       // remove the roots.
       GC_remove_roots(dataStart, dataEnd);
}

Here is the call graph for this function:


Variable Documentation

const kCodeLocationCacheSize = 256 [static]

Definition at line 25 of file gc_fragments.cpp.

Definition at line 141 of file gc_fragments.cpp.