mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-01-08 22:15:37 +00:00
fix pointer style to match the style guide
We do this in a lot of places, but we're inconsistent. Normalize the code to the Google C++ style guide. Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932 Reviewed-by: Sterling Augustine <saugustine@google.com> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
a741027533
commit
09b056975d
|
@ -37,7 +37,7 @@
|
|||
//
|
||||
// These files can then be uploaded to a server.
|
||||
|
||||
typedef void *BreakpadRef;
|
||||
typedef void* BreakpadRef;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -60,15 +60,15 @@ extern "C" {
|
|||
typedef bool (*BreakpadFilterCallback)(int exception_type,
|
||||
int exception_code,
|
||||
mach_port_t crashing_thread,
|
||||
void *context);
|
||||
void* context);
|
||||
|
||||
// Optional user-defined function that will be called after a network upload
|
||||
// of a crash report.
|
||||
// |report_id| will be the id returned by the server, or "ERR" if an error
|
||||
// occurred.
|
||||
// |error| will contain the error, or nil if no error occured.
|
||||
typedef void (*BreakpadUploadCompletionCallback)(NSString *report_id,
|
||||
NSError *error);
|
||||
typedef void (*BreakpadUploadCompletionCallback)(NSString* report_id,
|
||||
NSError* error);
|
||||
|
||||
// Create a new BreakpadRef object and install it as an exception
|
||||
// handler. The |parameters| will typically be the contents of your
|
||||
|
@ -163,7 +163,7 @@ typedef void (*BreakpadUploadCompletionCallback)(NSString *report_id,
|
|||
// internal values.
|
||||
|
||||
// Returns a new BreakpadRef object on success, NULL otherwise.
|
||||
BreakpadRef BreakpadCreate(NSDictionary *parameters);
|
||||
BreakpadRef BreakpadCreate(NSDictionary* parameters);
|
||||
|
||||
// Uninstall and release the data associated with |ref|.
|
||||
void BreakpadRelease(BreakpadRef ref);
|
||||
|
@ -187,20 +187,20 @@ void BreakpadRelease(BreakpadRef ref);
|
|||
// TODO (nealsid): separate server parameter dictionary from the
|
||||
// dictionary used to configure Breakpad, and document limits for each
|
||||
// independently.
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value);
|
||||
NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key);
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key);
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value);
|
||||
NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key);
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key);
|
||||
|
||||
// You can use this method to specify parameters that will be uploaded
|
||||
// to the crash server. They will be automatically encoded as
|
||||
// necessary. Note that as mentioned above there are limits on both
|
||||
// the number of keys and their length.
|
||||
void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key,
|
||||
NSString *value);
|
||||
void BreakpadAddUploadParameter(BreakpadRef ref, NSString* key,
|
||||
NSString* value);
|
||||
|
||||
// This method will remove a previously-added parameter from the
|
||||
// upload parameter set.
|
||||
void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
|
||||
void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString* key);
|
||||
|
||||
// Method to handle uploading data to the server
|
||||
|
||||
|
@ -208,10 +208,10 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
|
|||
int BreakpadGetCrashReportCount(BreakpadRef ref);
|
||||
|
||||
// Returns the next upload configuration. The report file is deleted.
|
||||
NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref);
|
||||
NSDictionary* BreakpadGetNextReportConfiguration(BreakpadRef ref);
|
||||
|
||||
// Returns the date of the most recent crash report.
|
||||
NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref);
|
||||
NSDate* BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref);
|
||||
|
||||
// Upload next report to the server.
|
||||
void BreakpadUploadNextReport(BreakpadRef ref);
|
||||
|
@ -220,7 +220,7 @@ void BreakpadUploadNextReport(BreakpadRef ref);
|
|||
// |server_parameters| is additional server parameters to send.
|
||||
void BreakpadUploadNextReportWithParameters(
|
||||
BreakpadRef ref,
|
||||
NSDictionary *server_parameters,
|
||||
NSDictionary* server_parameters,
|
||||
BreakpadUploadCompletionCallback callback);
|
||||
|
||||
// Upload a report to the server.
|
||||
|
@ -228,8 +228,8 @@ void BreakpadUploadNextReportWithParameters(
|
|||
// |configuration| is the configuration of the breakpad report to send.
|
||||
void BreakpadUploadReportWithParametersAndConfiguration(
|
||||
BreakpadRef ref,
|
||||
NSDictionary *server_parameters,
|
||||
NSDictionary *configuration,
|
||||
NSDictionary* server_parameters,
|
||||
NSDictionary* configuration,
|
||||
BreakpadUploadCompletionCallback callback);
|
||||
|
||||
// Handles the network response of a breakpad upload. This function is needed if
|
||||
|
@ -239,21 +239,21 @@ void BreakpadUploadReportWithParametersAndConfiguration(
|
|||
// BreakpadUploadReportWithParametersAndConfiguration.
|
||||
// |data| and |error| contain the network response.
|
||||
void BreakpadHandleNetworkResponse(BreakpadRef ref,
|
||||
NSDictionary *configuration,
|
||||
NSData *data,
|
||||
NSError *error);
|
||||
NSDictionary* configuration,
|
||||
NSData* data,
|
||||
NSError* error);
|
||||
|
||||
// Upload a file to the server. |data| is the content of the file to sent.
|
||||
// |server_parameters| is additional server parameters to send.
|
||||
void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
|
||||
NSDictionary *server_parameters);
|
||||
void BreakpadUploadData(BreakpadRef ref, NSData* data, NSString* name,
|
||||
NSDictionary* server_parameters);
|
||||
|
||||
// Generate a breakpad minidump and configuration file in the dump directory.
|
||||
// The report will be available for uploading. The paths of the created files
|
||||
// are returned in the dictionary. |server_parameters| is additional server
|
||||
// parameters to add in the config file.
|
||||
NSDictionary *BreakpadGenerateReport(BreakpadRef ref,
|
||||
NSDictionary *server_parameters);
|
||||
NSDictionary* BreakpadGenerateReport(BreakpadRef ref,
|
||||
NSDictionary* server_parameters);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -84,9 +84,9 @@ using google_breakpad::LongStringDictionary;
|
|||
// allocation of C++ objects. Note that we don't use operator delete()
|
||||
// but instead call the objects destructor directly: object->~ClassName();
|
||||
//
|
||||
ProtectedMemoryAllocator *gMasterAllocator = NULL;
|
||||
ProtectedMemoryAllocator *gKeyValueAllocator = NULL;
|
||||
ProtectedMemoryAllocator *gBreakpadAllocator = NULL;
|
||||
ProtectedMemoryAllocator* gMasterAllocator = NULL;
|
||||
ProtectedMemoryAllocator* gKeyValueAllocator = NULL;
|
||||
ProtectedMemoryAllocator* gBreakpadAllocator = NULL;
|
||||
|
||||
// Mutex for thread-safe access to the key/value dictionary used by breakpad.
|
||||
// It's a global instead of an instance variable of Breakpad
|
||||
|
@ -101,8 +101,8 @@ pthread_mutex_t gDictionaryMutex;
|
|||
// Its destructor will first re-protect the memory then release the lock.
|
||||
class ProtectedMemoryLocker {
|
||||
public:
|
||||
ProtectedMemoryLocker(pthread_mutex_t *mutex,
|
||||
ProtectedMemoryAllocator *allocator)
|
||||
ProtectedMemoryLocker(pthread_mutex_t* mutex,
|
||||
ProtectedMemoryAllocator* allocator)
|
||||
: mutex_(mutex),
|
||||
allocator_(allocator) {
|
||||
// Lock the mutex
|
||||
|
@ -127,17 +127,17 @@ class ProtectedMemoryLocker {
|
|||
ProtectedMemoryLocker(const ProtectedMemoryLocker&);
|
||||
ProtectedMemoryLocker& operator=(const ProtectedMemoryLocker&);
|
||||
|
||||
pthread_mutex_t *mutex_;
|
||||
ProtectedMemoryAllocator *allocator_;
|
||||
pthread_mutex_t* mutex_;
|
||||
ProtectedMemoryAllocator* allocator_;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
class Breakpad {
|
||||
public:
|
||||
// factory method
|
||||
static Breakpad *Create(NSDictionary *parameters) {
|
||||
static Breakpad* Create(NSDictionary* parameters) {
|
||||
// Allocate from our special allocation pool
|
||||
Breakpad *breakpad =
|
||||
Breakpad* breakpad =
|
||||
new (gBreakpadAllocator->Allocate(sizeof(Breakpad)))
|
||||
Breakpad();
|
||||
|
||||
|
@ -155,62 +155,62 @@ class Breakpad {
|
|||
|
||||
~Breakpad();
|
||||
|
||||
void SetKeyValue(NSString *key, NSString *value);
|
||||
NSString *KeyValue(NSString *key);
|
||||
void RemoveKeyValue(NSString *key);
|
||||
NSArray *CrashReportsToUpload();
|
||||
NSString *NextCrashReportToUpload();
|
||||
NSDictionary *NextCrashReportConfiguration();
|
||||
NSDictionary *FixedUpCrashReportConfiguration(NSDictionary *configuration);
|
||||
NSDate *DateOfMostRecentCrashReport();
|
||||
void UploadNextReport(NSDictionary *server_parameters);
|
||||
void UploadReportWithConfiguration(NSDictionary *configuration,
|
||||
NSDictionary *server_parameters,
|
||||
void SetKeyValue(NSString* key, NSString* value);
|
||||
NSString* KeyValue(NSString* key);
|
||||
void RemoveKeyValue(NSString* key);
|
||||
NSArray* CrashReportsToUpload();
|
||||
NSString* NextCrashReportToUpload();
|
||||
NSDictionary* NextCrashReportConfiguration();
|
||||
NSDictionary* FixedUpCrashReportConfiguration(NSDictionary* configuration);
|
||||
NSDate* DateOfMostRecentCrashReport();
|
||||
void UploadNextReport(NSDictionary* server_parameters);
|
||||
void UploadReportWithConfiguration(NSDictionary* configuration,
|
||||
NSDictionary* server_parameters,
|
||||
BreakpadUploadCompletionCallback callback);
|
||||
void UploadData(NSData *data, NSString *name,
|
||||
NSDictionary *server_parameters);
|
||||
void HandleNetworkResponse(NSDictionary *configuration,
|
||||
NSData *data,
|
||||
NSError *error);
|
||||
NSDictionary *GenerateReport(NSDictionary *server_parameters);
|
||||
void UploadData(NSData* data, NSString* name,
|
||||
NSDictionary* server_parameters);
|
||||
void HandleNetworkResponse(NSDictionary* configuration,
|
||||
NSData* data,
|
||||
NSError* error);
|
||||
NSDictionary* GenerateReport(NSDictionary* server_parameters);
|
||||
|
||||
private:
|
||||
Breakpad()
|
||||
: handler_(NULL),
|
||||
config_params_(NULL) {}
|
||||
|
||||
bool Initialize(NSDictionary *parameters);
|
||||
bool Initialize(NSDictionary* parameters);
|
||||
|
||||
bool ExtractParameters(NSDictionary *parameters);
|
||||
bool ExtractParameters(NSDictionary* parameters);
|
||||
|
||||
// Dispatches to HandleMinidump()
|
||||
static bool HandleMinidumpCallback(const char *dump_dir,
|
||||
const char *minidump_id,
|
||||
void *context, bool succeeded);
|
||||
static bool HandleMinidumpCallback(const char* dump_dir,
|
||||
const char* minidump_id,
|
||||
void* context, bool succeeded);
|
||||
|
||||
bool HandleMinidump(const char *dump_dir,
|
||||
const char *minidump_id);
|
||||
bool HandleMinidump(const char* dump_dir,
|
||||
const char* minidump_id);
|
||||
|
||||
// NSException handler
|
||||
static void UncaughtExceptionHandler(NSException *exception);
|
||||
static void UncaughtExceptionHandler(NSException* exception);
|
||||
|
||||
// Handle an uncaught NSException.
|
||||
void HandleUncaughtException(NSException *exception);
|
||||
void HandleUncaughtException(NSException* exception);
|
||||
|
||||
// Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's
|
||||
// MachineExceptions.h, we have to explicitly name the handler.
|
||||
google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG)
|
||||
google_breakpad::ExceptionHandler* handler_; // The actual handler (STRONG)
|
||||
|
||||
LongStringDictionary *config_params_; // Create parameters (STRONG)
|
||||
LongStringDictionary* config_params_; // Create parameters (STRONG)
|
||||
|
||||
ConfigFile config_file_;
|
||||
|
||||
// A static reference to the current Breakpad instance. Used for handling
|
||||
// NSException.
|
||||
static Breakpad *current_breakpad_;
|
||||
static Breakpad* current_breakpad_;
|
||||
};
|
||||
|
||||
Breakpad *Breakpad::current_breakpad_ = NULL;
|
||||
Breakpad* Breakpad::current_breakpad_ = NULL;
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Helper functions
|
||||
|
@ -221,14 +221,14 @@ Breakpad *Breakpad::current_breakpad_ = NULL;
|
|||
//=============================================================================
|
||||
static BOOL IsDebuggerActive() {
|
||||
BOOL result = NO;
|
||||
NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// We check both defaults and the environment variable here
|
||||
|
||||
BOOL ignoreDebugger = [stdDefaults boolForKey:@IGNORE_DEBUGGER];
|
||||
|
||||
if (!ignoreDebugger) {
|
||||
char *ignoreDebuggerStr = getenv(IGNORE_DEBUGGER);
|
||||
char* ignoreDebuggerStr = getenv(IGNORE_DEBUGGER);
|
||||
ignoreDebugger =
|
||||
(ignoreDebuggerStr ? strtol(ignoreDebuggerStr, NULL, 10) : 0) != 0;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ static BOOL IsDebuggerActive() {
|
|||
size_t actualSize;
|
||||
|
||||
if (sysctl(mib, mibSize, NULL, &actualSize, NULL, 0) == 0) {
|
||||
struct kinfo_proc *info = (struct kinfo_proc *)malloc(actualSize);
|
||||
struct kinfo_proc* info = (struct kinfo_proc*)malloc(actualSize);
|
||||
|
||||
if (info) {
|
||||
// This comes from looking at the Darwin xnu Kernel
|
||||
|
@ -256,10 +256,10 @@ static BOOL IsDebuggerActive() {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::HandleMinidumpCallback(const char *dump_dir,
|
||||
const char *minidump_id,
|
||||
void *context, bool succeeded) {
|
||||
Breakpad *breakpad = (Breakpad *)context;
|
||||
bool Breakpad::HandleMinidumpCallback(const char* dump_dir,
|
||||
const char* minidump_id,
|
||||
void* context, bool succeeded) {
|
||||
Breakpad* breakpad = (Breakpad*)context;
|
||||
|
||||
// If our context is damaged or something, just return false to indicate that
|
||||
// the handler should continue without us.
|
||||
|
@ -270,7 +270,7 @@ bool Breakpad::HandleMinidumpCallback(const char *dump_dir,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::UncaughtExceptionHandler(NSException *exception) {
|
||||
void Breakpad::UncaughtExceptionHandler(NSException* exception) {
|
||||
NSSetUncaughtExceptionHandler(NULL);
|
||||
if (current_breakpad_) {
|
||||
current_breakpad_->HandleUncaughtException(exception);
|
||||
|
@ -282,7 +282,7 @@ void Breakpad::UncaughtExceptionHandler(NSException *exception) {
|
|||
#pragma mark -
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::Initialize(NSDictionary *parameters) {
|
||||
bool Breakpad::Initialize(NSDictionary* parameters) {
|
||||
// Initialize
|
||||
current_breakpad_ = this;
|
||||
config_params_ = NULL;
|
||||
|
@ -325,21 +325,21 @@ Breakpad::~Breakpad() {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
||||
NSString *serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE];
|
||||
NSString *display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY];
|
||||
NSString *product = [parameters objectForKey:@BREAKPAD_PRODUCT];
|
||||
NSString *version = [parameters objectForKey:@BREAKPAD_VERSION];
|
||||
NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL];
|
||||
NSString *vendor =
|
||||
bool Breakpad::ExtractParameters(NSDictionary* parameters) {
|
||||
NSString* serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE];
|
||||
NSString* display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY];
|
||||
NSString* product = [parameters objectForKey:@BREAKPAD_PRODUCT];
|
||||
NSString* version = [parameters objectForKey:@BREAKPAD_VERSION];
|
||||
NSString* urlStr = [parameters objectForKey:@BREAKPAD_URL];
|
||||
NSString* vendor =
|
||||
[parameters objectForKey:@BREAKPAD_VENDOR];
|
||||
// We check both parameters and the environment variable here.
|
||||
char *envVarDumpSubdirectory = getenv(BREAKPAD_DUMP_DIRECTORY);
|
||||
NSString *dumpSubdirectory = envVarDumpSubdirectory ?
|
||||
char* envVarDumpSubdirectory = getenv(BREAKPAD_DUMP_DIRECTORY);
|
||||
NSString* dumpSubdirectory = envVarDumpSubdirectory ?
|
||||
[NSString stringWithUTF8String:envVarDumpSubdirectory] :
|
||||
[parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY];
|
||||
|
||||
NSDictionary *serverParameters =
|
||||
NSDictionary* serverParameters =
|
||||
[parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT];
|
||||
|
||||
if (!product)
|
||||
|
@ -360,7 +360,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
}
|
||||
|
||||
if (!dumpSubdirectory) {
|
||||
NSString *cachePath =
|
||||
NSString* cachePath =
|
||||
[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
|
||||
NSUserDomainMask,
|
||||
YES)
|
||||
|
@ -388,7 +388,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
new (gKeyValueAllocator->Allocate(sizeof(LongStringDictionary)))
|
||||
LongStringDictionary();
|
||||
|
||||
LongStringDictionary &dictionary = *config_params_;
|
||||
LongStringDictionary& dictionary = *config_params_;
|
||||
|
||||
dictionary.SetKeyValue(BREAKPAD_SERVER_TYPE, [serverType UTF8String]);
|
||||
dictionary.SetKeyValue(BREAKPAD_PRODUCT_DISPLAY, [display UTF8String]);
|
||||
|
@ -407,8 +407,8 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
|
||||
if (serverParameters) {
|
||||
// For each key-value pair, call BreakpadAddUploadParameter()
|
||||
NSEnumerator *keyEnumerator = [serverParameters keyEnumerator];
|
||||
NSString *aParameter;
|
||||
NSEnumerator* keyEnumerator = [serverParameters keyEnumerator];
|
||||
NSString* aParameter;
|
||||
while ((aParameter = [keyEnumerator nextObject])) {
|
||||
BreakpadAddUploadParameter(this, aParameter,
|
||||
[serverParameters objectForKey:aParameter]);
|
||||
|
@ -418,7 +418,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::SetKeyValue(NSString *key, NSString *value) {
|
||||
void Breakpad::SetKeyValue(NSString* key, NSString* value) {
|
||||
// We allow nil values. This is the same as removing the keyvalue.
|
||||
if (!config_params_ || !key)
|
||||
return;
|
||||
|
@ -427,7 +427,7 @@ void Breakpad::SetKeyValue(NSString *key, NSString *value) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSString *Breakpad::KeyValue(NSString *key) {
|
||||
NSString* Breakpad::KeyValue(NSString* key) {
|
||||
if (!config_params_ || !key)
|
||||
return nil;
|
||||
|
||||
|
@ -436,44 +436,44 @@ NSString *Breakpad::KeyValue(NSString *key) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::RemoveKeyValue(NSString *key) {
|
||||
void Breakpad::RemoveKeyValue(NSString* key) {
|
||||
if (!config_params_ || !key) return;
|
||||
|
||||
config_params_->RemoveKey([key UTF8String]);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
NSArray *Breakpad::CrashReportsToUpload() {
|
||||
NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
NSArray* Breakpad::CrashReportsToUpload() {
|
||||
NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
if (!directory)
|
||||
return nil;
|
||||
NSArray *dirContents = [[NSFileManager defaultManager]
|
||||
NSArray* dirContents = [[NSFileManager defaultManager]
|
||||
contentsOfDirectoryAtPath:directory error:nil];
|
||||
NSArray *configs = [dirContents filteredArrayUsingPredicate:[NSPredicate
|
||||
NSArray* configs = [dirContents filteredArrayUsingPredicate:[NSPredicate
|
||||
predicateWithFormat:@"self BEGINSWITH 'Config-'"]];
|
||||
return configs;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
NSString *Breakpad::NextCrashReportToUpload() {
|
||||
NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
NSString* Breakpad::NextCrashReportToUpload() {
|
||||
NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
if (!directory)
|
||||
return nil;
|
||||
NSString *config = [CrashReportsToUpload() lastObject];
|
||||
NSString* config = [CrashReportsToUpload() lastObject];
|
||||
if (!config)
|
||||
return nil;
|
||||
return [NSString stringWithFormat:@"%@/%@", directory, config];
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDictionary *Breakpad::NextCrashReportConfiguration() {
|
||||
NSDictionary *configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()];
|
||||
NSDictionary* Breakpad::NextCrashReportConfiguration() {
|
||||
NSDictionary* configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()];
|
||||
return FixedUpCrashReportConfiguration(configuration);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configuration) {
|
||||
NSMutableDictionary *fixedConfiguration = [[configuration mutableCopy] autorelease];
|
||||
NSDictionary* Breakpad::FixedUpCrashReportConfiguration(NSDictionary* configuration) {
|
||||
NSMutableDictionary* fixedConfiguration = [[configuration mutableCopy] autorelease];
|
||||
// kReporterMinidumpDirectoryKey can become stale because the app's data container path includes
|
||||
// an UUID that is not guaranteed to stay the same over time.
|
||||
[fixedConfiguration setObject:KeyValue(@BREAKPAD_DUMP_DIRECTORY)
|
||||
|
@ -482,19 +482,19 @@ NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configurat
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDate *Breakpad::DateOfMostRecentCrashReport() {
|
||||
NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
NSDate* Breakpad::DateOfMostRecentCrashReport() {
|
||||
NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
if (!directory) {
|
||||
return nil;
|
||||
}
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSArray *dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil];
|
||||
NSArray *dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate
|
||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||
NSArray* dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil];
|
||||
NSArray* dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate
|
||||
predicateWithFormat:@"self ENDSWITH '.dmp'"]];
|
||||
NSDate *mostRecentCrashReportDate = nil;
|
||||
for (NSString *dump in dumps) {
|
||||
NSString *filePath = [directory stringByAppendingPathComponent:dump];
|
||||
NSDate *crashReportDate =
|
||||
NSDate* mostRecentCrashReportDate = nil;
|
||||
for (NSString* dump in dumps) {
|
||||
NSString* filePath = [directory stringByAppendingPathComponent:dump];
|
||||
NSDate* crashReportDate =
|
||||
[[fileManager attributesOfItemAtPath:filePath error:nil] fileCreationDate];
|
||||
if (!mostRecentCrashReportDate) {
|
||||
mostRecentCrashReportDate = crashReportDate;
|
||||
|
@ -506,29 +506,29 @@ NSDate *Breakpad::DateOfMostRecentCrashReport() {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::HandleNetworkResponse(NSDictionary *configuration,
|
||||
NSData *data,
|
||||
NSError *error) {
|
||||
Uploader *uploader = [[[Uploader alloc]
|
||||
void Breakpad::HandleNetworkResponse(NSDictionary* configuration,
|
||||
NSData* data,
|
||||
NSError* error) {
|
||||
Uploader* uploader = [[[Uploader alloc]
|
||||
initWithConfig:configuration] autorelease];
|
||||
[uploader handleNetworkResponse:data withError:error];
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::UploadReportWithConfiguration(
|
||||
NSDictionary *configuration,
|
||||
NSDictionary *server_parameters,
|
||||
NSDictionary* configuration,
|
||||
NSDictionary* server_parameters,
|
||||
BreakpadUploadCompletionCallback callback) {
|
||||
Uploader *uploader = [[[Uploader alloc]
|
||||
Uploader* uploader = [[[Uploader alloc]
|
||||
initWithConfig:configuration] autorelease];
|
||||
if (!uploader)
|
||||
return;
|
||||
for (NSString *key in server_parameters) {
|
||||
for (NSString* key in server_parameters) {
|
||||
[uploader addServerParameter:[server_parameters objectForKey:key]
|
||||
forKey:key];
|
||||
}
|
||||
if (callback) {
|
||||
[uploader setUploadCompletionBlock:^(NSString *report_id, NSError *error) {
|
||||
[uploader setUploadCompletionBlock:^(NSString* report_id, NSError* error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
callback(report_id, error);
|
||||
});
|
||||
|
@ -538,8 +538,8 @@ void Breakpad::UploadReportWithConfiguration(
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::UploadNextReport(NSDictionary *server_parameters) {
|
||||
NSDictionary *configuration = NextCrashReportConfiguration();
|
||||
void Breakpad::UploadNextReport(NSDictionary* server_parameters) {
|
||||
NSDictionary* configuration = NextCrashReportConfiguration();
|
||||
if (configuration) {
|
||||
return UploadReportWithConfiguration(configuration, server_parameters,
|
||||
nullptr);
|
||||
|
@ -547,19 +547,19 @@ void Breakpad::UploadNextReport(NSDictionary *server_parameters) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::UploadData(NSData *data, NSString *name,
|
||||
NSDictionary *server_parameters) {
|
||||
NSMutableDictionary *config = [NSMutableDictionary dictionary];
|
||||
void Breakpad::UploadData(NSData* data, NSString* name,
|
||||
NSDictionary* server_parameters) {
|
||||
NSMutableDictionary* config = [NSMutableDictionary dictionary];
|
||||
|
||||
LongStringDictionary::Iterator it(*config_params_);
|
||||
while (const LongStringDictionary::Entry *next = it.Next()) {
|
||||
while (const LongStringDictionary::Entry* next = it.Next()) {
|
||||
[config setValue:[NSString stringWithUTF8String:next->value]
|
||||
forKey:[NSString stringWithUTF8String:next->key]];
|
||||
}
|
||||
|
||||
Uploader *uploader =
|
||||
Uploader* uploader =
|
||||
[[[Uploader alloc] initWithConfig:config] autorelease];
|
||||
for (NSString *key in server_parameters) {
|
||||
for (NSString* key in server_parameters) {
|
||||
[uploader addServerParameter:[server_parameters objectForKey:key]
|
||||
forKey:key];
|
||||
}
|
||||
|
@ -567,11 +567,11 @@ void Breakpad::UploadData(NSData *data, NSString *name,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) {
|
||||
NSString *dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
NSDictionary* Breakpad::GenerateReport(NSDictionary* server_parameters) {
|
||||
NSString* dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||
if (!dumpDirAsNSString)
|
||||
return nil;
|
||||
const char *dumpDir = [dumpDirAsNSString UTF8String];
|
||||
const char* dumpDir = [dumpDirAsNSString UTF8String];
|
||||
|
||||
google_breakpad::MinidumpGenerator generator(mach_task_self(),
|
||||
MACH_PORT_NULL);
|
||||
|
@ -582,7 +582,7 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) {
|
|||
return nil;
|
||||
|
||||
LongStringDictionary params = *config_params_;
|
||||
for (NSString *key in server_parameters) {
|
||||
for (NSString* key in server_parameters) {
|
||||
params.SetKeyValue([key UTF8String],
|
||||
[[server_parameters objectForKey:key] UTF8String]);
|
||||
}
|
||||
|
@ -590,8 +590,8 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) {
|
|||
config_file.WriteFile(dumpDir, ¶ms, dumpDir, dumpId.c_str());
|
||||
|
||||
// Handle results.
|
||||
NSMutableDictionary *result = [NSMutableDictionary dictionary];
|
||||
NSString *dumpFullPath = [NSString stringWithUTF8String:dumpFilename.c_str()];
|
||||
NSMutableDictionary* result = [NSMutableDictionary dictionary];
|
||||
NSString* dumpFullPath = [NSString stringWithUTF8String:dumpFilename.c_str()];
|
||||
[result setValue:dumpFullPath
|
||||
forKey:@BREAKPAD_OUTPUT_DUMP_FILE];
|
||||
[result setValue:[NSString stringWithUTF8String:config_file.GetFilePath()]
|
||||
|
@ -600,8 +600,8 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::HandleMinidump(const char *dump_dir,
|
||||
const char *minidump_id) {
|
||||
bool Breakpad::HandleMinidump(const char* dump_dir,
|
||||
const char* minidump_id) {
|
||||
config_file_.WriteFile(dump_dir,
|
||||
config_params_,
|
||||
dump_dir,
|
||||
|
@ -613,7 +613,7 @@ bool Breakpad::HandleMinidump(const char *dump_dir,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::HandleUncaughtException(NSException *exception) {
|
||||
void Breakpad::HandleUncaughtException(NSException* exception) {
|
||||
// Generate the minidump.
|
||||
google_breakpad::IosExceptionMinidumpGenerator generator(exception);
|
||||
const std::string minidump_path =
|
||||
|
@ -650,7 +650,7 @@ void Breakpad::HandleUncaughtException(NSException *exception) {
|
|||
#pragma mark Public API
|
||||
|
||||
//=============================================================================
|
||||
BreakpadRef BreakpadCreate(NSDictionary *parameters) {
|
||||
BreakpadRef BreakpadCreate(NSDictionary* parameters) {
|
||||
try {
|
||||
// This is confusing. Our two main allocators for breakpad memory are:
|
||||
// - gKeyValueAllocator for the key/value memory
|
||||
|
@ -690,8 +690,8 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
|
|||
ProtectedMemoryAllocator(breakpad_pool_size);
|
||||
|
||||
// Stack-based autorelease pool for Breakpad::Create() obj-c code.
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
Breakpad *breakpad = Breakpad::Create(parameters);
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
Breakpad* breakpad = Breakpad::Create(parameters);
|
||||
|
||||
if (breakpad) {
|
||||
// Make read-only to protect against memory smashers
|
||||
|
@ -731,7 +731,7 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
|
|||
//=============================================================================
|
||||
void BreakpadRelease(BreakpadRef ref) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (gMasterAllocator) {
|
||||
gMasterAllocator->Unprotect();
|
||||
|
@ -764,10 +764,10 @@ void BreakpadRelease(BreakpadRef ref) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) {
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
@ -780,20 +780,20 @@ void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) {
|
|||
}
|
||||
|
||||
void BreakpadAddUploadParameter(BreakpadRef ref,
|
||||
NSString *key,
|
||||
NSString *value) {
|
||||
NSString* key,
|
||||
NSString* value) {
|
||||
// The only difference, internally, between an upload parameter and
|
||||
// a key value one that is set with BreakpadSetKeyValue is that we
|
||||
// prepend the keyname with a special prefix. This informs the
|
||||
// crash sender that the parameter should be sent along with the
|
||||
// POST of the crash dump upload.
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
||||
NSString *prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX
|
||||
NSString* prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX
|
||||
stringByAppendingString:key];
|
||||
breakpad->SetKeyValue(prefixedKey, value);
|
||||
}
|
||||
|
@ -803,15 +803,15 @@ void BreakpadAddUploadParameter(BreakpadRef ref,
|
|||
}
|
||||
|
||||
void BreakpadRemoveUploadParameter(BreakpadRef ref,
|
||||
NSString *key) {
|
||||
NSString* key) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
||||
NSString *prefixedKey = [NSString stringWithFormat:@"%@%@",
|
||||
NSString* prefixedKey = [NSString stringWithFormat:@"%@%@",
|
||||
@BREAKPAD_SERVER_PARAMETER_PREFIX, key];
|
||||
breakpad->RemoveKeyValue(prefixedKey);
|
||||
}
|
||||
|
@ -820,12 +820,12 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref,
|
|||
}
|
||||
}
|
||||
//=============================================================================
|
||||
NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) {
|
||||
NSString *value = nil;
|
||||
NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key) {
|
||||
NSString* value = nil;
|
||||
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (!breakpad || !key || !gKeyValueAllocator)
|
||||
return nil;
|
||||
|
@ -841,10 +841,10 @@ NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) {
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
@ -860,7 +860,7 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) {
|
|||
int BreakpadGetCrashReportCount(BreakpadRef ref) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad) {
|
||||
return static_cast<int>([breakpad->CrashReportsToUpload() count]);
|
||||
|
@ -877,9 +877,9 @@ void BreakpadUploadNextReport(BreakpadRef ref) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) {
|
||||
NSDictionary* BreakpadGetNextReportConfiguration(BreakpadRef ref) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
if (breakpad)
|
||||
return breakpad->NextCrashReportConfiguration();
|
||||
} catch(...) { // don't let exceptions leave this C API
|
||||
|
@ -889,9 +889,9 @@ NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) {
|
||||
NSDate* BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
if (breakpad) {
|
||||
return breakpad->DateOfMostRecentCrashReport();
|
||||
}
|
||||
|
@ -904,11 +904,11 @@ NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) {
|
|||
//=============================================================================
|
||||
void BreakpadUploadReportWithParametersAndConfiguration(
|
||||
BreakpadRef ref,
|
||||
NSDictionary *server_parameters,
|
||||
NSDictionary *configuration,
|
||||
NSDictionary* server_parameters,
|
||||
NSDictionary* configuration,
|
||||
BreakpadUploadCompletionCallback callback) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
if (!breakpad || !configuration)
|
||||
return;
|
||||
breakpad->UploadReportWithConfiguration(configuration, server_parameters,
|
||||
|
@ -922,13 +922,13 @@ void BreakpadUploadReportWithParametersAndConfiguration(
|
|||
//=============================================================================
|
||||
void BreakpadUploadNextReportWithParameters(
|
||||
BreakpadRef ref,
|
||||
NSDictionary *server_parameters,
|
||||
NSDictionary* server_parameters,
|
||||
BreakpadUploadCompletionCallback callback) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
if (!breakpad)
|
||||
return;
|
||||
NSDictionary *configuration = breakpad->NextCrashReportConfiguration();
|
||||
NSDictionary* configuration = breakpad->NextCrashReportConfiguration();
|
||||
if (!configuration)
|
||||
return;
|
||||
return BreakpadUploadReportWithParametersAndConfiguration(
|
||||
|
@ -939,12 +939,12 @@ void BreakpadUploadNextReportWithParameters(
|
|||
}
|
||||
|
||||
void BreakpadHandleNetworkResponse(BreakpadRef ref,
|
||||
NSDictionary *configuration,
|
||||
NSData *data,
|
||||
NSError *error) {
|
||||
NSDictionary* configuration,
|
||||
NSData* data,
|
||||
NSError* error) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
if (breakpad && configuration)
|
||||
breakpad->HandleNetworkResponse(configuration,data, error);
|
||||
|
||||
|
@ -954,11 +954,11 @@ void BreakpadHandleNetworkResponse(BreakpadRef ref,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
|
||||
NSDictionary *server_parameters) {
|
||||
void BreakpadUploadData(BreakpadRef ref, NSData* data, NSString* name,
|
||||
NSDictionary* server_parameters) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad) {
|
||||
breakpad->UploadData(data, name, server_parameters);
|
||||
|
@ -969,11 +969,11 @@ void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSDictionary *BreakpadGenerateReport(BreakpadRef ref,
|
||||
NSDictionary *server_parameters) {
|
||||
NSDictionary* BreakpadGenerateReport(BreakpadRef ref,
|
||||
NSDictionary* server_parameters) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad) {
|
||||
return breakpad->GenerateReport(server_parameters);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
// for more details.
|
||||
#if USE_PROTECTED_ALLOCATIONS
|
||||
#include "client/mac/handler/protected_memory_allocator.h"
|
||||
extern ProtectedMemoryAllocator *gBreakpadAllocator;
|
||||
extern ProtectedMemoryAllocator* gBreakpadAllocator;
|
||||
#endif
|
||||
|
||||
namespace google_breakpad {
|
||||
|
@ -72,10 +72,10 @@ static union {
|
|||
char protected_buffer[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
|
||||
#endif // defined PAGE_MAX_SIZE
|
||||
#endif // USE_PROTECTED_ALLOCATIONS
|
||||
google_breakpad::ExceptionHandler *handler;
|
||||
google_breakpad::ExceptionHandler* handler;
|
||||
} gProtectedData;
|
||||
|
||||
ExceptionHandler::ExceptionHandler(const string &dump_path,
|
||||
ExceptionHandler::ExceptionHandler(const string& dump_path,
|
||||
FilterCallback filter,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context,
|
||||
|
|
|
@ -53,7 +53,7 @@ class ExceptionHandler {
|
|||
// attempting to write a minidump. If a FilterCallback returns false, Breakpad
|
||||
// will immediately report the exception as unhandled without writing a
|
||||
// minidump, allowing another handler the opportunity to handle it.
|
||||
typedef bool (*FilterCallback)(void *context);
|
||||
typedef bool (*FilterCallback)(void* context);
|
||||
|
||||
// A callback function to run after the minidump has been written.
|
||||
// |minidump_id| is a unique id for the dump, so the minidump
|
||||
|
@ -63,18 +63,18 @@ class ExceptionHandler {
|
|||
// Return true if the exception was fully handled and breakpad should exit.
|
||||
// Return false to allow any other exception handlers to process the
|
||||
// exception.
|
||||
typedef bool (*MinidumpCallback)(const char *dump_dir,
|
||||
const char *minidump_id,
|
||||
void *context, bool succeeded);
|
||||
typedef bool (*MinidumpCallback)(const char* dump_dir,
|
||||
const char* minidump_id,
|
||||
void* context, bool succeeded);
|
||||
|
||||
// A callback function which will be called directly if an exception occurs.
|
||||
// This bypasses the minidump file writing and simply gives the client
|
||||
// the exception information.
|
||||
typedef bool (*DirectCallback)( void *context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
mach_port_t thread_name);
|
||||
typedef bool (*DirectCallback)(void* context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
mach_port_t thread_name);
|
||||
|
||||
// Creates a new ExceptionHandler instance to handle writing minidumps.
|
||||
// Minidump files will be written to dump_path, and the optional callback
|
||||
|
@ -84,22 +84,22 @@ class ExceptionHandler {
|
|||
// be written when WriteMinidump is called.
|
||||
// If port_name is non-NULL, attempt to perform out-of-process dump generation
|
||||
// If port_name is NULL, in-process dump generation will be used.
|
||||
ExceptionHandler(const string &dump_path,
|
||||
ExceptionHandler(const string& dump_path,
|
||||
FilterCallback filter, MinidumpCallback callback,
|
||||
void *callback_context, bool install_handler,
|
||||
const char *port_name);
|
||||
void* callback_context, bool install_handler,
|
||||
const char* port_name);
|
||||
|
||||
// A special constructor if we want to bypass minidump writing and
|
||||
// simply get a callback with the exception information.
|
||||
ExceptionHandler(DirectCallback callback,
|
||||
void *callback_context,
|
||||
void* callback_context,
|
||||
bool install_handler);
|
||||
|
||||
~ExceptionHandler();
|
||||
|
||||
// Get and set the minidump path.
|
||||
string dump_path() const { return dump_path_; }
|
||||
void set_dump_path(const string &dump_path) {
|
||||
void set_dump_path(const string& dump_path) {
|
||||
dump_path_ = dump_path;
|
||||
dump_path_c_ = dump_path_.c_str();
|
||||
UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_.
|
||||
|
@ -126,7 +126,7 @@ class ExceptionHandler {
|
|||
bool WriteMinidumpWithException(int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
breakpad_ucontext_t *task_context,
|
||||
breakpad_ucontext_t* task_context,
|
||||
mach_port_t thread_name,
|
||||
bool exit_after_write,
|
||||
bool report_current_thread);
|
||||
|
@ -135,8 +135,8 @@ class ExceptionHandler {
|
|||
static void SignalHandler(int sig, siginfo_t* info, void* uc);
|
||||
|
||||
// disallow copy ctor and operator=
|
||||
explicit ExceptionHandler(const ExceptionHandler &);
|
||||
void operator=(const ExceptionHandler &);
|
||||
explicit ExceptionHandler(const ExceptionHandler&);
|
||||
void operator=(const ExceptionHandler&);
|
||||
|
||||
// Generates a new ID and stores it in next_minidump_id_, and stores the
|
||||
// path of the next minidump to be written in next_minidump_path_.
|
||||
|
@ -152,15 +152,15 @@ class ExceptionHandler {
|
|||
string next_minidump_path_;
|
||||
|
||||
// Pointers to the UTF-8 versions of above
|
||||
const char *dump_path_c_;
|
||||
const char *next_minidump_id_c_;
|
||||
const char *next_minidump_path_c_;
|
||||
const char* dump_path_c_;
|
||||
const char* next_minidump_id_c_;
|
||||
const char* next_minidump_path_c_;
|
||||
|
||||
// The callback function and pointer to be passed back after the minidump
|
||||
// has been written
|
||||
FilterCallback filter_;
|
||||
MinidumpCallback callback_;
|
||||
void *callback_context_;
|
||||
void* callback_context_;
|
||||
|
||||
// The callback function to be passed back when we don't want a minidump
|
||||
// file to be written
|
||||
|
|
|
@ -41,12 +41,12 @@ namespace google_breakpad {
|
|||
|
||||
class IosExceptionMinidumpGenerator : public MinidumpGenerator {
|
||||
public:
|
||||
explicit IosExceptionMinidumpGenerator(NSException *exception);
|
||||
explicit IosExceptionMinidumpGenerator(NSException* exception);
|
||||
virtual ~IosExceptionMinidumpGenerator();
|
||||
|
||||
protected:
|
||||
virtual bool WriteExceptionStream(MDRawDirectory *exception_stream);
|
||||
virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread *thread);
|
||||
virtual bool WriteExceptionStream(MDRawDirectory* exception_stream);
|
||||
virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread* thread);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -57,16 +57,16 @@ class IosExceptionMinidumpGenerator : public MinidumpGenerator {
|
|||
uintptr_t GetLRFromException();
|
||||
|
||||
// Write a virtual thread context for the crashing site.
|
||||
bool WriteCrashingContext(MDLocationDescriptor *register_location);
|
||||
bool WriteCrashingContext(MDLocationDescriptor* register_location);
|
||||
// Per-CPU implementations of the above method.
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
bool WriteCrashingContextARM(MDLocationDescriptor *register_location);
|
||||
bool WriteCrashingContextARM(MDLocationDescriptor* register_location);
|
||||
#endif
|
||||
#ifdef HAS_ARM64_SUPPORT
|
||||
bool WriteCrashingContextARM64(MDLocationDescriptor *register_location);
|
||||
bool WriteCrashingContextARM64(MDLocationDescriptor* register_location);
|
||||
#endif
|
||||
|
||||
NSArray *return_addresses_;
|
||||
NSArray* return_addresses_;
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
|
|
@ -52,7 +52,7 @@ const uintptr_t kExpectedFinalSp = 0;
|
|||
|
||||
// Append the given value to the sp position of the stack represented
|
||||
// by memory.
|
||||
void AppendToMemory(uint8_t *memory, uintptr_t sp, uintptr_t data) {
|
||||
void AppendToMemory(uint8_t* memory, uintptr_t sp, uintptr_t data) {
|
||||
memcpy(memory + sp, &data, sizeof(data));
|
||||
}
|
||||
#endif
|
||||
|
@ -62,7 +62,7 @@ void AppendToMemory(uint8_t *memory, uintptr_t sp, uintptr_t data) {
|
|||
namespace google_breakpad {
|
||||
|
||||
IosExceptionMinidumpGenerator::IosExceptionMinidumpGenerator(
|
||||
NSException *exception)
|
||||
NSException* exception)
|
||||
: MinidumpGenerator(mach_task_self(), 0) {
|
||||
return_addresses_ = [[exception callStackReturnAddresses] retain];
|
||||
SetExceptionInformation(kExceptionType,
|
||||
|
@ -76,7 +76,7 @@ IosExceptionMinidumpGenerator::~IosExceptionMinidumpGenerator() {
|
|||
}
|
||||
|
||||
bool IosExceptionMinidumpGenerator::WriteCrashingContext(
|
||||
MDLocationDescriptor *register_location) {
|
||||
MDLocationDescriptor* register_location) {
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
return WriteCrashingContextARM(register_location);
|
||||
#elif defined(HAS_ARM64_SUPPORT)
|
||||
|
@ -89,12 +89,12 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContext(
|
|||
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
bool IosExceptionMinidumpGenerator::WriteCrashingContextARM(
|
||||
MDLocationDescriptor *register_location) {
|
||||
MDLocationDescriptor* register_location) {
|
||||
TypedMDRVA<MDRawContextARM> context(&writer_);
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
*register_location = context.location();
|
||||
MDRawContextARM *context_ptr = context.get();
|
||||
MDRawContextARM* context_ptr = context.get();
|
||||
memset(context_ptr, 0, sizeof(MDRawContextARM));
|
||||
context_ptr->context_flags = MD_CONTEXT_ARM_FULL;
|
||||
context_ptr->iregs[MD_CONTEXT_ARM_REG_IOS_FP] = kExpectedFinalFp; // FP
|
||||
|
@ -107,12 +107,12 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContextARM(
|
|||
|
||||
#ifdef HAS_ARM64_SUPPORT
|
||||
bool IosExceptionMinidumpGenerator::WriteCrashingContextARM64(
|
||||
MDLocationDescriptor *register_location) {
|
||||
MDLocationDescriptor* register_location) {
|
||||
TypedMDRVA<MDRawContextARM64_Old> context(&writer_);
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
*register_location = context.location();
|
||||
MDRawContextARM64_Old *context_ptr = context.get();
|
||||
MDRawContextARM64_Old* context_ptr = context.get();
|
||||
memset(context_ptr, 0, sizeof(*context_ptr));
|
||||
context_ptr->context_flags = MD_CONTEXT_ARM64_FULL_OLD;
|
||||
context_ptr->iregs[MD_CONTEXT_ARM64_REG_FP] = kExpectedFinalFp; // FP
|
||||
|
@ -132,7 +132,7 @@ uintptr_t IosExceptionMinidumpGenerator::GetLRFromException() {
|
|||
}
|
||||
|
||||
bool IosExceptionMinidumpGenerator::WriteExceptionStream(
|
||||
MDRawDirectory *exception_stream) {
|
||||
MDRawDirectory* exception_stream) {
|
||||
#if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT)
|
||||
TypedMDRVA<MDRawExceptionStream> exception(&writer_);
|
||||
|
||||
|
@ -141,7 +141,7 @@ bool IosExceptionMinidumpGenerator::WriteExceptionStream(
|
|||
|
||||
exception_stream->stream_type = MD_EXCEPTION_STREAM;
|
||||
exception_stream->location = exception.location();
|
||||
MDRawExceptionStream *exception_ptr = exception.get();
|
||||
MDRawExceptionStream* exception_ptr = exception.get();
|
||||
exception_ptr->thread_id = pthread_mach_thread_np(pthread_self());
|
||||
|
||||
// This naming is confusing, but it is the proper translation from
|
||||
|
@ -160,7 +160,7 @@ bool IosExceptionMinidumpGenerator::WriteExceptionStream(
|
|||
}
|
||||
|
||||
bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id,
|
||||
MDRawThread *thread) {
|
||||
MDRawThread* thread) {
|
||||
#if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT)
|
||||
if (pthread_mach_thread_np(pthread_self()) != thread_id)
|
||||
return MinidumpGenerator::WriteThreadStream(thread_id, thread);
|
||||
|
|
|
@ -229,7 +229,7 @@ CrashGenerationServer::ClientEvent(short revents)
|
|||
// Walk the control payload and extract the file descriptor and validated pid.
|
||||
pid_t crashing_pid = -1;
|
||||
int signal_fd = -1;
|
||||
for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr;
|
||||
for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr;
|
||||
hdr = CMSG_NXTHDR(&msg, hdr)) {
|
||||
if (hdr->cmsg_level != SOL_SOCKET)
|
||||
continue;
|
||||
|
@ -248,7 +248,7 @@ CrashGenerationServer::ClientEvent(short revents)
|
|||
signal_fd = reinterpret_cast<int*>(CMSG_DATA(hdr))[0];
|
||||
}
|
||||
} else if (hdr->cmsg_type == SCM_CREDENTIALS) {
|
||||
const struct ucred *cred =
|
||||
const struct ucred* cred =
|
||||
reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
|
||||
crashing_pid = cred->pid;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ CrashGenerationServer::MakeMinidumpFilename(string& outFilename)
|
|||
|
||||
// static
|
||||
void*
|
||||
CrashGenerationServer::ThreadMain(void *arg)
|
||||
CrashGenerationServer::ThreadMain(void* arg)
|
||||
{
|
||||
reinterpret_cast<CrashGenerationServer*>(arg)->Run();
|
||||
return NULL;
|
||||
|
|
|
@ -48,7 +48,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
|
|||
return uc->uc_mcontext.gregs[REG_EIP];
|
||||
}
|
||||
|
||||
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
|
||||
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
|
||||
const fpstate_t* fp) {
|
||||
const greg_t* regs = uc->uc_mcontext.gregs;
|
||||
|
||||
|
@ -96,7 +96,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
|
|||
return uc->uc_mcontext.gregs[REG_RIP];
|
||||
}
|
||||
|
||||
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
|
||||
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
|
||||
const fpstate_t* fpregs) {
|
||||
const greg_t* regs = uc->uc_mcontext.gregs;
|
||||
|
||||
|
@ -153,7 +153,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
|
|||
return uc->uc_mcontext.arm_pc;
|
||||
}
|
||||
|
||||
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
|
||||
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc) {
|
||||
out->context_flags = MD_CONTEXT_ARM_FULL;
|
||||
|
||||
out->iregs[0] = uc->uc_mcontext.arm_r0;
|
||||
|
@ -192,7 +192,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
|
|||
return uc->uc_mcontext.pc;
|
||||
}
|
||||
|
||||
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
|
||||
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
|
||||
const struct fpsimd_context* fpregs) {
|
||||
out->context_flags = MD_CONTEXT_ARM64_FULL_OLD;
|
||||
|
||||
|
@ -218,7 +218,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
|
|||
return uc->uc_mcontext.pc;
|
||||
}
|
||||
|
||||
void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
|
||||
void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc) {
|
||||
#if _MIPS_SIM == _ABI64
|
||||
out->context_flags = MD_CONTEXT_MIPS64_FULL;
|
||||
#elif _MIPS_SIM == _ABIO32
|
||||
|
|
|
@ -50,13 +50,13 @@ struct UContextReader {
|
|||
// out: the minidump structure
|
||||
// info: the collection of register structures.
|
||||
#if defined(__i386__) || defined(__x86_64)
|
||||
static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
|
||||
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
|
||||
const fpstate_t* fp);
|
||||
#elif defined(__aarch64__)
|
||||
static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
|
||||
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
|
||||
const struct fpsimd_context* fpregs);
|
||||
#else
|
||||
static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc);
|
||||
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -419,8 +419,8 @@ struct ThreadArgument {
|
|||
// This is the entry function for the cloned process. We are in a compromised
|
||||
// context here: see the top of the file.
|
||||
// static
|
||||
int ExceptionHandler::ThreadEntry(void *arg) {
|
||||
const ThreadArgument *thread_arg = reinterpret_cast<ThreadArgument*>(arg);
|
||||
int ExceptionHandler::ThreadEntry(void* arg) {
|
||||
const ThreadArgument* thread_arg = reinterpret_cast<ThreadArgument*>(arg);
|
||||
|
||||
// Close the write end of the pipe. This allows us to fail if the parent dies
|
||||
// while waiting for the continue signal.
|
||||
|
@ -495,7 +495,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) {
|
|||
}
|
||||
|
||||
// This function may run in a compromised context: see the top of the file.
|
||||
bool ExceptionHandler::GenerateDump(CrashContext *context) {
|
||||
bool ExceptionHandler::GenerateDump(CrashContext* context) {
|
||||
if (IsOutOfProcess())
|
||||
return crash_generation_client_->RequestDump(context, sizeof(*context));
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class ExceptionHandler {
|
|||
// attempting to write a minidump. If a FilterCallback returns false,
|
||||
// Breakpad will immediately report the exception as unhandled without
|
||||
// writing a minidump, allowing another handler the opportunity to handle it.
|
||||
typedef bool (*FilterCallback)(void *context);
|
||||
typedef bool (*FilterCallback)(void* context);
|
||||
|
||||
// A callback function to run after the minidump has been written.
|
||||
// |descriptor| contains the file descriptor or file path containing the
|
||||
|
@ -234,7 +234,7 @@ class ExceptionHandler {
|
|||
static void RestoreHandlersLocked();
|
||||
|
||||
void PreresolveSymbols();
|
||||
bool GenerateDump(CrashContext *context);
|
||||
bool GenerateDump(CrashContext* context);
|
||||
void SendContinueSignalToChild();
|
||||
void WaitForContinueSignal();
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ static bool DoneCallback(const MinidumpDescriptor& descriptor,
|
|||
// optimize them out. In the case of ExceptionHandlerTest::ExternalDumper,
|
||||
// GCC-4.9 optimized out the entire set up of ExceptionHandler, causing
|
||||
// test failure.
|
||||
volatile int *p_null; // external linkage, so GCC can't tell that it
|
||||
volatile int* p_null; // external linkage, so GCC can't tell that it
|
||||
// remains NULL. Volatile just for a good measure.
|
||||
static void DoNullPointerDereference() {
|
||||
*p_null = 1;
|
||||
|
@ -994,7 +994,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size,
|
|||
msg.msg_control = cmsg;
|
||||
msg.msg_controllen = sizeof(cmsg);
|
||||
|
||||
struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
|
||||
struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg);
|
||||
hdr->cmsg_level = SOL_SOCKET;
|
||||
hdr->cmsg_type = SCM_RIGHTS;
|
||||
hdr->cmsg_len = CMSG_LEN(sizeof(int));
|
||||
|
@ -1003,7 +1003,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size,
|
|||
hdr->cmsg_level = SOL_SOCKET;
|
||||
hdr->cmsg_type = SCM_CREDENTIALS;
|
||||
hdr->cmsg_len = CMSG_LEN(sizeof(struct ucred));
|
||||
struct ucred *cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
|
||||
struct ucred* cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
|
||||
cred->uid = getuid();
|
||||
cred->gid = getgid();
|
||||
cred->pid = getpid();
|
||||
|
@ -1056,7 +1056,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) {
|
|||
|
||||
pid_t crashing_pid = -1;
|
||||
int signal_fd = -1;
|
||||
for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr;
|
||||
for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr;
|
||||
hdr = CMSG_NXTHDR(&msg, hdr)) {
|
||||
if (hdr->cmsg_level != SOL_SOCKET)
|
||||
continue;
|
||||
|
@ -1066,7 +1066,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) {
|
|||
ASSERT_EQ(sizeof(int), len);
|
||||
signal_fd = *(reinterpret_cast<int*>(CMSG_DATA(hdr)));
|
||||
} else if (hdr->cmsg_type == SCM_CREDENTIALS) {
|
||||
const struct ucred *cred =
|
||||
const struct ucred* cred =
|
||||
reinterpret_cast<struct ucred*>(CMSG_DATA(hdr));
|
||||
crashing_pid = cred->pid;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace {
|
|||
// __android_log_buf_write() is not exported in the NDK and is being used by
|
||||
// dynamic runtime linking. Its declaration is taken from Android's
|
||||
// system/core/include/log/log.h.
|
||||
using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char *tag,
|
||||
const char *text);
|
||||
using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char* tag,
|
||||
const char* text);
|
||||
const int kAndroidCrashLogId = 4; // From LOG_ID_CRASH in log.h.
|
||||
const char kAndroidLogTag[] = "google-breakpad";
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef testing::Test DirectoryReaderTest;
|
|||
TEST(DirectoryReaderTest, CompareResults) {
|
||||
std::set<string> dent_set;
|
||||
|
||||
DIR *const dir = opendir("/proc/self");
|
||||
DIR* const dir = opendir("/proc/self");
|
||||
ASSERT_TRUE(dir != NULL);
|
||||
|
||||
struct dirent* dent;
|
||||
|
|
|
@ -61,7 +61,7 @@ class LineReader {
|
|||
//
|
||||
// One must call |PopLine| after this function, otherwise you'll continue to
|
||||
// get the same line over and over.
|
||||
bool GetNextLine(const char **line, unsigned *len) {
|
||||
bool GetNextLine(const char** line, unsigned* len) {
|
||||
for (;;) {
|
||||
if (buf_used_ == 0 && hit_eof_)
|
||||
return false;
|
||||
|
|
|
@ -59,7 +59,7 @@ TEST(LineReaderTest, EmptyFile) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned len;
|
||||
ASSERT_FALSE(reader.GetNextLine(&line, &len));
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ TEST(LineReaderTest, OneLineTerminated) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned int len;
|
||||
ASSERT_TRUE(reader.GetNextLine(&line, &len));
|
||||
ASSERT_EQ((unsigned int)1, len);
|
||||
|
@ -85,7 +85,7 @@ TEST(LineReaderTest, OneLine) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned len;
|
||||
ASSERT_TRUE(reader.GetNextLine(&line, &len));
|
||||
ASSERT_EQ((unsigned)1, len);
|
||||
|
@ -101,7 +101,7 @@ TEST(LineReaderTest, TwoLinesTerminated) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned len;
|
||||
ASSERT_TRUE(reader.GetNextLine(&line, &len));
|
||||
ASSERT_EQ((unsigned)1, len);
|
||||
|
@ -123,7 +123,7 @@ TEST(LineReaderTest, TwoLines) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned len;
|
||||
ASSERT_TRUE(reader.GetNextLine(&line, &len));
|
||||
ASSERT_EQ((unsigned)1, len);
|
||||
|
@ -147,7 +147,7 @@ TEST(LineReaderTest, MaxLength) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned len;
|
||||
ASSERT_TRUE(reader.GetNextLine(&line, &len));
|
||||
ASSERT_EQ(sizeof(l), len);
|
||||
|
@ -163,7 +163,7 @@ TEST(LineReaderTest, TooLong) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
LineReader reader(file.GetFd());
|
||||
|
||||
const char *line;
|
||||
const char* line;
|
||||
unsigned len;
|
||||
ASSERT_FALSE(reader.GetNextLine(&line, &len));
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ const size_t kHpageMask = (~(kHpageSize - 1));
|
|||
// next is backed by some file.
|
||||
// curr and next are contiguous.
|
||||
// offset(next) == sizeof(curr)
|
||||
void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) {
|
||||
void TryRecoverMappings(MappingInfo* curr, MappingInfo* next) {
|
||||
// Merged segments are marked with size = 0.
|
||||
if (curr->size == 0 || next->size == 0)
|
||||
return;
|
||||
|
@ -167,8 +167,8 @@ void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) {
|
|||
// next and prev are backed by the same file.
|
||||
// prev, curr and next are contiguous.
|
||||
// offset(next) == offset(prev) + sizeof(prev) + sizeof(curr)
|
||||
void TryRecoverMappings(MappingInfo *prev, MappingInfo *curr,
|
||||
MappingInfo *next) {
|
||||
void TryRecoverMappings(MappingInfo* prev, MappingInfo* curr,
|
||||
MappingInfo* next) {
|
||||
// Merged segments are marked with size = 0.
|
||||
if (prev->size == 0 || curr->size == 0 || next->size == 0)
|
||||
return;
|
||||
|
@ -551,11 +551,11 @@ bool LinuxDumper::EnumerateMappings() {
|
|||
// See http://www.trilithium.com/johan/2005/08/linux-gate/ for more
|
||||
// information.
|
||||
const void* linux_gate_loc =
|
||||
reinterpret_cast<void *>(auxv_[AT_SYSINFO_EHDR]);
|
||||
reinterpret_cast<void*>(auxv_[AT_SYSINFO_EHDR]);
|
||||
// Although the initial executable is usually the first mapping, it's not
|
||||
// guaranteed (see http://crosbug.com/25355); therefore, try to use the
|
||||
// actual entry point to find the mapping.
|
||||
const void* entry_point_loc = reinterpret_cast<void *>(auxv_[AT_ENTRY]);
|
||||
const void* entry_point_loc = reinterpret_cast<void*>(auxv_[AT_ENTRY]);
|
||||
|
||||
const int fd = sys_open(maps_path, O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
|
|
|
@ -110,8 +110,8 @@ class LinuxDumper {
|
|||
}
|
||||
|
||||
// These are only valid after a call to |Init|.
|
||||
const wasteful_vector<pid_t> &threads() { return threads_; }
|
||||
const wasteful_vector<MappingInfo*> &mappings() { return mappings_; }
|
||||
const wasteful_vector<pid_t>& threads() { return threads_; }
|
||||
const wasteful_vector<MappingInfo*>& mappings() { return mappings_; }
|
||||
const MappingInfo* FindMapping(const void* address) const;
|
||||
// Find the mapping which the given memory address falls in. Unlike
|
||||
// FindMapping, this method uses the unadjusted mapping address
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
#error This test has not been ported to this platform.
|
||||
#endif
|
||||
|
||||
void *thread_function(void *data) {
|
||||
int pipefd = *static_cast<int *>(data);
|
||||
void* thread_function(void* data) {
|
||||
int pipefd = *static_cast<int*>(data);
|
||||
volatile pid_t* thread_id = new pid_t;
|
||||
*thread_id = syscall(__NR_gettid);
|
||||
// Signal parent that a thread has started.
|
||||
|
@ -65,13 +65,13 @@ void *thread_function(void *data) {
|
|||
perror("ERROR: parent notification failed");
|
||||
return NULL;
|
||||
}
|
||||
register volatile pid_t *thread_id_ptr asm(TID_PTR_REGISTER) = thread_id;
|
||||
register volatile pid_t* thread_id_ptr asm(TID_PTR_REGISTER) = thread_id;
|
||||
while (true)
|
||||
asm volatile ("" : : "r" (thread_id_ptr));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc < 3) {
|
||||
fprintf(stderr,
|
||||
"usage: linux_dumper_unittest_helper <pipe fd> <# of threads>\n");
|
||||
|
|
|
@ -337,7 +337,7 @@ TEST_F(LinuxPtraceDumperChildTest, MappingsIncludeLinuxGate) {
|
|||
ASSERT_TRUE(dumper.Init());
|
||||
|
||||
void* linux_gate_loc =
|
||||
reinterpret_cast<void *>(dumper.auxv()[AT_SYSINFO_EHDR]);
|
||||
reinterpret_cast<void*>(dumper.auxv()[AT_SYSINFO_EHDR]);
|
||||
ASSERT_TRUE(linux_gate_loc);
|
||||
bool found_linux_gate = false;
|
||||
|
||||
|
|
|
@ -740,14 +740,14 @@ class MinidumpWriter {
|
|||
}
|
||||
|
||||
bool WriteDSODebugStream(MDRawDirectory* dirent) {
|
||||
ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr) *>(dumper_->auxv()[AT_PHDR]);
|
||||
ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(dumper_->auxv()[AT_PHDR]);
|
||||
char* base;
|
||||
int phnum = dumper_->auxv()[AT_PHNUM];
|
||||
if (!phnum || !phdr)
|
||||
return false;
|
||||
|
||||
// Assume the program base is at the beginning of the same page as the PHDR
|
||||
base = reinterpret_cast<char *>(reinterpret_cast<uintptr_t>(phdr) & ~0xfff);
|
||||
base = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(phdr) & ~0xfff);
|
||||
|
||||
// Search for the program PT_DYNAMIC segment
|
||||
ElfW(Addr) dyn_addr = 0;
|
||||
|
@ -768,7 +768,7 @@ class MinidumpWriter {
|
|||
if (!dyn_addr)
|
||||
return false;
|
||||
|
||||
ElfW(Dyn) *dynamic = reinterpret_cast<ElfW(Dyn) *>(dyn_addr + base);
|
||||
ElfW(Dyn)* dynamic = reinterpret_cast<ElfW(Dyn)*>(dyn_addr + base);
|
||||
|
||||
// The dynamic linker makes information available that helps gdb find all
|
||||
// DSOs loaded into the program. If this information is indeed available,
|
||||
|
@ -1222,7 +1222,7 @@ class MinidumpWriter {
|
|||
Buffers* next;
|
||||
size_t len;
|
||||
uint8_t data[kBufSize];
|
||||
} *buffers = reinterpret_cast<Buffers*>(Alloc(sizeof(Buffers)));
|
||||
}* buffers = reinterpret_cast<Buffers*>(Alloc(sizeof(Buffers)));
|
||||
buffers->next = NULL;
|
||||
buffers->len = 0;
|
||||
|
||||
|
|
|
@ -299,10 +299,10 @@ TEST(MinidumpWriterTest, MinidumpStacksSkippedIfRequested) {
|
|||
Minidump minidump(templ);
|
||||
ASSERT_TRUE(minidump.Read());
|
||||
|
||||
MinidumpThreadList *threads = minidump.GetThreadList();
|
||||
MinidumpThreadList* threads = minidump.GetThreadList();
|
||||
int threads_with_stacks = 0;
|
||||
for (unsigned int i = 0; i < threads->thread_count(); ++i) {
|
||||
MinidumpThread *thread = threads->GetThreadAtIndex(i);
|
||||
MinidumpThread* thread = threads->GetThreadAtIndex(i);
|
||||
if (thread->GetMemory()) {
|
||||
++threads_with_stacks;
|
||||
}
|
||||
|
@ -353,13 +353,13 @@ TEST(MinidumpWriterTest, StacksAreSanitizedIfRequested) {
|
|||
#else
|
||||
0x0defaced;
|
||||
#endif
|
||||
MinidumpThreadList *threads = minidump.GetThreadList();
|
||||
MinidumpThreadList* threads = minidump.GetThreadList();
|
||||
for (unsigned int i = 0; i < threads->thread_count(); ++i) {
|
||||
MinidumpThread *thread = threads->GetThreadAtIndex(i);
|
||||
MinidumpMemoryRegion *mem = thread->GetMemory();
|
||||
MinidumpThread* thread = threads->GetThreadAtIndex(i);
|
||||
MinidumpMemoryRegion* mem = thread->GetMemory();
|
||||
ASSERT_TRUE(mem != nullptr);
|
||||
uint32_t sz = mem->GetSize();
|
||||
const uint8_t *data = mem->GetMemory();
|
||||
const uint8_t* data = mem->GetMemory();
|
||||
ASSERT_TRUE(memmem(data, sz, &defaced, sizeof(defaced)) != nullptr);
|
||||
}
|
||||
close(fds[1]);
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace google_breakpad {
|
|||
|
||||
string GetHelperBinary() {
|
||||
string helper_path;
|
||||
char *bindir = getenv("bindir");
|
||||
char* bindir = getenv("bindir");
|
||||
if (bindir) {
|
||||
helper_path = string(bindir) + "/";
|
||||
} else {
|
||||
|
|
|
@ -65,7 +65,7 @@ TEST(ProcCpuInfoReaderTest, EmptyFile) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
ProcCpuInfoReader reader(file.GetFd());
|
||||
|
||||
const char *field;
|
||||
const char* field;
|
||||
ASSERT_FALSE(reader.GetNextField(&field));
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ TEST(ProcCpuInfoReaderTest, OneLineTerminated) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
ProcCpuInfoReader reader(file.GetFd());
|
||||
|
||||
const char *field;
|
||||
const char* field;
|
||||
ASSERT_TRUE(reader.GetNextField(&field));
|
||||
ASSERT_STREQ("foo", field);
|
||||
ASSERT_STREQ("bar", reader.GetValue());
|
||||
|
@ -87,7 +87,7 @@ TEST(ProcCpuInfoReaderTest, OneLine) {
|
|||
ASSERT_TRUE(file.IsOk());
|
||||
ProcCpuInfoReader reader(file.GetFd());
|
||||
|
||||
const char *field;
|
||||
const char* field;
|
||||
size_t value_len;
|
||||
ASSERT_TRUE(reader.GetNextField(&field));
|
||||
ASSERT_STREQ("foo", field);
|
||||
|
|
|
@ -84,7 +84,7 @@ bool CheckForRequiredFlagsOrDie() {
|
|||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
if (!CheckForRequiredFlagsOrDie()) {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
// OnDemandServer and restored in Inspector.
|
||||
#define BREAKPAD_BOOTSTRAP_PARENT_PORT "com.Breakpad.BootstrapParent"
|
||||
|
||||
typedef void *BreakpadRef;
|
||||
typedef void* BreakpadRef;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -65,7 +65,7 @@ extern "C" {
|
|||
typedef bool (*BreakpadFilterCallback)(int exception_type,
|
||||
int exception_code,
|
||||
mach_port_t crashing_thread,
|
||||
void *context);
|
||||
void* context);
|
||||
|
||||
// Create a new BreakpadRef object and install it as an exception
|
||||
// handler. The |parameters| will typically be the contents of your
|
||||
|
@ -226,7 +226,7 @@ typedef bool (*BreakpadFilterCallback)(int exception_type,
|
|||
// Only used in crash_report_sender.
|
||||
|
||||
// Returns a new BreakpadRef object on success, NULL otherwise.
|
||||
BreakpadRef BreakpadCreate(NSDictionary *parameters);
|
||||
BreakpadRef BreakpadCreate(NSDictionary* parameters);
|
||||
|
||||
// Uninstall and release the data associated with |ref|.
|
||||
void BreakpadRelease(BreakpadRef ref);
|
||||
|
@ -238,7 +238,7 @@ void BreakpadRelease(BreakpadRef ref);
|
|||
// Context is a pointer to arbitrary data to make the callback with.
|
||||
void BreakpadSetFilterCallback(BreakpadRef ref,
|
||||
BreakpadFilterCallback callback,
|
||||
void *context);
|
||||
void* context);
|
||||
|
||||
// User defined key and value string storage. Generally this is used
|
||||
// to configure Breakpad's internal operation, such as whether the
|
||||
|
@ -259,23 +259,23 @@ void BreakpadSetFilterCallback(BreakpadRef ref,
|
|||
// TODO (nealsid): separate server parameter dictionary from the
|
||||
// dictionary used to configure Breakpad, and document limits for each
|
||||
// independently.
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value);
|
||||
NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key);
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key);
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value);
|
||||
NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key);
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key);
|
||||
|
||||
// You can use this method to specify parameters that will be uploaded
|
||||
// to the crash server. They will be automatically encoded as
|
||||
// necessary. Note that as mentioned above there are limits on both
|
||||
// the number of keys and their length.
|
||||
void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key,
|
||||
NSString *value);
|
||||
void BreakpadAddUploadParameter(BreakpadRef ref, NSString* key,
|
||||
NSString* value);
|
||||
|
||||
// This method will remove a previously-added parameter from the
|
||||
// upload parameter set.
|
||||
void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key);
|
||||
void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString* key);
|
||||
|
||||
// Add a log file for Breakpad to read and send upon crash dump
|
||||
void BreakpadAddLogFile(BreakpadRef ref, NSString *logPathname);
|
||||
void BreakpadAddLogFile(BreakpadRef ref, NSString* logPathname);
|
||||
|
||||
// Generate a minidump and send
|
||||
void BreakpadGenerateAndSendReport(BreakpadRef ref);
|
||||
|
|
|
@ -81,9 +81,9 @@ using google_breakpad::SimpleStringDictionary;
|
|||
// allocation of C++ objects. Note that we don't use operator delete()
|
||||
// but instead call the objects destructor directly: object->~ClassName();
|
||||
//
|
||||
ProtectedMemoryAllocator *gMasterAllocator = NULL;
|
||||
ProtectedMemoryAllocator *gKeyValueAllocator = NULL;
|
||||
ProtectedMemoryAllocator *gBreakpadAllocator = NULL;
|
||||
ProtectedMemoryAllocator* gMasterAllocator = NULL;
|
||||
ProtectedMemoryAllocator* gKeyValueAllocator = NULL;
|
||||
ProtectedMemoryAllocator* gBreakpadAllocator = NULL;
|
||||
|
||||
// Mutex for thread-safe access to the key/value dictionary used by breakpad.
|
||||
// It's a global instead of an instance variable of Breakpad
|
||||
|
@ -98,8 +98,8 @@ pthread_mutex_t gDictionaryMutex;
|
|||
// Its destructor will first re-protect the memory then release the lock.
|
||||
class ProtectedMemoryLocker {
|
||||
public:
|
||||
ProtectedMemoryLocker(pthread_mutex_t *mutex,
|
||||
ProtectedMemoryAllocator *allocator)
|
||||
ProtectedMemoryLocker(pthread_mutex_t* mutex,
|
||||
ProtectedMemoryAllocator* allocator)
|
||||
: mutex_(mutex),
|
||||
allocator_(allocator) {
|
||||
// Lock the mutex
|
||||
|
@ -124,17 +124,17 @@ class ProtectedMemoryLocker {
|
|||
ProtectedMemoryLocker(const ProtectedMemoryLocker&);
|
||||
ProtectedMemoryLocker& operator=(const ProtectedMemoryLocker&);
|
||||
|
||||
pthread_mutex_t *mutex_;
|
||||
ProtectedMemoryAllocator *allocator_;
|
||||
pthread_mutex_t* mutex_;
|
||||
ProtectedMemoryAllocator* allocator_;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
class Breakpad {
|
||||
public:
|
||||
// factory method
|
||||
static Breakpad *Create(NSDictionary *parameters) {
|
||||
static Breakpad* Create(NSDictionary* parameters) {
|
||||
// Allocate from our special allocation pool
|
||||
Breakpad *breakpad =
|
||||
Breakpad* breakpad =
|
||||
new (gBreakpadAllocator->Allocate(sizeof(Breakpad)))
|
||||
Breakpad();
|
||||
|
||||
|
@ -152,13 +152,13 @@ class Breakpad {
|
|||
|
||||
~Breakpad();
|
||||
|
||||
void SetKeyValue(NSString *key, NSString *value);
|
||||
NSString *KeyValue(NSString *key);
|
||||
void RemoveKeyValue(NSString *key);
|
||||
void SetKeyValue(NSString* key, NSString* value);
|
||||
NSString* KeyValue(NSString* key);
|
||||
void RemoveKeyValue(NSString* key);
|
||||
|
||||
void GenerateAndSendReport();
|
||||
|
||||
void SetFilterCallback(BreakpadFilterCallback callback, void *context) {
|
||||
void SetFilterCallback(BreakpadFilterCallback callback, void* context) {
|
||||
filter_callback_ = callback;
|
||||
filter_callback_context_ = context;
|
||||
}
|
||||
|
@ -173,14 +173,14 @@ class Breakpad {
|
|||
inspector_path_[0] = 0;
|
||||
}
|
||||
|
||||
bool Initialize(NSDictionary *parameters);
|
||||
bool InitializeInProcess(NSDictionary *parameters);
|
||||
bool InitializeOutOfProcess(NSDictionary *parameters);
|
||||
bool Initialize(NSDictionary* parameters);
|
||||
bool InitializeInProcess(NSDictionary* parameters);
|
||||
bool InitializeOutOfProcess(NSDictionary* parameters);
|
||||
|
||||
bool ExtractParameters(NSDictionary *parameters);
|
||||
bool ExtractParameters(NSDictionary* parameters);
|
||||
|
||||
// Dispatches to HandleException()
|
||||
static bool ExceptionHandlerDirectCallback(void *context,
|
||||
static bool ExceptionHandlerDirectCallback(void* context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
|
@ -194,28 +194,28 @@ class Breakpad {
|
|||
// Dispatches to HandleMinidump().
|
||||
// This gets called instead of ExceptionHandlerDirectCallback when running
|
||||
// with the BREAKPAD_IN_PROCESS option.
|
||||
static bool HandleMinidumpCallback(const char *dump_dir,
|
||||
const char *minidump_id,
|
||||
void *context,
|
||||
static bool HandleMinidumpCallback(const char* dump_dir,
|
||||
const char* minidump_id,
|
||||
void* context,
|
||||
bool succeeded);
|
||||
|
||||
// This is only used when BREAKPAD_IN_PROCESS is YES.
|
||||
bool HandleMinidump(const char *dump_dir, const char *minidump_id);
|
||||
bool HandleMinidump(const char* dump_dir, const char* minidump_id);
|
||||
|
||||
// Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's
|
||||
// MachineExceptions.h, we have to explicitly name the handler.
|
||||
google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG)
|
||||
google_breakpad::ExceptionHandler* handler_; // The actual handler (STRONG)
|
||||
|
||||
char inspector_path_[PATH_MAX]; // Path to inspector tool
|
||||
|
||||
SimpleStringDictionary *config_params_; // Create parameters (STRONG)
|
||||
SimpleStringDictionary* config_params_; // Create parameters (STRONG)
|
||||
|
||||
OnDemandServer inspector_;
|
||||
|
||||
bool send_and_exit_; // Exit after sending, if true
|
||||
|
||||
BreakpadFilterCallback filter_callback_;
|
||||
void *filter_callback_context_;
|
||||
void* filter_callback_context_;
|
||||
};
|
||||
|
||||
#pragma mark -
|
||||
|
@ -227,14 +227,14 @@ class Breakpad {
|
|||
//=============================================================================
|
||||
static BOOL IsDebuggerActive() {
|
||||
BOOL result = NO;
|
||||
NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// We check both defaults and the environment variable here
|
||||
|
||||
BOOL ignoreDebugger = [stdDefaults boolForKey:@IGNORE_DEBUGGER];
|
||||
|
||||
if (!ignoreDebugger) {
|
||||
char *ignoreDebuggerStr = getenv(IGNORE_DEBUGGER);
|
||||
char* ignoreDebuggerStr = getenv(IGNORE_DEBUGGER);
|
||||
ignoreDebugger = (ignoreDebuggerStr ? strtol(ignoreDebuggerStr, NULL, 10) : 0) != 0;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ static BOOL IsDebuggerActive() {
|
|||
size_t actualSize;
|
||||
|
||||
if (sysctl(mib, mibSize, NULL, &actualSize, NULL, 0) == 0) {
|
||||
struct kinfo_proc *info = (struct kinfo_proc *)malloc(actualSize);
|
||||
struct kinfo_proc* info = (struct kinfo_proc*)malloc(actualSize);
|
||||
|
||||
if (info) {
|
||||
// This comes from looking at the Darwin xnu Kernel
|
||||
|
@ -261,12 +261,12 @@ static BOOL IsDebuggerActive() {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::ExceptionHandlerDirectCallback(void *context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
mach_port_t crashing_thread) {
|
||||
Breakpad *breakpad = (Breakpad *)context;
|
||||
bool Breakpad::ExceptionHandlerDirectCallback(void* context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
mach_port_t crashing_thread) {
|
||||
Breakpad* breakpad = (Breakpad*)context;
|
||||
|
||||
// If our context is damaged or something, just return false to indicate that
|
||||
// the handler should continue without us.
|
||||
|
@ -280,11 +280,11 @@ bool Breakpad::ExceptionHandlerDirectCallback(void *context,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::HandleMinidumpCallback(const char *dump_dir,
|
||||
const char *minidump_id,
|
||||
void *context,
|
||||
bool Breakpad::HandleMinidumpCallback(const char* dump_dir,
|
||||
const char* minidump_id,
|
||||
void* context,
|
||||
bool succeeded) {
|
||||
Breakpad *breakpad = (Breakpad *)context;
|
||||
Breakpad* breakpad = (Breakpad*)context;
|
||||
|
||||
// If our context is damaged or something, just return false to indicate that
|
||||
// the handler should continue without us.
|
||||
|
@ -307,9 +307,9 @@ bool Breakpad::HandleMinidumpCallback(const char *dump_dir,
|
|||
// simple non-static C name
|
||||
//
|
||||
extern "C" {
|
||||
NSString * GetResourcePath();
|
||||
NSString * GetResourcePath() {
|
||||
NSString *resourcePath = nil;
|
||||
NSString* GetResourcePath();
|
||||
NSString* GetResourcePath() {
|
||||
NSString* resourcePath = nil;
|
||||
|
||||
// If there are multiple breakpads installed then calling bundleWithIdentifier
|
||||
// will not work properly, so only use that as a backup plan.
|
||||
|
@ -320,17 +320,17 @@ NSString * GetResourcePath() {
|
|||
// Get the pathname to the code which contains this function
|
||||
Dl_info info;
|
||||
if (dladdr((const void*)GetResourcePath, &info) != 0) {
|
||||
NSFileManager *filemgr = [NSFileManager defaultManager];
|
||||
NSString *filePath =
|
||||
NSFileManager* filemgr = [NSFileManager defaultManager];
|
||||
NSString* filePath =
|
||||
[filemgr stringWithFileSystemRepresentation:info.dli_fname
|
||||
length:strlen(info.dli_fname)];
|
||||
NSString *bundlePath = [filePath stringByDeletingLastPathComponent];
|
||||
NSString* bundlePath = [filePath stringByDeletingLastPathComponent];
|
||||
// The "Resources" directory should be in the same directory as the
|
||||
// executable code, since that's how the Breakpad framework is built.
|
||||
resourcePath = [bundlePath stringByAppendingPathComponent:@"Resources/"];
|
||||
} else {
|
||||
// fallback plan
|
||||
NSBundle *bundle =
|
||||
NSBundle* bundle =
|
||||
[NSBundle bundleWithIdentifier:@"com.Google.BreakpadFramework"];
|
||||
resourcePath = [bundle resourcePath];
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ NSString * GetResourcePath() {
|
|||
} // extern "C"
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::Initialize(NSDictionary *parameters) {
|
||||
bool Breakpad::Initialize(NSDictionary* parameters) {
|
||||
// Initialize
|
||||
config_params_ = NULL;
|
||||
handler_ = NULL;
|
||||
|
@ -375,7 +375,7 @@ bool Breakpad::InitializeInProcess(NSDictionary* parameters) {
|
|||
//=============================================================================
|
||||
bool Breakpad::InitializeOutOfProcess(NSDictionary* parameters) {
|
||||
// Get path to Inspector executable.
|
||||
NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION);
|
||||
NSString* inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION);
|
||||
|
||||
// Standardize path (resolve symlinkes, etc.) and escape spaces
|
||||
inspectorPathString = [inspectorPathString stringByStandardizingPath];
|
||||
|
@ -434,34 +434,34 @@ Breakpad::~Breakpad() {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
||||
NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString *skipConfirm = [stdDefaults stringForKey:@BREAKPAD_SKIP_CONFIRM];
|
||||
NSString *sendAndExit = [stdDefaults stringForKey:@BREAKPAD_SEND_AND_EXIT];
|
||||
bool Breakpad::ExtractParameters(NSDictionary* parameters) {
|
||||
NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString* skipConfirm = [stdDefaults stringForKey:@BREAKPAD_SKIP_CONFIRM];
|
||||
NSString* sendAndExit = [stdDefaults stringForKey:@BREAKPAD_SEND_AND_EXIT];
|
||||
|
||||
NSString *serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE];
|
||||
NSString *display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY];
|
||||
NSString *product = [parameters objectForKey:@BREAKPAD_PRODUCT];
|
||||
NSString *version = [parameters objectForKey:@BREAKPAD_VERSION];
|
||||
NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL];
|
||||
NSString *interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL];
|
||||
NSString *inspectorPathString =
|
||||
NSString* serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE];
|
||||
NSString* display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY];
|
||||
NSString* product = [parameters objectForKey:@BREAKPAD_PRODUCT];
|
||||
NSString* version = [parameters objectForKey:@BREAKPAD_VERSION];
|
||||
NSString* urlStr = [parameters objectForKey:@BREAKPAD_URL];
|
||||
NSString* interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL];
|
||||
NSString* inspectorPathString =
|
||||
[parameters objectForKey:@BREAKPAD_INSPECTOR_LOCATION];
|
||||
NSString *reporterPathString =
|
||||
NSString* reporterPathString =
|
||||
[parameters objectForKey:@BREAKPAD_REPORTER_EXE_LOCATION];
|
||||
NSString *timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT];
|
||||
NSArray *logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES];
|
||||
NSString *logFileTailSize =
|
||||
NSString* timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT];
|
||||
NSArray* logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES];
|
||||
NSString* logFileTailSize =
|
||||
[parameters objectForKey:@BREAKPAD_LOGFILE_UPLOAD_SIZE];
|
||||
NSString *requestUserText =
|
||||
NSString* requestUserText =
|
||||
[parameters objectForKey:@BREAKPAD_REQUEST_COMMENTS];
|
||||
NSString *requestEmail = [parameters objectForKey:@BREAKPAD_REQUEST_EMAIL];
|
||||
NSString *vendor =
|
||||
NSString* requestEmail = [parameters objectForKey:@BREAKPAD_REQUEST_EMAIL];
|
||||
NSString* vendor =
|
||||
[parameters objectForKey:@BREAKPAD_VENDOR];
|
||||
NSString *dumpSubdirectory =
|
||||
NSString* dumpSubdirectory =
|
||||
[parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY];
|
||||
|
||||
NSDictionary *serverParameters =
|
||||
NSDictionary* serverParameters =
|
||||
[parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT];
|
||||
|
||||
// These may have been set above as user prefs, which take priority.
|
||||
|
@ -536,7 +536,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
}
|
||||
|
||||
// Find the helper applications if not specified in user config.
|
||||
NSString *resourcePath = nil;
|
||||
NSString* resourcePath = nil;
|
||||
if (!inspectorPathString || !reporterPathString) {
|
||||
resourcePath = GetResourcePath();
|
||||
if (!resourcePath) {
|
||||
|
@ -591,7 +591,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
new (gKeyValueAllocator->Allocate(sizeof(SimpleStringDictionary)) )
|
||||
SimpleStringDictionary();
|
||||
|
||||
SimpleStringDictionary &dictionary = *config_params_;
|
||||
SimpleStringDictionary& dictionary = *config_params_;
|
||||
|
||||
dictionary.SetKeyValue(BREAKPAD_SERVER_TYPE, [serverType UTF8String]);
|
||||
dictionary.SetKeyValue(BREAKPAD_PRODUCT_DISPLAY, [display UTF8String]);
|
||||
|
@ -633,8 +633,8 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
|
||||
if (serverParameters) {
|
||||
// For each key-value pair, call BreakpadAddUploadParameter()
|
||||
NSEnumerator *keyEnumerator = [serverParameters keyEnumerator];
|
||||
NSString *aParameter;
|
||||
NSEnumerator* keyEnumerator = [serverParameters keyEnumerator];
|
||||
NSString* aParameter;
|
||||
while ((aParameter = [keyEnumerator nextObject])) {
|
||||
BreakpadAddUploadParameter(this, aParameter,
|
||||
[serverParameters objectForKey:aParameter]);
|
||||
|
@ -644,7 +644,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::SetKeyValue(NSString *key, NSString *value) {
|
||||
void Breakpad::SetKeyValue(NSString* key, NSString* value) {
|
||||
// We allow nil values. This is the same as removing the keyvalue.
|
||||
if (!config_params_ || !key)
|
||||
return;
|
||||
|
@ -653,16 +653,16 @@ void Breakpad::SetKeyValue(NSString *key, NSString *value) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
NSString *Breakpad::KeyValue(NSString *key) {
|
||||
NSString* Breakpad::KeyValue(NSString* key) {
|
||||
if (!config_params_ || !key)
|
||||
return nil;
|
||||
|
||||
const char *value = config_params_->GetValueForKey([key UTF8String]);
|
||||
const char* value = config_params_->GetValueForKey([key UTF8String]);
|
||||
return value ? [NSString stringWithUTF8String:value] : nil;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
void Breakpad::RemoveKeyValue(NSString *key) {
|
||||
void Breakpad::RemoveKeyValue(NSString* key) {
|
||||
if (!config_params_ || !key) return;
|
||||
|
||||
config_params_->RemoveKey([key UTF8String]);
|
||||
|
@ -722,7 +722,7 @@ bool Breakpad::HandleException(int exception_type,
|
|||
|
||||
if (result == KERN_SUCCESS) {
|
||||
// Now, send a series of key-value pairs to the Inspector.
|
||||
const SimpleStringDictionary::Entry *entry = NULL;
|
||||
const SimpleStringDictionary::Entry* entry = NULL;
|
||||
SimpleStringDictionary::Iterator iter(*config_params_);
|
||||
|
||||
while ( (entry = iter.Next()) ) {
|
||||
|
@ -759,7 +759,7 @@ bool Breakpad::HandleException(int exception_type,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) {
|
||||
bool Breakpad::HandleMinidump(const char* dump_dir, const char* minidump_id) {
|
||||
google_breakpad::ConfigFile config_file;
|
||||
config_file.WriteFile(dump_dir, config_params_, dump_dir, minidump_id);
|
||||
google_breakpad::LaunchReporter(
|
||||
|
@ -775,7 +775,7 @@ bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) {
|
|||
#pragma mark Public API
|
||||
|
||||
//=============================================================================
|
||||
BreakpadRef BreakpadCreate(NSDictionary *parameters) {
|
||||
BreakpadRef BreakpadCreate(NSDictionary* parameters) {
|
||||
try {
|
||||
// This is confusing. Our two main allocators for breakpad memory are:
|
||||
// - gKeyValueAllocator for the key/value memory
|
||||
|
@ -815,8 +815,8 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
|
|||
ProtectedMemoryAllocator(breakpad_pool_size);
|
||||
|
||||
// Stack-based autorelease pool for Breakpad::Create() obj-c code.
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
Breakpad *breakpad = Breakpad::Create(parameters);
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
Breakpad* breakpad = Breakpad::Create(parameters);
|
||||
|
||||
if (breakpad) {
|
||||
// Make read-only to protect against memory smashers
|
||||
|
@ -856,7 +856,7 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
|
|||
//=============================================================================
|
||||
void BreakpadRelease(BreakpadRef ref) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (gMasterAllocator) {
|
||||
gMasterAllocator->Unprotect();
|
||||
|
@ -889,10 +889,10 @@ void BreakpadRelease(BreakpadRef ref) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) {
|
||||
void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
@ -905,20 +905,20 @@ void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) {
|
|||
}
|
||||
|
||||
void BreakpadAddUploadParameter(BreakpadRef ref,
|
||||
NSString *key,
|
||||
NSString *value) {
|
||||
NSString* key,
|
||||
NSString* value) {
|
||||
// The only difference, internally, between an upload parameter and
|
||||
// a key value one that is set with BreakpadSetKeyValue is that we
|
||||
// prepend the keyname with a special prefix. This informs the
|
||||
// crash sender that the parameter should be sent along with the
|
||||
// POST of the crash dump upload.
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
||||
NSString *prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX
|
||||
NSString* prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX
|
||||
stringByAppendingString:key];
|
||||
breakpad->SetKeyValue(prefixedKey, value);
|
||||
}
|
||||
|
@ -928,15 +928,15 @@ void BreakpadAddUploadParameter(BreakpadRef ref,
|
|||
}
|
||||
|
||||
void BreakpadRemoveUploadParameter(BreakpadRef ref,
|
||||
NSString *key) {
|
||||
NSString* key) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
||||
NSString *prefixedKey = [NSString stringWithFormat:@"%@%@",
|
||||
NSString* prefixedKey = [NSString stringWithFormat:@"%@%@",
|
||||
@BREAKPAD_SERVER_PARAMETER_PREFIX, key];
|
||||
breakpad->RemoveKeyValue(prefixedKey);
|
||||
}
|
||||
|
@ -945,12 +945,12 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref,
|
|||
}
|
||||
}
|
||||
//=============================================================================
|
||||
NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) {
|
||||
NSString *value = nil;
|
||||
NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key) {
|
||||
NSString* value = nil;
|
||||
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (!breakpad || !key || !gKeyValueAllocator)
|
||||
return nil;
|
||||
|
@ -966,10 +966,10 @@ NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) {
|
||||
void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key) {
|
||||
try {
|
||||
// Not called at exception time
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && key && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
@ -984,7 +984,7 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) {
|
|||
//=============================================================================
|
||||
void BreakpadGenerateAndSendReport(BreakpadRef ref) {
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && gKeyValueAllocator) {
|
||||
ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator);
|
||||
|
@ -1001,10 +1001,10 @@ void BreakpadGenerateAndSendReport(BreakpadRef ref) {
|
|||
//=============================================================================
|
||||
void BreakpadSetFilterCallback(BreakpadRef ref,
|
||||
BreakpadFilterCallback callback,
|
||||
void *context) {
|
||||
void* context) {
|
||||
|
||||
try {
|
||||
Breakpad *breakpad = (Breakpad *)ref;
|
||||
Breakpad* breakpad = (Breakpad*)ref;
|
||||
|
||||
if (breakpad && gBreakpadAllocator) {
|
||||
// share the dictionary mutex here (we really don't need a mutex)
|
||||
|
@ -1018,14 +1018,14 @@ void BreakpadSetFilterCallback(BreakpadRef ref,
|
|||
}
|
||||
|
||||
//============================================================================
|
||||
void BreakpadAddLogFile(BreakpadRef ref, NSString *logPathname) {
|
||||
void BreakpadAddLogFile(BreakpadRef ref, NSString* logPathname) {
|
||||
int logFileCounter = 0;
|
||||
|
||||
NSString *logFileKey = [NSString stringWithFormat:@"%@%d",
|
||||
NSString* logFileKey = [NSString stringWithFormat:@"%@%d",
|
||||
@BREAKPAD_LOGFILE_KEY_PREFIX,
|
||||
logFileCounter];
|
||||
|
||||
NSString *existingLogFilename = nil;
|
||||
NSString* existingLogFilename = nil;
|
||||
existingLogFilename = BreakpadKeyValue(ref, logFileKey);
|
||||
// Find the first log file key that we can use by testing for existence
|
||||
while (existingLogFilename) {
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
// Example Usage :
|
||||
//
|
||||
// kern_return_t result;
|
||||
// OnDemandServer *server = OnDemandServer::Create("/tmp/myserver",
|
||||
// OnDemandServer* server = OnDemandServer::Create("/tmp/myserver",
|
||||
// "com.MyCompany.MyServiceName",
|
||||
// true,
|
||||
// &result);
|
||||
|
@ -88,8 +88,8 @@ class OnDemandServer {
|
|||
}
|
||||
|
||||
// Creates the bootstrap server and service
|
||||
kern_return_t Initialize(const char *server_command,
|
||||
const char *service_name,
|
||||
kern_return_t Initialize(const char* server_command,
|
||||
const char* service_name,
|
||||
bool unregister_on_cleanup);
|
||||
|
||||
// Returns an OnDemandServer object if successful, or NULL if there's
|
||||
|
@ -110,10 +110,10 @@ class OnDemandServer {
|
|||
// out_result : if non-NULL, returns the result
|
||||
// this value will be KERN_SUCCESS if Create() returns non-NULL
|
||||
//
|
||||
static OnDemandServer *Create(const char *server_command,
|
||||
const char *service_name,
|
||||
static OnDemandServer* Create(const char *server_command,
|
||||
const char* service_name,
|
||||
bool unregister_on_cleanup,
|
||||
kern_return_t *out_result);
|
||||
kern_return_t* out_result);
|
||||
|
||||
// Cleans up and if LaunchOnDemand() has not yet been called then
|
||||
// the bootstrap service will be unregistered.
|
||||
|
|
|
@ -49,11 +49,11 @@
|
|||
#endif
|
||||
|
||||
//==============================================================================
|
||||
OnDemandServer *OnDemandServer::Create(const char *server_command,
|
||||
const char *service_name,
|
||||
OnDemandServer* OnDemandServer::Create(const char* server_command,
|
||||
const char* service_name,
|
||||
bool unregister_on_cleanup,
|
||||
kern_return_t *out_result) {
|
||||
OnDemandServer *server = new OnDemandServer();
|
||||
kern_return_t* out_result) {
|
||||
OnDemandServer* server = new OnDemandServer();
|
||||
|
||||
if (!server) return NULL;
|
||||
|
||||
|
@ -74,8 +74,8 @@ OnDemandServer *OnDemandServer::Create(const char *server_command,
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
kern_return_t OnDemandServer::Initialize(const char *server_command,
|
||||
const char *service_name,
|
||||
kern_return_t OnDemandServer::Initialize(const char* server_command,
|
||||
const char* service_name,
|
||||
bool unregister_on_cleanup) {
|
||||
unregister_on_cleanup_ = unregister_on_cleanup;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
namespace google_breakpad {
|
||||
|
||||
BOOL EnsureDirectoryPathExists(NSString *dirPath);
|
||||
BOOL EnsureDirectoryPathExists(NSString* dirPath);
|
||||
|
||||
//=============================================================================
|
||||
class ConfigFile {
|
||||
|
@ -50,11 +50,11 @@ class ConfigFile {
|
|||
}
|
||||
|
||||
void WriteFile(const char* directory,
|
||||
const SimpleStringDictionary *configurationParameters,
|
||||
const char *dump_dir,
|
||||
const char *minidump_id);
|
||||
const SimpleStringDictionary* configurationParameters,
|
||||
const char* dump_dir,
|
||||
const char* minidump_id);
|
||||
|
||||
const char *GetFilePath() { return config_file_path_; }
|
||||
const char* GetFilePath() { return config_file_path_; }
|
||||
|
||||
void Unlink() {
|
||||
if (config_file_ != -1)
|
||||
|
@ -64,16 +64,16 @@ class ConfigFile {
|
|||
}
|
||||
|
||||
private:
|
||||
BOOL WriteData(const void *data, size_t length);
|
||||
BOOL WriteData(const void* data, size_t length);
|
||||
|
||||
BOOL AppendConfigData(const char *key,
|
||||
const void *data,
|
||||
BOOL AppendConfigData(const char* key,
|
||||
const void* data,
|
||||
size_t length);
|
||||
|
||||
BOOL AppendConfigString(const char *key,
|
||||
const char *value);
|
||||
BOOL AppendConfigString(const char* key,
|
||||
const char* value);
|
||||
|
||||
BOOL AppendCrashTimeParameters(const char *processStartTimeString);
|
||||
BOOL AppendCrashTimeParameters(const char* processStartTimeString);
|
||||
|
||||
int config_file_; // descriptor for config file
|
||||
char config_file_path_[PATH_MAX]; // Path to configuration file
|
||||
|
|
|
@ -42,10 +42,10 @@
|
|||
namespace google_breakpad {
|
||||
|
||||
//=============================================================================
|
||||
BOOL EnsureDirectoryPathExists(NSString *dirPath) {
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
BOOL EnsureDirectoryPathExists(NSString* dirPath) {
|
||||
NSFileManager* mgr = [NSFileManager defaultManager];
|
||||
|
||||
NSDictionary *attrs =
|
||||
NSDictionary* attrs =
|
||||
[NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:0750]
|
||||
forKey:NSFilePosixPermissions];
|
||||
|
||||
|
@ -56,15 +56,15 @@ BOOL EnsureDirectoryPathExists(NSString *dirPath) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
BOOL ConfigFile::WriteData(const void *data, size_t length) {
|
||||
BOOL ConfigFile::WriteData(const void* data, size_t length) {
|
||||
size_t result = write(config_file_, data, length);
|
||||
|
||||
return result == length;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
BOOL ConfigFile::AppendConfigData(const char *key,
|
||||
const void *data, size_t length) {
|
||||
BOOL ConfigFile::AppendConfigData(const char* key,
|
||||
const void* data, size_t length) {
|
||||
assert(config_file_ != -1);
|
||||
|
||||
if (!key) {
|
||||
|
@ -88,13 +88,13 @@ BOOL ConfigFile::AppendConfigData(const char *key,
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
BOOL ConfigFile::AppendConfigString(const char *key,
|
||||
const char *value) {
|
||||
BOOL ConfigFile::AppendConfigString(const char* key,
|
||||
const char* value) {
|
||||
return AppendConfigData(key, value, strlen(value));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
BOOL ConfigFile::AppendCrashTimeParameters(const char *processStartTimeString) {
|
||||
BOOL ConfigFile::AppendCrashTimeParameters(const char* processStartTimeString) {
|
||||
// Set process uptime parameter
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
@ -118,9 +118,9 @@ BOOL ConfigFile::AppendCrashTimeParameters(const char *processStartTimeString) {
|
|||
|
||||
//=============================================================================
|
||||
void ConfigFile::WriteFile(const char* directory,
|
||||
const SimpleStringDictionary *configurationParameters,
|
||||
const char *dump_dir,
|
||||
const char *minidump_id) {
|
||||
const SimpleStringDictionary* configurationParameters,
|
||||
const char* dump_dir,
|
||||
const char* minidump_id) {
|
||||
|
||||
assert(config_file_ == -1);
|
||||
|
||||
|
@ -146,9 +146,9 @@ void ConfigFile::WriteFile(const char* directory,
|
|||
|
||||
// Write out the configuration parameters
|
||||
BOOL result = YES;
|
||||
const SimpleStringDictionary &dictionary = *configurationParameters;
|
||||
const SimpleStringDictionary& dictionary = *configurationParameters;
|
||||
|
||||
const SimpleStringDictionary::Entry *entry = NULL;
|
||||
const SimpleStringDictionary::Entry* entry = NULL;
|
||||
SimpleStringDictionary::Iterator iter(dictionary);
|
||||
|
||||
while ((entry = iter.Next())) {
|
||||
|
|
|
@ -63,7 +63,7 @@ struct KeyValueMessageData {
|
|||
public:
|
||||
KeyValueMessageData() {}
|
||||
explicit KeyValueMessageData(
|
||||
const google_breakpad::SimpleStringDictionary::Entry &inEntry) {
|
||||
const google_breakpad::SimpleStringDictionary::Entry& inEntry) {
|
||||
strlcpy(key, inEntry.key, sizeof(key) );
|
||||
strlcpy(value, inEntry.value, sizeof(value) );
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace google_breakpad {
|
|||
//=============================================================================
|
||||
class MinidumpLocation {
|
||||
public:
|
||||
MinidumpLocation(NSString *minidumpDir) {
|
||||
MinidumpLocation(NSString* minidumpDir) {
|
||||
// Ensure that the path exists. Fallback to /tmp if unable to locate path.
|
||||
assert(minidumpDir);
|
||||
if (!EnsureDirectoryPathExists(minidumpDir)) {
|
||||
|
@ -100,8 +100,8 @@ class MinidumpLocation {
|
|||
strlcpy(minidump_id_, next_minidump_id.c_str(), sizeof(minidump_id_));
|
||||
}
|
||||
|
||||
const char *GetPath() { return minidump_dir_path_; }
|
||||
const char *GetID() { return minidump_id_; }
|
||||
const char* GetPath() { return minidump_dir_path_; }
|
||||
const char* GetID() { return minidump_id_; }
|
||||
|
||||
private:
|
||||
char minidump_dir_path_[PATH_MAX]; // Path to minidump directory
|
||||
|
@ -116,7 +116,7 @@ class Inspector {
|
|||
// given a bootstrap service name, receives mach messages
|
||||
// from a crashed process, then inspects it, creates a minidump file
|
||||
// and asks the user if he wants to upload it to a server.
|
||||
void Inspect(const char *receive_port_name);
|
||||
void Inspect(const char* receive_port_name);
|
||||
|
||||
private:
|
||||
// The Inspector is invoked with its bootstrap port set to the bootstrap
|
||||
|
@ -131,8 +131,8 @@ class Inspector {
|
|||
// ServiceCheckOut.
|
||||
kern_return_t ResetBootstrapPort();
|
||||
|
||||
kern_return_t ServiceCheckIn(const char *receive_port_name);
|
||||
kern_return_t ServiceCheckOut(const char *receive_port_name);
|
||||
kern_return_t ServiceCheckIn(const char* receive_port_name);
|
||||
kern_return_t ServiceCheckOut(const char* receive_port_name);
|
||||
|
||||
kern_return_t ReadMessages();
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
namespace google_breakpad {
|
||||
|
||||
//=============================================================================
|
||||
void Inspector::Inspect(const char *receive_port_name) {
|
||||
void Inspector::Inspect(const char* receive_port_name) {
|
||||
kern_return_t result = ResetBootstrapPort();
|
||||
if (result != KERN_SUCCESS) {
|
||||
return;
|
||||
|
@ -143,7 +143,7 @@ kern_return_t Inspector::ResetBootstrapPort() {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
kern_return_t Inspector::ServiceCheckIn(const char *receive_port_name) {
|
||||
kern_return_t Inspector::ServiceCheckIn(const char* receive_port_name) {
|
||||
// We need to get the mach port representing this service, so we can
|
||||
// get information from the crashed process.
|
||||
kern_return_t kr = bootstrap_check_in(bootstrap_subset_port_,
|
||||
|
@ -160,7 +160,7 @@ kern_return_t Inspector::ServiceCheckIn(const char *receive_port_name) {
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
kern_return_t Inspector::ServiceCheckOut(const char *receive_port_name) {
|
||||
kern_return_t Inspector::ServiceCheckOut(const char* receive_port_name) {
|
||||
// We're done receiving mach messages from the crashed process,
|
||||
// so clean up a bit.
|
||||
kern_return_t kr;
|
||||
|
@ -198,7 +198,7 @@ kern_return_t Inspector::ReadMessages() {
|
|||
kern_return_t result = receive_port.WaitForMessage(&message, 1000);
|
||||
|
||||
if (result == KERN_SUCCESS) {
|
||||
InspectorInfo &info = (InspectorInfo &)*message.GetData();
|
||||
InspectorInfo& info = (InspectorInfo&)*message.GetData();
|
||||
exception_type_ = info.exception_type;
|
||||
exception_code_ = info.exception_code;
|
||||
exception_subcode_ = info.exception_subcode;
|
||||
|
@ -237,7 +237,7 @@ kern_return_t Inspector::ReadMessages() {
|
|||
result = receive_port.WaitForMessage(¶meter_message, 1000);
|
||||
|
||||
if(result == KERN_SUCCESS) {
|
||||
KeyValueMessageData &key_value_data =
|
||||
KeyValueMessageData& key_value_data =
|
||||
(KeyValueMessageData&)*parameter_message.GetData();
|
||||
// If we get a blank key, make sure we don't increment the
|
||||
// parameter count; in some cases (notably on-demand generation
|
||||
|
@ -267,27 +267,27 @@ bool Inspector::InspectTask() {
|
|||
// keep the task quiet while we're looking at it
|
||||
task_suspend(remote_task_);
|
||||
|
||||
NSString *minidumpDir;
|
||||
NSString* minidumpDir;
|
||||
|
||||
const char *minidumpDirectory =
|
||||
const char* minidumpDirectory =
|
||||
config_params_.GetValueForKey(BREAKPAD_DUMP_DIRECTORY);
|
||||
|
||||
// If the client app has not specified a minidump directory,
|
||||
// use a default of Library/<kDefaultLibrarySubdirectory>/<Product Name>
|
||||
if (!minidumpDirectory || 0 == strlen(minidumpDirectory)) {
|
||||
NSArray *libraryDirectories =
|
||||
NSArray* libraryDirectories =
|
||||
NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||
NSUserDomainMask,
|
||||
YES);
|
||||
|
||||
NSString *applicationSupportDirectory =
|
||||
NSString* applicationSupportDirectory =
|
||||
[libraryDirectories objectAtIndex:0];
|
||||
NSString *library_subdirectory = [NSString
|
||||
NSString* library_subdirectory = [NSString
|
||||
stringWithUTF8String:kDefaultLibrarySubdirectory];
|
||||
NSString *breakpad_product = [NSString
|
||||
NSString* breakpad_product = [NSString
|
||||
stringWithUTF8String:config_params_.GetValueForKey(BREAKPAD_PRODUCT)];
|
||||
|
||||
NSArray *path_components = [NSArray
|
||||
NSArray* path_components = [NSArray
|
||||
arrayWithObjects:applicationSupportDirectory,
|
||||
library_subdirectory,
|
||||
breakpad_product,
|
||||
|
@ -306,11 +306,11 @@ bool Inspector::InspectTask() {
|
|||
// assumes system encoding and in RTL locales will prepend an LTR override
|
||||
// character for paths beginning with '/' which fileSystemRepresentation does
|
||||
// not remove. Filed as rdar://6889706 .
|
||||
NSString *path_ns = [NSString
|
||||
NSString* path_ns = [NSString
|
||||
stringWithUTF8String:minidumpLocation.GetPath()];
|
||||
NSString *pathid_ns = [NSString
|
||||
NSString* pathid_ns = [NSString
|
||||
stringWithUTF8String:minidumpLocation.GetID()];
|
||||
NSString *minidumpPath = [path_ns stringByAppendingPathComponent:pathid_ns];
|
||||
NSString* minidumpPath = [path_ns stringByAppendingPathComponent:pathid_ns];
|
||||
minidumpPath = [minidumpPath
|
||||
stringByAppendingPathExtension:@"dmp"];
|
||||
|
||||
|
|
|
@ -38,15 +38,15 @@
|
|||
namespace google_breakpad {
|
||||
|
||||
CrashGenerationServer::CrashGenerationServer(
|
||||
const char *mach_port_name,
|
||||
const char* mach_port_name,
|
||||
FilterCallback filter,
|
||||
void *filter_context,
|
||||
void* filter_context,
|
||||
OnClientDumpRequestCallback dump_callback,
|
||||
void *dump_context,
|
||||
void* dump_context,
|
||||
OnClientExitingCallback exit_callback,
|
||||
void *exit_context,
|
||||
void* exit_context,
|
||||
bool generate_dumps,
|
||||
const std::string &dump_path)
|
||||
const std::string& dump_path)
|
||||
: filter_(filter),
|
||||
filter_context_(filter_context),
|
||||
dump_callback_(dump_callback),
|
||||
|
@ -90,8 +90,8 @@ bool CrashGenerationServer::Stop() {
|
|||
}
|
||||
|
||||
// static
|
||||
void *CrashGenerationServer::WaitForMessages(void *server) {
|
||||
CrashGenerationServer *self =
|
||||
void* CrashGenerationServer::WaitForMessages(void* server) {
|
||||
CrashGenerationServer* self =
|
||||
reinterpret_cast<CrashGenerationServer*>(server);
|
||||
while (self->WaitForOneMessage()) {}
|
||||
return NULL;
|
||||
|
@ -104,7 +104,7 @@ bool CrashGenerationServer::WaitForOneMessage() {
|
|||
if (result == KERN_SUCCESS) {
|
||||
switch (message.GetMessageID()) {
|
||||
case kDumpRequestMessage: {
|
||||
ExceptionInfo &info = (ExceptionInfo &)*message.GetData();
|
||||
ExceptionInfo& info = (ExceptionInfo&)*message.GetData();
|
||||
|
||||
mach_port_t remote_task = message.GetTranslatedPort(0);
|
||||
mach_port_t crashing_thread = message.GetTranslatedPort(1);
|
||||
|
|
|
@ -59,14 +59,14 @@ class CrashGenerationServer {
|
|||
// WARNING: callbacks may be invoked on a different thread
|
||||
// than that which creates the CrashGenerationServer. They must
|
||||
// be thread safe.
|
||||
typedef void (*OnClientDumpRequestCallback)(void *context,
|
||||
const ClientInfo &client_info,
|
||||
const std::string &file_path);
|
||||
typedef void (*OnClientDumpRequestCallback)(void* context,
|
||||
const ClientInfo& client_info,
|
||||
const std::string& file_path);
|
||||
|
||||
typedef void (*OnClientExitingCallback)(void *context,
|
||||
const ClientInfo &client_info);
|
||||
typedef void (*OnClientExitingCallback)(void* context,
|
||||
const ClientInfo& client_info);
|
||||
// If a FilterCallback returns false, the dump will not be written.
|
||||
typedef bool (*FilterCallback)(void *context);
|
||||
typedef bool (*FilterCallback)(void* context);
|
||||
|
||||
// Create an instance with the given parameters.
|
||||
//
|
||||
|
@ -83,15 +83,15 @@ class CrashGenerationServer {
|
|||
// passed for this parameter.
|
||||
// dump_path: Path for generating dumps; required only if true is
|
||||
// passed for generateDumps parameter; NULL can be passed otherwise.
|
||||
CrashGenerationServer(const char *mach_port_name,
|
||||
CrashGenerationServer(const char* mach_port_name,
|
||||
FilterCallback filter,
|
||||
void *filter_context,
|
||||
void* filter_context,
|
||||
OnClientDumpRequestCallback dump_callback,
|
||||
void *dump_context,
|
||||
void* dump_context,
|
||||
OnClientExitingCallback exit_callback,
|
||||
void *exit_context,
|
||||
void* exit_context,
|
||||
bool generate_dumps,
|
||||
const std::string &dump_path);
|
||||
const std::string& dump_path);
|
||||
|
||||
~CrashGenerationServer();
|
||||
|
||||
|
@ -105,24 +105,24 @@ class CrashGenerationServer {
|
|||
|
||||
private:
|
||||
// Return a unique filename at which a minidump can be written.
|
||||
bool MakeMinidumpFilename(std::string &outFilename);
|
||||
bool MakeMinidumpFilename(std::string& outFilename);
|
||||
|
||||
// Loop reading client messages and responding to them until
|
||||
// a quit message is received.
|
||||
static void *WaitForMessages(void *server);
|
||||
static void* WaitForMessages(void* server);
|
||||
|
||||
// Wait for a single client message and respond to it. Returns false
|
||||
// if a quit message was received or if an error occurred.
|
||||
bool WaitForOneMessage();
|
||||
|
||||
FilterCallback filter_;
|
||||
void *filter_context_;
|
||||
void* filter_context_;
|
||||
|
||||
OnClientDumpRequestCallback dump_callback_;
|
||||
void *dump_context_;
|
||||
void* dump_context_;
|
||||
|
||||
OnClientExitingCallback exit_callback_;
|
||||
void *exit_context_;
|
||||
void* exit_context_;
|
||||
|
||||
bool generate_dumps_;
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ struct MachBits<nlist64> {
|
|||
|
||||
template<typename nlist_type>
|
||||
int
|
||||
__breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
||||
__breakpad_fdnlist(int fd, nlist_type* list, const char** symbolNames,
|
||||
cpu_type_t cpu_type);
|
||||
|
||||
/*
|
||||
|
@ -139,9 +139,9 @@ __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
*/
|
||||
|
||||
template <typename nlist_type>
|
||||
int breakpad_nlist_common(const char *name,
|
||||
nlist_type *list,
|
||||
const char **symbolNames,
|
||||
int breakpad_nlist_common(const char* name,
|
||||
nlist_type* list,
|
||||
const char** symbolNames,
|
||||
cpu_type_t cpu_type) {
|
||||
int fd = open(name, O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
|
@ -151,16 +151,16 @@ int breakpad_nlist_common(const char *name,
|
|||
return n;
|
||||
}
|
||||
|
||||
int breakpad_nlist(const char *name,
|
||||
struct nlist *list,
|
||||
const char **symbolNames,
|
||||
int breakpad_nlist(const char* name,
|
||||
struct nlist* list,
|
||||
const char** symbolNames,
|
||||
cpu_type_t cpu_type) {
|
||||
return breakpad_nlist_common(name, list, symbolNames, cpu_type);
|
||||
}
|
||||
|
||||
int breakpad_nlist(const char *name,
|
||||
struct nlist_64 *list,
|
||||
const char **symbolNames,
|
||||
int breakpad_nlist(const char* name,
|
||||
struct nlist_64* list,
|
||||
const char** symbolNames,
|
||||
cpu_type_t cpu_type) {
|
||||
return breakpad_nlist_common(name, list, symbolNames, cpu_type);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ int breakpad_nlist(const char *name,
|
|||
/* Note: __fdnlist() is called from kvm_nlist in libkvm's kvm.c */
|
||||
|
||||
template<typename nlist_type>
|
||||
int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
||||
int __breakpad_fdnlist(int fd, nlist_type* list, const char** symbolNames,
|
||||
cpu_type_t cpu_type) {
|
||||
typedef typename MachBits<nlist_type>::mach_header_type mach_header_type;
|
||||
typedef typename MachBits<nlist_type>::word_type word_type;
|
||||
|
@ -189,9 +189,9 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
}
|
||||
|
||||
struct exec buf;
|
||||
if (read(fd, (char *)&buf, sizeof(buf)) != sizeof(buf) ||
|
||||
(N_BADMAG(buf) && *((uint32_t *)&buf) != magic &&
|
||||
CFSwapInt32BigToHost(*((uint32_t *)&buf)) != FAT_MAGIC &&
|
||||
if (read(fd, (char*)&buf, sizeof(buf)) != sizeof(buf) ||
|
||||
(N_BADMAG(buf) && *((uint32_t*)&buf) != magic &&
|
||||
CFSwapInt32BigToHost(*((uint32_t*)&buf)) != FAT_MAGIC &&
|
||||
/* The following is the big-endian ppc64 check */
|
||||
(*((uint32_t*)&buf)) != FAT_MAGIC)) {
|
||||
return -1;
|
||||
|
@ -199,15 +199,15 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
|
||||
/* Deal with fat file if necessary */
|
||||
unsigned arch_offset = 0;
|
||||
if (CFSwapInt32BigToHost(*((uint32_t *)&buf)) == FAT_MAGIC ||
|
||||
if (CFSwapInt32BigToHost(*((uint32_t*)&buf)) == FAT_MAGIC ||
|
||||
/* The following is the big-endian ppc64 check */
|
||||
*((unsigned int *)&buf) == FAT_MAGIC) {
|
||||
*((unsigned int*)&buf) == FAT_MAGIC) {
|
||||
/* Read in the fat header */
|
||||
struct fat_header fh;
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) {
|
||||
return -1;
|
||||
}
|
||||
if (read(fd, (char *)&fh, sizeof(fh)) != sizeof(fh)) {
|
||||
if (read(fd, (char*)&fh, sizeof(fh)) != sizeof(fh)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -215,12 +215,12 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
fh.nfat_arch = CFSwapInt32BigToHost(fh.nfat_arch);
|
||||
|
||||
/* Read in the fat archs */
|
||||
struct fat_arch *fat_archs =
|
||||
(struct fat_arch *)malloc(fh.nfat_arch * sizeof(struct fat_arch));
|
||||
struct fat_arch* fat_archs =
|
||||
(struct fat_arch*)malloc(fh.nfat_arch * sizeof(struct fat_arch));
|
||||
if (fat_archs == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (read(fd, (char *)fat_archs,
|
||||
if (read(fd, (char*)fat_archs,
|
||||
sizeof(struct fat_arch) * fh.nfat_arch) !=
|
||||
(ssize_t)(sizeof(struct fat_arch) * fh.nfat_arch)) {
|
||||
free(fat_archs);
|
||||
|
@ -244,7 +244,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
CFSwapInt32BigToHost(fat_archs[i].align);
|
||||
}
|
||||
|
||||
struct fat_arch *fap = NULL;
|
||||
struct fat_arch* fap = NULL;
|
||||
for (unsigned i = 0; i < fh.nfat_arch; i++) {
|
||||
if (fat_archs[i].cputype == cpu_type) {
|
||||
fap = &fat_archs[i];
|
||||
|
@ -263,7 +263,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
if (lseek(fd, arch_offset, SEEK_SET) == -1) {
|
||||
return -1;
|
||||
}
|
||||
if (read(fd, (char *)&buf, sizeof(buf)) != sizeof(buf)) {
|
||||
if (read(fd, (char*)&buf, sizeof(buf)) != sizeof(buf)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -271,48 +271,45 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
off_t sa; /* symbol address */
|
||||
off_t ss; /* start of strings */
|
||||
register_t n;
|
||||
if (*((unsigned int *)&buf) == magic) {
|
||||
if (*((unsigned int*)&buf) == magic) {
|
||||
if (lseek(fd, arch_offset, SEEK_SET) == -1) {
|
||||
return -1;
|
||||
}
|
||||
mach_header_type mh;
|
||||
if (read(fd, (char *)&mh, sizeof(mh)) != sizeof(mh)) {
|
||||
if (read(fd, (char*)&mh, sizeof(mh)) != sizeof(mh)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct load_command *load_commands =
|
||||
(struct load_command *)malloc(mh.sizeofcmds);
|
||||
struct load_command* load_commands =
|
||||
(struct load_command*)malloc(mh.sizeofcmds);
|
||||
if (load_commands == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (read(fd, (char *)load_commands, mh.sizeofcmds) !=
|
||||
if (read(fd, (char*)load_commands, mh.sizeofcmds) !=
|
||||
(ssize_t)mh.sizeofcmds) {
|
||||
free(load_commands);
|
||||
return -1;
|
||||
}
|
||||
struct symtab_command *stp = NULL;
|
||||
struct load_command *lcp = load_commands;
|
||||
struct symtab_command* stp = NULL;
|
||||
struct load_command* lcp = load_commands;
|
||||
// iterate through all load commands, looking for
|
||||
// LC_SYMTAB load command
|
||||
for (uint32_t i = 0; i < mh.ncmds; i++) {
|
||||
if (lcp->cmdsize % sizeof(word_type) != 0 ||
|
||||
lcp->cmdsize <= 0 ||
|
||||
(char *)lcp + lcp->cmdsize >
|
||||
(char *)load_commands + mh.sizeofcmds) {
|
||||
(char*)lcp + lcp->cmdsize > (char*)load_commands + mh.sizeofcmds) {
|
||||
free(load_commands);
|
||||
return -1;
|
||||
}
|
||||
if (lcp->cmd == LC_SYMTAB) {
|
||||
if (lcp->cmdsize !=
|
||||
sizeof(struct symtab_command)) {
|
||||
if (lcp->cmdsize != sizeof(struct symtab_command)) {
|
||||
free(load_commands);
|
||||
return -1;
|
||||
}
|
||||
stp = (struct symtab_command *)lcp;
|
||||
stp = (struct symtab_command*)lcp;
|
||||
break;
|
||||
}
|
||||
lcp = (struct load_command *)
|
||||
((char *)lcp + lcp->cmdsize);
|
||||
lcp = (struct load_command*)((char*)lcp + lcp->cmdsize);
|
||||
}
|
||||
if (stp == NULL) {
|
||||
free(load_commands);
|
||||
|
@ -347,7 +344,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
|
||||
if (n < m)
|
||||
m = n;
|
||||
if (read(fd, (char *)space, m) != m)
|
||||
if (read(fd, (char*)space, m) != m)
|
||||
break;
|
||||
n -= m;
|
||||
off_t savpos = lseek(fd, 0, SEEK_CUR);
|
||||
|
@ -368,13 +365,13 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames,
|
|||
if (read(fd, nambuf, maxlen+1) == -1) {
|
||||
return -1;
|
||||
}
|
||||
const char *s2 = nambuf;
|
||||
for (nlist_type *p = list;
|
||||
const char* s2 = nambuf;
|
||||
for (nlist_type* p = list;
|
||||
symbolNames[p-list] && symbolNames[p-list][0];
|
||||
p++) {
|
||||
// get the symbol name the user has passed in that
|
||||
// corresponds to the nlist entry that we're looking at
|
||||
const char *s1 = symbolNames[p - list];
|
||||
const char* s1 = symbolNames[p - list];
|
||||
while (*s1) {
|
||||
if (*s1++ != *s2++)
|
||||
goto cont;
|
||||
|
|
|
@ -36,13 +36,13 @@
|
|||
|
||||
#include <mach/machine.h>
|
||||
|
||||
int breakpad_nlist(const char *name,
|
||||
struct nlist *list,
|
||||
const char **symbolNames,
|
||||
int breakpad_nlist(const char* name,
|
||||
struct nlist* list,
|
||||
const char** symbolNames,
|
||||
cpu_type_t cpu_type);
|
||||
int breakpad_nlist(const char *name,
|
||||
struct nlist_64 *list,
|
||||
const char **symbolNames,
|
||||
int breakpad_nlist(const char* name,
|
||||
struct nlist_64* list,
|
||||
const char** symbolNames,
|
||||
cpu_type_t cpu_type);
|
||||
|
||||
#endif /* CLIENT_MAC_HANDLER_BREAKPAD_NLIST_H__ */
|
||||
|
|
|
@ -66,7 +66,7 @@ struct task_dyld_info {
|
|||
mach_vm_size_t all_image_info_size;
|
||||
};
|
||||
typedef struct task_dyld_info task_dyld_info_data_t;
|
||||
typedef struct task_dyld_info *task_dyld_info_t;
|
||||
typedef struct task_dyld_info* task_dyld_info_t;
|
||||
#define TASK_DYLD_INFO_COUNT (sizeof(task_dyld_info_data_t) / sizeof(natural_t))
|
||||
|
||||
#endif
|
||||
|
@ -88,7 +88,7 @@ using std::vector;
|
|||
//
|
||||
static mach_vm_size_t GetMemoryRegionSize(task_port_t target_task,
|
||||
const uint64_t address,
|
||||
mach_vm_size_t *size_to_end) {
|
||||
mach_vm_size_t* size_to_end) {
|
||||
mach_vm_address_t region_base = (mach_vm_address_t)address;
|
||||
mach_vm_size_t region_size;
|
||||
natural_t nesting_level = 0;
|
||||
|
@ -182,7 +182,7 @@ static string ReadTaskString(task_port_t target_task,
|
|||
kern_return_t ReadTaskMemory(task_port_t target_task,
|
||||
const uint64_t address,
|
||||
size_t length,
|
||||
vector<uint8_t> &bytes) {
|
||||
vector<uint8_t>& bytes) {
|
||||
int systemPageSize = getpagesize();
|
||||
|
||||
// use the negative of the page size for the mask to find the page address
|
||||
|
@ -250,16 +250,16 @@ bool FindTextSection(DynamicImage& image) {
|
|||
return false;
|
||||
}
|
||||
|
||||
const struct load_command *cmd =
|
||||
reinterpret_cast<const struct load_command *>(header + 1);
|
||||
const struct load_command* cmd =
|
||||
reinterpret_cast<const struct load_command*>(header + 1);
|
||||
|
||||
bool found_text_section = false;
|
||||
bool found_dylib_id_command = false;
|
||||
for (unsigned int i = 0; cmd && (i < header->ncmds); ++i) {
|
||||
if (!found_text_section) {
|
||||
if (cmd->cmd == MachBits::segment_load_command) {
|
||||
const mach_segment_command_type *seg =
|
||||
reinterpret_cast<const mach_segment_command_type *>(cmd);
|
||||
const mach_segment_command_type* seg =
|
||||
reinterpret_cast<const mach_segment_command_type*>(cmd);
|
||||
|
||||
if (!strcmp(seg->segname, "__TEXT")) {
|
||||
image.vmaddr_ = static_cast<mach_vm_address_t>(seg->vmaddr);
|
||||
|
@ -277,8 +277,8 @@ bool FindTextSection(DynamicImage& image) {
|
|||
|
||||
if (!found_dylib_id_command) {
|
||||
if (cmd->cmd == LC_ID_DYLIB) {
|
||||
const struct dylib_command *dc =
|
||||
reinterpret_cast<const struct dylib_command *>(cmd);
|
||||
const struct dylib_command* dc =
|
||||
reinterpret_cast<const struct dylib_command*>(cmd);
|
||||
|
||||
image.version_ = dc->dylib.current_version;
|
||||
found_dylib_id_command = true;
|
||||
|
@ -289,8 +289,8 @@ bool FindTextSection(DynamicImage& image) {
|
|||
return true;
|
||||
}
|
||||
|
||||
cmd = reinterpret_cast<const struct load_command *>
|
||||
(reinterpret_cast<const char *>(cmd) + cmd->cmdsize);
|
||||
cmd = reinterpret_cast<const struct load_command*>
|
||||
(reinterpret_cast<const char*>(cmd) + cmd->cmdsize);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -349,8 +349,8 @@ static uint64_t LookupSymbol(const char* symbol_name,
|
|||
typedef typename MachBits::nlist_type nlist_type;
|
||||
|
||||
nlist_type symbol_info[8] = {};
|
||||
const char *symbolNames[2] = { symbol_name, "\0" };
|
||||
nlist_type &list = symbol_info[0];
|
||||
const char* symbolNames[2] = { symbol_name, "\0" };
|
||||
nlist_type& list = symbol_info[0];
|
||||
int invalidEntriesCount = breakpad_nlist(filename,
|
||||
&list,
|
||||
symbolNames,
|
||||
|
@ -396,8 +396,8 @@ uint64_t DynamicImages::GetDyldAllImageInfosPointer() {
|
|||
|
||||
return (uint64_t)task_dyld_info.all_image_info_addr;
|
||||
} else {
|
||||
const char *imageSymbolName = "_dyld_all_image_infos";
|
||||
const char *dyldPath = "/usr/lib/dyld";
|
||||
const char* imageSymbolName = "_dyld_all_image_infos";
|
||||
const char* dyldPath = "/usr/lib/dyld";
|
||||
|
||||
if (Is64Bit())
|
||||
return LookupSymbol<MachO64>(imageSymbolName, dyldPath, cpu_type_);
|
||||
|
@ -428,7 +428,7 @@ void ReadImageInfo(DynamicImages& images,
|
|||
dyld_all_info_bytes) != KERN_SUCCESS)
|
||||
return;
|
||||
|
||||
dyld_all_image_infos *dyldInfo =
|
||||
dyld_all_image_infos* dyldInfo =
|
||||
reinterpret_cast<dyld_all_image_infos*>(&dyld_all_info_bytes[0]);
|
||||
|
||||
// number of loaded images
|
||||
|
@ -443,12 +443,12 @@ void ReadImageInfo(DynamicImages& images,
|
|||
dyld_info_array_bytes) != KERN_SUCCESS)
|
||||
return;
|
||||
|
||||
dyld_image_info *infoArray =
|
||||
dyld_image_info* infoArray =
|
||||
reinterpret_cast<dyld_image_info*>(&dyld_info_array_bytes[0]);
|
||||
images.image_list_.reserve(count);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
dyld_image_info &info = infoArray[i];
|
||||
dyld_image_info& info = infoArray[i];
|
||||
|
||||
// First read just the mach_header from the image in the task.
|
||||
vector<uint8_t> mach_header_bytes;
|
||||
|
@ -458,7 +458,7 @@ void ReadImageInfo(DynamicImages& images,
|
|||
mach_header_bytes) != KERN_SUCCESS)
|
||||
continue; // bail on this dynamic image
|
||||
|
||||
mach_header_type *header =
|
||||
mach_header_type* header =
|
||||
reinterpret_cast<mach_header_type*>(&mach_header_bytes[0]);
|
||||
|
||||
// Now determine the total amount necessary to read the header
|
||||
|
@ -482,7 +482,7 @@ void ReadImageInfo(DynamicImages& images,
|
|||
}
|
||||
|
||||
// Create an object representing this image and add it to our list.
|
||||
DynamicImage *new_image;
|
||||
DynamicImage* new_image;
|
||||
new_image = new DynamicImage(&mach_header_bytes[0],
|
||||
header_size,
|
||||
info.load_address_,
|
||||
|
@ -522,7 +522,7 @@ void DynamicImages::ReadImageInfoForTask() {
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
DynamicImage *DynamicImages::GetExecutableImage() {
|
||||
DynamicImage* DynamicImages::GetExecutableImage() {
|
||||
int executable_index = GetExecutableImageIndex();
|
||||
|
||||
if (executable_index >= 0) {
|
||||
|
@ -538,7 +538,7 @@ int DynamicImages::GetExecutableImageIndex() {
|
|||
int image_count = GetImageCount();
|
||||
|
||||
for (int i = 0; i < image_count; ++i) {
|
||||
DynamicImage *image = GetImage(i);
|
||||
DynamicImage* image = GetImage(i);
|
||||
if (image->GetFileType() == MH_EXECUTE) {
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ uint32_t GetFileTypeFromHeader(DynamicImage& image);
|
|||
// Represents a single dynamically loaded mach-o image
|
||||
class DynamicImage {
|
||||
public:
|
||||
DynamicImage(uint8_t *header, // data is copied
|
||||
DynamicImage(uint8_t* header, // data is copied
|
||||
size_t header_size, // includes load commands
|
||||
uint64_t load_address,
|
||||
string file_path,
|
||||
|
@ -163,7 +163,7 @@ class DynamicImage {
|
|||
|
||||
uint32_t GetVersion() {return version_;}
|
||||
// For sorting
|
||||
bool operator<(const DynamicImage &inInfo) {
|
||||
bool operator<(const DynamicImage& inInfo) {
|
||||
return GetLoadAddress() < inInfo.GetLoadAddress();
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,8 @@ class DynamicImage {
|
|||
bool IsValid() {return GetVMSize() != 0;}
|
||||
|
||||
private:
|
||||
DynamicImage(const DynamicImage &);
|
||||
DynamicImage &operator=(const DynamicImage &);
|
||||
DynamicImage(const DynamicImage&);
|
||||
DynamicImage& operator=(const DynamicImage&);
|
||||
|
||||
friend class DynamicImages;
|
||||
template<typename MachBits>
|
||||
|
@ -205,26 +205,26 @@ class DynamicImage {
|
|||
//
|
||||
class DynamicImageRef {
|
||||
public:
|
||||
explicit DynamicImageRef(DynamicImage *inP) : p(inP) {}
|
||||
explicit DynamicImageRef(DynamicImage* inP) : p(inP) {}
|
||||
// The copy constructor is required by STL
|
||||
DynamicImageRef(const DynamicImageRef &inRef) : p(inRef.p) {}
|
||||
DynamicImageRef(const DynamicImageRef& inRef) : p(inRef.p) {}
|
||||
|
||||
bool operator<(const DynamicImageRef &inRef) const {
|
||||
bool operator<(const DynamicImageRef& inRef) const {
|
||||
return (*const_cast<DynamicImageRef*>(this)->p)
|
||||
< (*const_cast<DynamicImageRef&>(inRef).p);
|
||||
}
|
||||
|
||||
bool operator==(const DynamicImageRef &inInfo) const {
|
||||
bool operator==(const DynamicImageRef& inInfo) const {
|
||||
return (*const_cast<DynamicImageRef*>(this)->p).GetLoadAddress() ==
|
||||
(*const_cast<DynamicImageRef&>(inInfo)).GetLoadAddress();
|
||||
}
|
||||
|
||||
// Be just like DynamicImage*
|
||||
DynamicImage *operator->() {return p;}
|
||||
DynamicImage* operator->() {return p;}
|
||||
operator DynamicImage*() {return p;}
|
||||
|
||||
private:
|
||||
DynamicImage *p;
|
||||
DynamicImage* p;
|
||||
};
|
||||
|
||||
// Helper function to deal with 32-bit/64-bit Mach-O differences.
|
||||
|
@ -250,7 +250,7 @@ class DynamicImages {
|
|||
int GetImageCount() const {return static_cast<int>(image_list_.size());}
|
||||
|
||||
// Returns an individual image.
|
||||
DynamicImage *GetImage(int i) {
|
||||
DynamicImage* GetImage(int i) {
|
||||
if (i < (int)image_list_.size()) {
|
||||
return image_list_[i];
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ class DynamicImages {
|
|||
}
|
||||
|
||||
// Returns the image corresponding to the main executable.
|
||||
DynamicImage *GetExecutableImage();
|
||||
DynamicImage* GetExecutableImage();
|
||||
int GetExecutableImageIndex();
|
||||
|
||||
// Returns the task which we're looking at.
|
||||
|
@ -312,7 +312,7 @@ class DynamicImages {
|
|||
kern_return_t ReadTaskMemory(task_port_t target_task,
|
||||
const uint64_t address,
|
||||
size_t length,
|
||||
vector<uint8_t> &bytes);
|
||||
vector<uint8_t>& bytes);
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ kern_return_t catch_exception_raise(mach_port_t port, mach_port_t failed_thread,
|
|||
}
|
||||
#endif
|
||||
|
||||
ExceptionHandler::ExceptionHandler(const string &dump_path,
|
||||
ExceptionHandler::ExceptionHandler(const string& dump_path,
|
||||
FilterCallback filter,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context,
|
||||
|
@ -304,7 +304,7 @@ bool ExceptionHandler::WriteMinidump(bool write_exception_stream) {
|
|||
}
|
||||
|
||||
// static
|
||||
bool ExceptionHandler::WriteMinidump(const string &dump_path,
|
||||
bool ExceptionHandler::WriteMinidump(const string& dump_path,
|
||||
bool write_exception_stream,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context) {
|
||||
|
@ -316,7 +316,7 @@ bool ExceptionHandler::WriteMinidump(const string &dump_path,
|
|||
// static
|
||||
bool ExceptionHandler::WriteMinidumpForChild(mach_port_t child,
|
||||
mach_port_t child_blamed_thread,
|
||||
const string &dump_path,
|
||||
const string& dump_path,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context) {
|
||||
ScopedTaskSuspend suspend(child);
|
||||
|
|
|
@ -75,7 +75,7 @@ class ExceptionHandler {
|
|||
// attempting to write a minidump. If a FilterCallback returns false, Breakpad
|
||||
// will immediately report the exception as unhandled without writing a
|
||||
// minidump, allowing another handler the opportunity to handle it.
|
||||
typedef bool (*FilterCallback)(void *context);
|
||||
typedef bool (*FilterCallback)(void* context);
|
||||
|
||||
// A callback function to run after the minidump has been written.
|
||||
// |minidump_id| is a unique id for the dump, so the minidump
|
||||
|
@ -85,18 +85,18 @@ class ExceptionHandler {
|
|||
// Return true if the exception was fully handled and breakpad should exit.
|
||||
// Return false to allow any other exception handlers to process the
|
||||
// exception.
|
||||
typedef bool (*MinidumpCallback)(const char *dump_dir,
|
||||
const char *minidump_id,
|
||||
void *context, bool succeeded);
|
||||
typedef bool (*MinidumpCallback)(const char* dump_dir,
|
||||
const char* minidump_id,
|
||||
void* context, bool succeeded);
|
||||
|
||||
// A callback function which will be called directly if an exception occurs.
|
||||
// This bypasses the minidump file writing and simply gives the client
|
||||
// the exception information.
|
||||
typedef bool (*DirectCallback)( void *context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
mach_port_t thread_name);
|
||||
typedef bool (*DirectCallback)(void* context,
|
||||
int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
mach_port_t thread_name);
|
||||
|
||||
// Creates a new ExceptionHandler instance to handle writing minidumps.
|
||||
// Minidump files will be written to dump_path, and the optional callback
|
||||
|
@ -106,22 +106,22 @@ class ExceptionHandler {
|
|||
// be written when WriteMinidump is called.
|
||||
// If port_name is non-NULL, attempt to perform out-of-process dump generation
|
||||
// If port_name is NULL, in-process dump generation will be used.
|
||||
ExceptionHandler(const string &dump_path,
|
||||
ExceptionHandler(const string& dump_path,
|
||||
FilterCallback filter, MinidumpCallback callback,
|
||||
void *callback_context, bool install_handler,
|
||||
const char *port_name);
|
||||
void* callback_context, bool install_handler,
|
||||
const char* port_name);
|
||||
|
||||
// A special constructor if we want to bypass minidump writing and
|
||||
// simply get a callback with the exception information.
|
||||
ExceptionHandler(DirectCallback callback,
|
||||
void *callback_context,
|
||||
void* callback_context,
|
||||
bool install_handler);
|
||||
|
||||
~ExceptionHandler();
|
||||
|
||||
// Get and set the minidump path.
|
||||
string dump_path() const { return dump_path_; }
|
||||
void set_dump_path(const string &dump_path) {
|
||||
void set_dump_path(const string& dump_path) {
|
||||
dump_path_ = dump_path;
|
||||
dump_path_c_ = dump_path_.c_str();
|
||||
UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_.
|
||||
|
@ -137,23 +137,23 @@ class ExceptionHandler {
|
|||
|
||||
// Convenience form of WriteMinidump which does not require an
|
||||
// ExceptionHandler instance.
|
||||
static bool WriteMinidump(const string &dump_path, MinidumpCallback callback,
|
||||
void *callback_context) {
|
||||
static bool WriteMinidump(const string& dump_path, MinidumpCallback callback,
|
||||
void* callback_context) {
|
||||
return WriteMinidump(dump_path, false, callback, callback_context);
|
||||
}
|
||||
|
||||
static bool WriteMinidump(const string &dump_path,
|
||||
static bool WriteMinidump(const string& dump_path,
|
||||
bool write_exception_stream,
|
||||
MinidumpCallback callback,
|
||||
void *callback_context);
|
||||
void* callback_context);
|
||||
|
||||
// Write a minidump of child immediately. This can be used to capture
|
||||
// the execution state of a child process independently of a crash.
|
||||
static bool WriteMinidumpForChild(mach_port_t child,
|
||||
mach_port_t child_blamed_thread,
|
||||
const std::string &dump_path,
|
||||
MinidumpCallback callback,
|
||||
void *callback_context);
|
||||
mach_port_t child_blamed_thread,
|
||||
const std::string& dump_path,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context);
|
||||
|
||||
// Returns whether out-of-process dump generation is used or not.
|
||||
bool IsOutOfProcess() const {
|
||||
|
@ -189,21 +189,21 @@ class ExceptionHandler {
|
|||
bool WriteMinidumpWithException(int exception_type,
|
||||
int exception_code,
|
||||
int exception_subcode,
|
||||
breakpad_ucontext_t *task_context,
|
||||
breakpad_ucontext_t* task_context,
|
||||
mach_port_t thread_name,
|
||||
bool exit_after_write,
|
||||
bool report_current_thread);
|
||||
|
||||
// When installed, this static function will be call from a newly created
|
||||
// pthread with |this| as the argument
|
||||
static void *WaitForMessage(void *exception_handler_class);
|
||||
static void* WaitForMessage(void* exception_handler_class);
|
||||
|
||||
// Signal handler for SIGABRT.
|
||||
static void SignalHandler(int sig, siginfo_t* info, void* uc);
|
||||
|
||||
// disallow copy ctor and operator=
|
||||
explicit ExceptionHandler(const ExceptionHandler &);
|
||||
void operator=(const ExceptionHandler &);
|
||||
explicit ExceptionHandler(const ExceptionHandler&);
|
||||
void operator=(const ExceptionHandler&);
|
||||
|
||||
// Generates a new ID and stores it in next_minidump_id_, and stores the
|
||||
// path of the next minidump to be written in next_minidump_path_.
|
||||
|
@ -224,15 +224,15 @@ class ExceptionHandler {
|
|||
string next_minidump_path_;
|
||||
|
||||
// Pointers to the UTF-8 versions of above
|
||||
const char *dump_path_c_;
|
||||
const char *next_minidump_id_c_;
|
||||
const char *next_minidump_path_c_;
|
||||
const char* dump_path_c_;
|
||||
const char* next_minidump_id_c_;
|
||||
const char* next_minidump_path_c_;
|
||||
|
||||
// The callback function and pointer to be passed back after the minidump
|
||||
// has been written
|
||||
FilterCallback filter_;
|
||||
MinidumpCallback callback_;
|
||||
void *callback_context_;
|
||||
void* callback_context_;
|
||||
|
||||
// The callback function to be passed back when we don't want a minidump
|
||||
// file to be written
|
||||
|
@ -247,7 +247,7 @@ class ExceptionHandler {
|
|||
|
||||
// These variables save the previous exception handler's data so that it
|
||||
// can be re-installed when this handler is uninstalled
|
||||
ExceptionParameters *previous_;
|
||||
ExceptionParameters* previous_;
|
||||
|
||||
// True, if we've installed the exception handler
|
||||
bool installed_exception_handler_;
|
||||
|
|
|
@ -191,12 +191,12 @@ void MinidumpGenerator::GatherSystemInformation() {
|
|||
os_build_number_ = IntegerValueAtIndex(product_str, 2);
|
||||
}
|
||||
|
||||
void MinidumpGenerator::SetTaskContext(breakpad_ucontext_t *task_context) {
|
||||
void MinidumpGenerator::SetTaskContext(breakpad_ucontext_t* task_context) {
|
||||
task_context_ = task_context;
|
||||
}
|
||||
|
||||
string MinidumpGenerator::UniqueNameInDirectory(const string &dir,
|
||||
string *unique_name) {
|
||||
string MinidumpGenerator::UniqueNameInDirectory(const string& dir,
|
||||
string* unique_name) {
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
CFStringRef uuid_cfstr = CFUUIDCreateString(NULL, uuid);
|
||||
CFRelease(uuid);
|
||||
|
@ -220,7 +220,7 @@ string MinidumpGenerator::UniqueNameInDirectory(const string &dir,
|
|||
return path;
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::Write(const char *path) {
|
||||
bool MinidumpGenerator::Write(const char* path) {
|
||||
WriteStreamFN writers[] = {
|
||||
&MinidumpGenerator::WriteThreadListStream,
|
||||
&MinidumpGenerator::WriteMemoryListStream,
|
||||
|
@ -256,10 +256,10 @@ bool MinidumpGenerator::Write(const char *path) {
|
|||
if (!dir.AllocateArray(writer_count))
|
||||
return false;
|
||||
|
||||
MDRawHeader *header_ptr = header.get();
|
||||
MDRawHeader* header_ptr = header.get();
|
||||
header_ptr->signature = MD_HEADER_SIGNATURE;
|
||||
header_ptr->version = MD_HEADER_VERSION;
|
||||
time(reinterpret_cast<time_t *>(&(header_ptr->time_date_stamp)));
|
||||
time(reinterpret_cast<time_t*>(&(header_ptr->time_date_stamp)));
|
||||
header_ptr->stream_count = writer_count;
|
||||
header_ptr->stream_directory_rva = dir.position();
|
||||
|
||||
|
@ -335,7 +335,7 @@ size_t MinidumpGenerator::CalculateStackSize(mach_vm_address_t start_addr) {
|
|||
|
||||
bool MinidumpGenerator::WriteStackFromStartAddress(
|
||||
mach_vm_address_t start_addr,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
UntypedMDRVA memory(&writer_);
|
||||
|
||||
bool result = false;
|
||||
|
@ -372,7 +372,7 @@ bool MinidumpGenerator::WriteStackFromStartAddress(
|
|||
|
||||
result = memory.Copy(&stack_memory[0], size);
|
||||
} else {
|
||||
result = memory.Copy(reinterpret_cast<const void *>(start_addr), size);
|
||||
result = memory.Copy(reinterpret_cast<const void*>(start_addr), size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ bool MinidumpGenerator::WriteStackFromStartAddress(
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteStack(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
switch (cpu_type_) {
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
case CPU_TYPE_ARM:
|
||||
|
@ -411,7 +411,7 @@ bool MinidumpGenerator::WriteStack(breakpad_thread_state_data_t state,
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteContext(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location) {
|
||||
MDLocationDescriptor* register_location) {
|
||||
switch (cpu_type_) {
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
case CPU_TYPE_ARM:
|
||||
|
@ -469,33 +469,33 @@ uint64_t MinidumpGenerator::CurrentPCForStack(
|
|||
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
bool MinidumpGenerator::WriteStackARM(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
arm_thread_state_t *machine_state =
|
||||
reinterpret_cast<arm_thread_state_t *>(state);
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
arm_thread_state_t* machine_state =
|
||||
reinterpret_cast<arm_thread_state_t*>(state);
|
||||
mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, sp);
|
||||
return WriteStackFromStartAddress(start_addr, stack_location);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
MinidumpGenerator::CurrentPCForStackARM(breakpad_thread_state_data_t state) {
|
||||
arm_thread_state_t *machine_state =
|
||||
reinterpret_cast<arm_thread_state_t *>(state);
|
||||
arm_thread_state_t* machine_state =
|
||||
reinterpret_cast<arm_thread_state_t*>(state);
|
||||
|
||||
return REGISTER_FROM_THREADSTATE(machine_state, pc);
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteContextARM(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location)
|
||||
MDLocationDescriptor* register_location)
|
||||
{
|
||||
TypedMDRVA<MDRawContextARM> context(&writer_);
|
||||
arm_thread_state_t *machine_state =
|
||||
reinterpret_cast<arm_thread_state_t *>(state);
|
||||
arm_thread_state_t* machine_state =
|
||||
reinterpret_cast<arm_thread_state_t*>(state);
|
||||
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
|
||||
*register_location = context.location();
|
||||
MDRawContextARM *context_ptr = context.get();
|
||||
MDRawContextARM* context_ptr = context.get();
|
||||
context_ptr->context_flags = MD_CONTEXT_ARM_FULL;
|
||||
|
||||
#define AddGPR(a) context_ptr->iregs[a] = REGISTER_FROM_THREADSTATE(machine_state, r[a])
|
||||
|
@ -526,34 +526,34 @@ bool MinidumpGenerator::WriteContextARM(breakpad_thread_state_data_t state,
|
|||
|
||||
#ifdef HAS_ARM64_SUPPORT
|
||||
bool MinidumpGenerator::WriteStackARM64(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
arm_thread_state64_t *machine_state =
|
||||
reinterpret_cast<arm_thread_state64_t *>(state);
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
arm_thread_state64_t* machine_state =
|
||||
reinterpret_cast<arm_thread_state64_t*>(state);
|
||||
mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, sp);
|
||||
return WriteStackFromStartAddress(start_addr, stack_location);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
MinidumpGenerator::CurrentPCForStackARM64(breakpad_thread_state_data_t state) {
|
||||
arm_thread_state64_t *machine_state =
|
||||
reinterpret_cast<arm_thread_state64_t *>(state);
|
||||
arm_thread_state64_t* machine_state =
|
||||
reinterpret_cast<arm_thread_state64_t*>(state);
|
||||
|
||||
return REGISTER_FROM_THREADSTATE(machine_state, pc);
|
||||
}
|
||||
|
||||
bool
|
||||
MinidumpGenerator::WriteContextARM64(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location)
|
||||
MDLocationDescriptor* register_location)
|
||||
{
|
||||
TypedMDRVA<MDRawContextARM64_Old> context(&writer_);
|
||||
arm_thread_state64_t *machine_state =
|
||||
reinterpret_cast<arm_thread_state64_t *>(state);
|
||||
arm_thread_state64_t* machine_state =
|
||||
reinterpret_cast<arm_thread_state64_t*>(state);
|
||||
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
|
||||
*register_location = context.location();
|
||||
MDRawContextARM64_Old *context_ptr = context.get();
|
||||
MDRawContextARM64_Old* context_ptr = context.get();
|
||||
context_ptr->context_flags = MD_CONTEXT_ARM64_FULL_OLD;
|
||||
|
||||
#define AddGPR(a) \
|
||||
|
@ -602,49 +602,49 @@ MinidumpGenerator::WriteContextARM64(breakpad_thread_state_data_t state,
|
|||
|
||||
#ifdef HAS_PCC_SUPPORT
|
||||
bool MinidumpGenerator::WriteStackPPC(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
ppc_thread_state_t *machine_state =
|
||||
reinterpret_cast<ppc_thread_state_t *>(state);
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
ppc_thread_state_t* machine_state =
|
||||
reinterpret_cast<ppc_thread_state_t*>(state);
|
||||
mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, r1);
|
||||
return WriteStackFromStartAddress(start_addr, stack_location);
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteStackPPC64(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
ppc_thread_state64_t *machine_state =
|
||||
reinterpret_cast<ppc_thread_state64_t *>(state);
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
ppc_thread_state64_t* machine_state =
|
||||
reinterpret_cast<ppc_thread_state64_t*>(state);
|
||||
mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, r1);
|
||||
return WriteStackFromStartAddress(start_addr, stack_location);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
MinidumpGenerator::CurrentPCForStackPPC(breakpad_thread_state_data_t state) {
|
||||
ppc_thread_state_t *machine_state =
|
||||
reinterpret_cast<ppc_thread_state_t *>(state);
|
||||
ppc_thread_state_t* machine_state =
|
||||
reinterpret_cast<ppc_thread_state_t*>(state);
|
||||
|
||||
return REGISTER_FROM_THREADSTATE(machine_state, srr0);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
MinidumpGenerator::CurrentPCForStackPPC64(breakpad_thread_state_data_t state) {
|
||||
ppc_thread_state64_t *machine_state =
|
||||
reinterpret_cast<ppc_thread_state64_t *>(state);
|
||||
ppc_thread_state64_t* machine_state =
|
||||
reinterpret_cast<ppc_thread_state64_t*>(state);
|
||||
|
||||
return REGISTER_FROM_THREADSTATE(machine_state, srr0);
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteContextPPC(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location)
|
||||
MDLocationDescriptor* register_location)
|
||||
{
|
||||
TypedMDRVA<MDRawContextPPC> context(&writer_);
|
||||
ppc_thread_state_t *machine_state =
|
||||
reinterpret_cast<ppc_thread_state_t *>(state);
|
||||
ppc_thread_state_t* machine_state =
|
||||
reinterpret_cast<ppc_thread_state_t*>(state);
|
||||
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
|
||||
*register_location = context.location();
|
||||
MDRawContextPPC *context_ptr = context.get();
|
||||
MDRawContextPPC* context_ptr = context.get();
|
||||
context_ptr->context_flags = MD_CONTEXT_PPC_BASE;
|
||||
|
||||
#define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \
|
||||
|
@ -701,16 +701,16 @@ bool MinidumpGenerator::WriteContextPPC(breakpad_thread_state_data_t state,
|
|||
|
||||
bool MinidumpGenerator::WriteContextPPC64(
|
||||
breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location) {
|
||||
MDLocationDescriptor* register_location) {
|
||||
TypedMDRVA<MDRawContextPPC64> context(&writer_);
|
||||
ppc_thread_state64_t *machine_state =
|
||||
reinterpret_cast<ppc_thread_state64_t *>(state);
|
||||
ppc_thread_state64_t* machine_state =
|
||||
reinterpret_cast<ppc_thread_state64_t*>(state);
|
||||
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
|
||||
*register_location = context.location();
|
||||
MDRawContextPPC64 *context_ptr = context.get();
|
||||
MDRawContextPPC64* context_ptr = context.get();
|
||||
context_ptr->context_flags = MD_CONTEXT_PPC_BASE;
|
||||
|
||||
#define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \
|
||||
|
@ -768,18 +768,18 @@ bool MinidumpGenerator::WriteContextPPC64(
|
|||
|
||||
#ifdef HAS_X86_SUPPORT
|
||||
bool MinidumpGenerator::WriteStackX86(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
i386_thread_state_t *machine_state =
|
||||
reinterpret_cast<i386_thread_state_t *>(state);
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
i386_thread_state_t* machine_state =
|
||||
reinterpret_cast<i386_thread_state_t*>(state);
|
||||
|
||||
mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, esp);
|
||||
return WriteStackFromStartAddress(start_addr, stack_location);
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteStackX86_64(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location) {
|
||||
x86_thread_state64_t *machine_state =
|
||||
reinterpret_cast<x86_thread_state64_t *>(state);
|
||||
MDMemoryDescriptor* stack_location) {
|
||||
x86_thread_state64_t* machine_state =
|
||||
reinterpret_cast<x86_thread_state64_t*>(state);
|
||||
|
||||
mach_vm_address_t start_addr = static_cast<mach_vm_address_t>(
|
||||
REGISTER_FROM_THREADSTATE(machine_state, rsp));
|
||||
|
@ -788,32 +788,32 @@ bool MinidumpGenerator::WriteStackX86_64(breakpad_thread_state_data_t state,
|
|||
|
||||
uint64_t
|
||||
MinidumpGenerator::CurrentPCForStackX86(breakpad_thread_state_data_t state) {
|
||||
i386_thread_state_t *machine_state =
|
||||
reinterpret_cast<i386_thread_state_t *>(state);
|
||||
i386_thread_state_t* machine_state =
|
||||
reinterpret_cast<i386_thread_state_t*>(state);
|
||||
|
||||
return REGISTER_FROM_THREADSTATE(machine_state, eip);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
MinidumpGenerator::CurrentPCForStackX86_64(breakpad_thread_state_data_t state) {
|
||||
x86_thread_state64_t *machine_state =
|
||||
reinterpret_cast<x86_thread_state64_t *>(state);
|
||||
x86_thread_state64_t* machine_state =
|
||||
reinterpret_cast<x86_thread_state64_t*>(state);
|
||||
|
||||
return REGISTER_FROM_THREADSTATE(machine_state, rip);
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteContextX86(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location)
|
||||
MDLocationDescriptor* register_location)
|
||||
{
|
||||
TypedMDRVA<MDRawContextX86> context(&writer_);
|
||||
i386_thread_state_t *machine_state =
|
||||
reinterpret_cast<i386_thread_state_t *>(state);
|
||||
i386_thread_state_t* machine_state =
|
||||
reinterpret_cast<i386_thread_state_t*>(state);
|
||||
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
|
||||
*register_location = context.location();
|
||||
MDRawContextX86 *context_ptr = context.get();
|
||||
MDRawContextX86* context_ptr = context.get();
|
||||
|
||||
#define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \
|
||||
REGISTER_FROM_THREADSTATE(machine_state, a))
|
||||
|
@ -844,16 +844,16 @@ bool MinidumpGenerator::WriteContextX86(breakpad_thread_state_data_t state,
|
|||
|
||||
bool MinidumpGenerator::WriteContextX86_64(
|
||||
breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location) {
|
||||
MDLocationDescriptor* register_location) {
|
||||
TypedMDRVA<MDRawContextAMD64> context(&writer_);
|
||||
x86_thread_state64_t *machine_state =
|
||||
reinterpret_cast<x86_thread_state64_t *>(state);
|
||||
x86_thread_state64_t* machine_state =
|
||||
reinterpret_cast<x86_thread_state64_t*>(state);
|
||||
|
||||
if (!context.Allocate())
|
||||
return false;
|
||||
|
||||
*register_location = context.location();
|
||||
MDRawContextAMD64 *context_ptr = context.get();
|
||||
MDRawContextAMD64* context_ptr = context.get();
|
||||
|
||||
#define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \
|
||||
REGISTER_FROM_THREADSTATE(machine_state, a))
|
||||
|
@ -892,7 +892,7 @@ bool MinidumpGenerator::WriteContextX86_64(
|
|||
|
||||
bool MinidumpGenerator::GetThreadState(thread_act_t target_thread,
|
||||
thread_state_t state,
|
||||
mach_msg_type_number_t *count) {
|
||||
mach_msg_type_number_t* count) {
|
||||
if (task_context_ && target_thread == mach_thread_self()) {
|
||||
switch (cpu_type_) {
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
|
@ -963,7 +963,7 @@ bool MinidumpGenerator::GetThreadState(thread_act_t target_thread,
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteThreadStream(mach_port_t thread_id,
|
||||
MDRawThread *thread) {
|
||||
MDRawThread* thread) {
|
||||
breakpad_thread_state_data_t state;
|
||||
mach_msg_type_number_t state_count
|
||||
= static_cast<mach_msg_type_number_t>(sizeof(state));
|
||||
|
@ -986,7 +986,7 @@ bool MinidumpGenerator::WriteThreadStream(mach_port_t thread_id,
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteThreadListStream(
|
||||
MDRawDirectory *thread_list_stream) {
|
||||
MDRawDirectory* thread_list_stream) {
|
||||
TypedMDRVA<MDRawThreadList> list(&writer_);
|
||||
thread_act_port_array_t threads_for_task;
|
||||
mach_msg_type_number_t thread_count;
|
||||
|
@ -1027,7 +1027,7 @@ bool MinidumpGenerator::WriteThreadListStream(
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteMemoryListStream(
|
||||
MDRawDirectory *memory_list_stream) {
|
||||
MDRawDirectory* memory_list_stream) {
|
||||
TypedMDRVA<MDRawMemoryList> list(&writer_);
|
||||
|
||||
// If the dump has an exception, include some memory around the
|
||||
|
@ -1119,7 +1119,7 @@ bool MinidumpGenerator::WriteMemoryListStream(
|
|||
} else {
|
||||
// In-process, just copy from local memory.
|
||||
ip_memory.Copy(
|
||||
reinterpret_cast<const void *>(ip_memory_d.start_of_memory_range),
|
||||
reinterpret_cast<const void*>(ip_memory_d.start_of_memory_range),
|
||||
ip_memory_d.memory.data_size);
|
||||
}
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ bool MinidumpGenerator::WriteMemoryListStream(
|
|||
}
|
||||
|
||||
bool
|
||||
MinidumpGenerator::WriteExceptionStream(MDRawDirectory *exception_stream) {
|
||||
MinidumpGenerator::WriteExceptionStream(MDRawDirectory* exception_stream) {
|
||||
TypedMDRVA<MDRawExceptionStream> exception(&writer_);
|
||||
|
||||
if (!exception.Allocate())
|
||||
|
@ -1141,7 +1141,7 @@ MinidumpGenerator::WriteExceptionStream(MDRawDirectory *exception_stream) {
|
|||
|
||||
exception_stream->stream_type = MD_EXCEPTION_STREAM;
|
||||
exception_stream->location = exception.location();
|
||||
MDRawExceptionStream *exception_ptr = exception.get();
|
||||
MDRawExceptionStream* exception_ptr = exception.get();
|
||||
exception_ptr->thread_id = exception_thread_;
|
||||
|
||||
// This naming is confusing, but it is the proper translation from
|
||||
|
@ -1168,7 +1168,7 @@ MinidumpGenerator::WriteExceptionStream(MDRawDirectory *exception_stream) {
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteSystemInfoStream(
|
||||
MDRawDirectory *system_info_stream) {
|
||||
MDRawDirectory* system_info_stream) {
|
||||
TypedMDRVA<MDRawSystemInfo> info(&writer_);
|
||||
|
||||
if (!info.Allocate())
|
||||
|
@ -1181,7 +1181,7 @@ bool MinidumpGenerator::WriteSystemInfoStream(
|
|||
uint32_t number_of_processors;
|
||||
size_t len = sizeof(number_of_processors);
|
||||
sysctlbyname("hw.ncpu", &number_of_processors, &len, NULL, 0);
|
||||
MDRawSystemInfo *info_ptr = info.get();
|
||||
MDRawSystemInfo* info_ptr = info.get();
|
||||
|
||||
switch (cpu_type_) {
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
|
@ -1292,10 +1292,10 @@ bool MinidumpGenerator::WriteSystemInfoStream(
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteModuleStream(unsigned int index,
|
||||
MDRawModule *module) {
|
||||
MDRawModule* module) {
|
||||
if (dynamic_images_) {
|
||||
// we're in a different process than the crashed process
|
||||
DynamicImage *image = dynamic_images_->GetImage(index);
|
||||
DynamicImage* image = dynamic_images_->GetImage(index);
|
||||
|
||||
if (!image)
|
||||
return false;
|
||||
|
@ -1337,7 +1337,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index,
|
|||
}
|
||||
} else {
|
||||
// Getting module info in the crashed process
|
||||
const breakpad_mach_header *header;
|
||||
const breakpad_mach_header* header;
|
||||
header = (breakpad_mach_header*)_dyld_get_image_header(index);
|
||||
if (!header)
|
||||
return false;
|
||||
|
@ -1357,16 +1357,16 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index,
|
|||
int cpu_type = header->cputype;
|
||||
unsigned long slide = _dyld_get_image_vmaddr_slide(index);
|
||||
const char* name = _dyld_get_image_name(index);
|
||||
const struct load_command *cmd =
|
||||
reinterpret_cast<const struct load_command *>(header + 1);
|
||||
const struct load_command* cmd =
|
||||
reinterpret_cast<const struct load_command*>(header + 1);
|
||||
|
||||
memset(module, 0, sizeof(MDRawModule));
|
||||
|
||||
for (unsigned int i = 0; cmd && (i < header->ncmds); i++) {
|
||||
if (cmd->cmd == LC_SEGMENT_ARCH) {
|
||||
|
||||
const breakpad_mach_segment_command *seg =
|
||||
reinterpret_cast<const breakpad_mach_segment_command *>(cmd);
|
||||
const breakpad_mach_segment_command* seg =
|
||||
reinterpret_cast<const breakpad_mach_segment_command*>(cmd);
|
||||
|
||||
if (!strcmp(seg->segname, "__TEXT")) {
|
||||
MDLocationDescriptor string_location;
|
||||
|
@ -1389,7 +1389,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index,
|
|||
}
|
||||
}
|
||||
|
||||
cmd = reinterpret_cast<struct load_command*>((char *)cmd + cmd->cmdsize);
|
||||
cmd = reinterpret_cast<struct load_command*>((char*)cmd + cmd->cmdsize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ int MinidumpGenerator::FindExecutableModule() {
|
|||
}
|
||||
} else {
|
||||
int image_count = _dyld_image_count();
|
||||
const struct mach_header *header;
|
||||
const struct mach_header* header;
|
||||
|
||||
for (int index = 0; index < image_count; ++index) {
|
||||
header = _dyld_get_image_header(index);
|
||||
|
@ -1419,12 +1419,12 @@ int MinidumpGenerator::FindExecutableModule() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type,
|
||||
const char *module_path, bool in_memory) {
|
||||
bool MinidumpGenerator::WriteCVRecord(MDRawModule* module, int cpu_type,
|
||||
const char* module_path, bool in_memory) {
|
||||
TypedMDRVA<MDCVInfoPDB70> cv(&writer_);
|
||||
|
||||
// Only return the last path component of the full module path
|
||||
const char *module_name = strrchr(module_path, '/');
|
||||
const char* module_name = strrchr(module_path, '/');
|
||||
|
||||
// Increment past the slash
|
||||
if (module_name)
|
||||
|
@ -1441,7 +1441,7 @@ bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type,
|
|||
return false;
|
||||
|
||||
module->cv_record = cv.location();
|
||||
MDCVInfoPDB70 *cv_ptr = cv.get();
|
||||
MDCVInfoPDB70* cv_ptr = cv.get();
|
||||
cv_ptr->cv_signature = MD_CVINFOPDB70_SIGNATURE;
|
||||
cv_ptr->age = 0;
|
||||
|
||||
|
@ -1450,7 +1450,7 @@ bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type,
|
|||
bool result = false;
|
||||
if (in_memory) {
|
||||
MacFileUtilities::MachoID macho(module_path,
|
||||
reinterpret_cast<void *>(module->base_of_image),
|
||||
reinterpret_cast<void*>(module->base_of_image),
|
||||
static_cast<size_t>(module->size_of_image));
|
||||
result = macho.UUIDCommand(cpu_type, CPU_SUBTYPE_MULTIPLE, identifier);
|
||||
if (!result)
|
||||
|
@ -1487,7 +1487,7 @@ bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type,
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteModuleListStream(
|
||||
MDRawDirectory *module_list_stream) {
|
||||
MDRawDirectory* module_list_stream) {
|
||||
TypedMDRVA<MDRawModuleList> list(&writer_);
|
||||
|
||||
uint32_t image_count = dynamic_images_ ?
|
||||
|
@ -1525,7 +1525,7 @@ bool MinidumpGenerator::WriteModuleListStream(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) {
|
||||
bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory* misc_info_stream) {
|
||||
TypedMDRVA<MDRawMiscInfo> info(&writer_);
|
||||
|
||||
if (!info.Allocate())
|
||||
|
@ -1534,7 +1534,7 @@ bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) {
|
|||
misc_info_stream->stream_type = MD_MISC_INFO_STREAM;
|
||||
misc_info_stream->location = info.location();
|
||||
|
||||
MDRawMiscInfo *info_ptr = info.get();
|
||||
MDRawMiscInfo* info_ptr = info.get();
|
||||
info_ptr->size_of_info = static_cast<uint32_t>(sizeof(MDRawMiscInfo));
|
||||
info_ptr->flags1 = MD_MISCINFO_FLAGS1_PROCESS_ID |
|
||||
MD_MISCINFO_FLAGS1_PROCESS_TIMES |
|
||||
|
@ -1577,7 +1577,7 @@ bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) {
|
|||
}
|
||||
|
||||
bool MinidumpGenerator::WriteBreakpadInfoStream(
|
||||
MDRawDirectory *breakpad_info_stream) {
|
||||
MDRawDirectory* breakpad_info_stream) {
|
||||
TypedMDRVA<MDRawBreakpadInfo> info(&writer_);
|
||||
|
||||
if (!info.Allocate())
|
||||
|
@ -1585,7 +1585,7 @@ bool MinidumpGenerator::WriteBreakpadInfoStream(
|
|||
|
||||
breakpad_info_stream->stream_type = MD_BREAKPAD_INFO_STREAM;
|
||||
breakpad_info_stream->location = info.location();
|
||||
MDRawBreakpadInfo *info_ptr = info.get();
|
||||
MDRawBreakpadInfo* info_ptr = info.get();
|
||||
|
||||
if (exception_thread_ && exception_type_) {
|
||||
info_ptr->validity = MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID |
|
||||
|
|
|
@ -106,12 +106,12 @@ class MinidumpGenerator {
|
|||
|
||||
// Return <dir>/<unique_name>.dmp
|
||||
// Sets |unique_name| (if requested) to the unique name for the minidump
|
||||
static string UniqueNameInDirectory(const string &dir, string *unique_name);
|
||||
static string UniqueNameInDirectory(const string& dir, string* unique_name);
|
||||
|
||||
// Write out the minidump into |path|
|
||||
// All of the components of |path| must exist and be writable
|
||||
// Return true if successful, false otherwise
|
||||
bool Write(const char *path);
|
||||
bool Write(const char* path);
|
||||
|
||||
// Specify some exception information, if applicable
|
||||
void SetExceptionInformation(int type, int code, int subcode,
|
||||
|
@ -125,7 +125,7 @@ class MinidumpGenerator {
|
|||
// Specify the task context. If |task_context| is not NULL, it will be used
|
||||
// to retrieve the context of the current thread, instead of using
|
||||
// |thread_get_state|.
|
||||
void SetTaskContext(breakpad_ucontext_t *task_context);
|
||||
void SetTaskContext(breakpad_ucontext_t* task_context);
|
||||
|
||||
// Gather system information. This should be call at least once before using
|
||||
// the MinidumpGenerator class.
|
||||
|
@ -133,81 +133,81 @@ class MinidumpGenerator {
|
|||
|
||||
protected:
|
||||
// Overridable Stream writers
|
||||
virtual bool WriteExceptionStream(MDRawDirectory *exception_stream);
|
||||
virtual bool WriteExceptionStream(MDRawDirectory* exception_stream);
|
||||
|
||||
// Overridable Helper
|
||||
virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread *thread);
|
||||
virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread* thread);
|
||||
|
||||
private:
|
||||
typedef bool (MinidumpGenerator::*WriteStreamFN)(MDRawDirectory *);
|
||||
typedef bool (MinidumpGenerator::*WriteStreamFN)(MDRawDirectory*);
|
||||
|
||||
// Stream writers
|
||||
bool WriteThreadListStream(MDRawDirectory *thread_list_stream);
|
||||
bool WriteMemoryListStream(MDRawDirectory *memory_list_stream);
|
||||
bool WriteSystemInfoStream(MDRawDirectory *system_info_stream);
|
||||
bool WriteModuleListStream(MDRawDirectory *module_list_stream);
|
||||
bool WriteMiscInfoStream(MDRawDirectory *misc_info_stream);
|
||||
bool WriteBreakpadInfoStream(MDRawDirectory *breakpad_info_stream);
|
||||
bool WriteThreadListStream(MDRawDirectory* thread_list_stream);
|
||||
bool WriteMemoryListStream(MDRawDirectory* memory_list_stream);
|
||||
bool WriteSystemInfoStream(MDRawDirectory* system_info_stream);
|
||||
bool WriteModuleListStream(MDRawDirectory* module_list_stream);
|
||||
bool WriteMiscInfoStream(MDRawDirectory* misc_info_stream);
|
||||
bool WriteBreakpadInfoStream(MDRawDirectory* breakpad_info_stream);
|
||||
|
||||
// Helpers
|
||||
uint64_t CurrentPCForStack(breakpad_thread_state_data_t state);
|
||||
bool GetThreadState(thread_act_t target_thread, thread_state_t state,
|
||||
mach_msg_type_number_t *count);
|
||||
mach_msg_type_number_t* count);
|
||||
bool WriteStackFromStartAddress(mach_vm_address_t start_addr,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteStack(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContext(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
bool WriteCVRecord(MDRawModule *module, int cpu_type,
|
||||
const char *module_path, bool in_memory);
|
||||
bool WriteModuleStream(unsigned int index, MDRawModule *module);
|
||||
MDLocationDescriptor* register_location);
|
||||
bool WriteCVRecord(MDRawModule* module, int cpu_type,
|
||||
const char* module_path, bool in_memory);
|
||||
bool WriteModuleStream(unsigned int index, MDRawModule* module);
|
||||
size_t CalculateStackSize(mach_vm_address_t start_addr);
|
||||
int FindExecutableModule();
|
||||
|
||||
// Per-CPU implementations of these methods
|
||||
#ifdef HAS_ARM_SUPPORT
|
||||
bool WriteStackARM(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContextARM(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
MDLocationDescriptor* register_location);
|
||||
uint64_t CurrentPCForStackARM(breakpad_thread_state_data_t state);
|
||||
#endif
|
||||
#ifdef HAS_ARM64_SUPPORT
|
||||
bool WriteStackARM64(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContextARM64(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
MDLocationDescriptor* register_location);
|
||||
uint64_t CurrentPCForStackARM64(breakpad_thread_state_data_t state);
|
||||
#endif
|
||||
#ifdef HAS_PPC_SUPPORT
|
||||
bool WriteStackPPC(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContextPPC(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
MDLocationDescriptor* register_location);
|
||||
uint64_t CurrentPCForStackPPC(breakpad_thread_state_data_t state);
|
||||
bool WriteStackPPC64(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContextPPC64(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
MDLocationDescriptor* register_location);
|
||||
uint64_t CurrentPCForStackPPC64(breakpad_thread_state_data_t state);
|
||||
#endif
|
||||
#ifdef HAS_X86_SUPPORT
|
||||
bool WriteStackX86(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContextX86(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
MDLocationDescriptor* register_location);
|
||||
uint64_t CurrentPCForStackX86(breakpad_thread_state_data_t state);
|
||||
bool WriteStackX86_64(breakpad_thread_state_data_t state,
|
||||
MDMemoryDescriptor *stack_location);
|
||||
MDMemoryDescriptor* stack_location);
|
||||
bool WriteContextX86_64(breakpad_thread_state_data_t state,
|
||||
MDLocationDescriptor *register_location);
|
||||
MDLocationDescriptor* register_location);
|
||||
uint64_t CurrentPCForStackX86_64(breakpad_thread_state_data_t state);
|
||||
#endif
|
||||
|
||||
// disallow copy ctor and operator=
|
||||
explicit MinidumpGenerator(const MinidumpGenerator &);
|
||||
void operator=(const MinidumpGenerator &);
|
||||
explicit MinidumpGenerator(const MinidumpGenerator&);
|
||||
void operator=(const MinidumpGenerator&);
|
||||
|
||||
protected:
|
||||
// Use this writer to put the data to disk
|
||||
|
@ -232,10 +232,10 @@ class MinidumpGenerator {
|
|||
static int os_build_number_;
|
||||
|
||||
// Context of the task to dump.
|
||||
breakpad_ucontext_t *task_context_;
|
||||
breakpad_ucontext_t* task_context_;
|
||||
|
||||
// Information about dynamically loaded code
|
||||
DynamicImages *dynamic_images_;
|
||||
DynamicImages* dynamic_images_;
|
||||
|
||||
// PageAllocator makes it possible to allocate memory
|
||||
// directly from the system, even while handling an exception.
|
||||
|
|
|
@ -42,7 +42,7 @@ DynamicImagesTests test2(TEST_INVOCATION(DynamicImagesTests,
|
|||
DynamicImagesTests test3(TEST_INVOCATION(DynamicImagesTests,
|
||||
ReadLibrariesFromLocalTaskTest));
|
||||
|
||||
DynamicImagesTests::DynamicImagesTests(TestInvocation *invocation)
|
||||
DynamicImagesTests::DynamicImagesTests(TestInvocation* invocation)
|
||||
: TestCase(invocation) {
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ void DynamicImagesTests::ReadTaskMemoryTest() {
|
|||
|
||||
// pick test2 as a symbol we know to be valid to read
|
||||
// anything will work, really
|
||||
void *addr = reinterpret_cast<void*>(&test2);
|
||||
void* addr = reinterpret_cast<void*>(&test2);
|
||||
std::vector<uint8_t> buf(getpagesize());
|
||||
|
||||
fprintf(stderr, "reading 0x%p\n", addr);
|
||||
|
@ -71,7 +71,7 @@ void DynamicImagesTests::ReadTaskMemoryTest() {
|
|||
void DynamicImagesTests::ReadLibrariesFromLocalTaskTest() {
|
||||
|
||||
mach_port_t me = mach_task_self();
|
||||
google_breakpad::DynamicImages *d = new google_breakpad::DynamicImages(me);
|
||||
google_breakpad::DynamicImages* d = new google_breakpad::DynamicImages(me);
|
||||
|
||||
fprintf(stderr,"Local task image count: %d\n", d->GetImageCount());
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
BreakpadNlistTest test1(TEST_INVOCATION(BreakpadNlistTest, CompareToNM));
|
||||
|
||||
BreakpadNlistTest::BreakpadNlistTest(TestInvocation *invocation)
|
||||
BreakpadNlistTest::BreakpadNlistTest(TestInvocation* invocation)
|
||||
: TestCase(invocation) {
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void BreakpadNlistTest::CompareToNM() {
|
|||
system("/usr/bin/nm -arch ppc64 /usr/lib/dyld > /tmp/dyld-namelist.txt");
|
||||
#endif
|
||||
|
||||
FILE *fd = fopen("/tmp/dyld-namelist.txt", "rt");
|
||||
FILE* fd = fopen("/tmp/dyld-namelist.txt", "rt");
|
||||
|
||||
char oneNMAddr[30];
|
||||
char symbolType;
|
||||
|
@ -63,10 +63,10 @@ void BreakpadNlistTest::CompareToNM() {
|
|||
while (!feof(fd)) {
|
||||
fscanf(fd, "%s %c %s", oneNMAddr, &symbolType, symbolName);
|
||||
breakpad_nlist symbolList[2];
|
||||
breakpad_nlist &list = symbolList[0];
|
||||
breakpad_nlist& list = symbolList[0];
|
||||
|
||||
memset(symbolList, 0, sizeof(breakpad_nlist)*2);
|
||||
const char *symbolNames[2];
|
||||
const char* symbolNames[2];
|
||||
symbolNames[0] = (const char*)symbolName;
|
||||
symbolNames[1] = "\0";
|
||||
breakpad_nlist_64("/usr/lib/dyld", &list, symbolNames);
|
||||
|
@ -79,12 +79,12 @@ void BreakpadNlistTest::CompareToNM() {
|
|||
fclose(fd);
|
||||
}
|
||||
|
||||
bool BreakpadNlistTest::IsSymbolMoreThanOnceInDyld(const char *symbolName) {
|
||||
bool BreakpadNlistTest::IsSymbolMoreThanOnceInDyld(const char* symbolName) {
|
||||
// These are the symbols that occur more than once when nm dumps
|
||||
// the symbol table of /usr/lib/dyld. Our nlist program returns
|
||||
// the first address because it's doing a search so we need to exclude
|
||||
// these from causing the test to fail
|
||||
const char *multipleSymbols[] = {
|
||||
const char* multipleSymbols[] = {
|
||||
"__Z41__static_initialization_and_destruction_0ii",
|
||||
"___tcf_0",
|
||||
"___tcf_1",
|
||||
|
|
|
@ -47,7 +47,7 @@ class BreakpadNlistTest : public TestCase {
|
|||
// /usr/lib/dyld. So we track those so we don't report failures
|
||||
// in mismatches between what our nlist returns and what nm has
|
||||
// for the duplicate symbols.
|
||||
bool IsSymbolMoreThanOnceInDyld(const char *symbolName);
|
||||
bool IsSymbolMoreThanOnceInDyld(const char* symbolName);
|
||||
|
||||
public:
|
||||
explicit BreakpadNlistTest(TestInvocation* invocation);
|
||||
|
|
|
@ -30,5 +30,5 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
return NSApplicationMain(argc, (const char **) argv);
|
||||
return NSApplicationMain(argc, (const char**)argv);
|
||||
}
|
||||
|
|
|
@ -147,8 +147,8 @@ TEST_F(CrashGenerationServerTest, testRequestDumpNoDump) {
|
|||
globfree(&dirContents);
|
||||
}
|
||||
|
||||
void dumpCallback(void *context, const ClientInfo &client_info,
|
||||
const std::string &file_path) {
|
||||
void dumpCallback(void* context, const ClientInfo& client_info,
|
||||
const std::string& file_path) {
|
||||
if (context) {
|
||||
CrashGenerationServerTest* self =
|
||||
reinterpret_cast<CrashGenerationServerTest*>(context);
|
||||
|
@ -158,7 +158,7 @@ void dumpCallback(void *context, const ClientInfo &client_info,
|
|||
}
|
||||
}
|
||||
|
||||
void *RequestDump(void *context) {
|
||||
void* RequestDump(void* context) {
|
||||
CrashGenerationClient client((const char*)context);
|
||||
bool result = client.RequestDump();
|
||||
return (void*)(result ? 0 : 1);
|
||||
|
@ -206,7 +206,7 @@ TEST_F(CrashGenerationServerTest, testRequestDump) {
|
|||
}
|
||||
|
||||
static void Crasher() {
|
||||
int *a = (int*)0x42;
|
||||
int* a = (int*)0x42;
|
||||
|
||||
fprintf(stdout, "Going to crash...\n");
|
||||
fprintf(stdout, "A = %d", *a);
|
||||
|
|
|
@ -71,7 +71,7 @@ class ExceptionHandlerTest : public Test {
|
|||
};
|
||||
|
||||
static void Crasher() {
|
||||
int *a = (int*)0x42;
|
||||
int* a = (int*)0x42;
|
||||
|
||||
fprintf(stdout, "Going to crash...\n");
|
||||
fprintf(stdout, "A = %d", *a);
|
||||
|
@ -86,8 +86,8 @@ static void SoonToCrash(void(*crasher)()) {
|
|||
crasher();
|
||||
}
|
||||
|
||||
static bool MDCallback(const char *dump_dir, const char *file_name,
|
||||
void *context, bool success) {
|
||||
static bool MDCallback(const char* dump_dir, const char* file_name,
|
||||
void* context, bool success) {
|
||||
string path(dump_dir);
|
||||
path.append("/");
|
||||
path.append(file_name);
|
||||
|
@ -179,9 +179,9 @@ TEST_F(ExceptionHandlerTest, InProcessAbort) {
|
|||
InProcessCrash(true);
|
||||
}
|
||||
|
||||
static bool DumpNameMDCallback(const char *dump_dir, const char *file_name,
|
||||
void *context, bool success) {
|
||||
ExceptionHandlerTest *self = reinterpret_cast<ExceptionHandlerTest*>(context);
|
||||
static bool DumpNameMDCallback(const char* dump_dir, const char* file_name,
|
||||
void* context, bool success) {
|
||||
ExceptionHandlerTest* self = reinterpret_cast<ExceptionHandlerTest*>(context);
|
||||
if (dump_dir && file_name) {
|
||||
self->lastDumpName = dump_dir;
|
||||
self->lastDumpName += "/";
|
||||
|
@ -652,7 +652,7 @@ TEST_F(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) {
|
|||
ASSERT_EQ((unsigned int)1, memory_list->region_count());
|
||||
}
|
||||
|
||||
static void *Junk(void *) {
|
||||
static void* Junk(void*) {
|
||||
sleep(1000000);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class MinidumpGeneratorTest : public Test {
|
|||
AutoTempDir tempDir;
|
||||
};
|
||||
|
||||
static void *Junk(void* data) {
|
||||
static void* Junk(void* data) {
|
||||
bool* wait = reinterpret_cast<bool*>(data);
|
||||
while (!*wait) {
|
||||
usleep(10000);
|
||||
|
|
|
@ -69,7 +69,7 @@ inline bool TypedMDRVA<MDType>::AllocateObjectAndArray(size_t count,
|
|||
}
|
||||
|
||||
template<typename MDType>
|
||||
inline bool TypedMDRVA<MDType>::CopyIndex(unsigned int index, MDType *item) {
|
||||
inline bool TypedMDRVA<MDType>::CopyIndex(unsigned int index, MDType* item) {
|
||||
assert(allocation_state_ == ARRAY);
|
||||
return writer_->Copy(
|
||||
static_cast<MDRVA>(position_ + index * minidump_size<MDType>::size()),
|
||||
|
@ -78,7 +78,7 @@ inline bool TypedMDRVA<MDType>::CopyIndex(unsigned int index, MDType *item) {
|
|||
|
||||
template<typename MDType>
|
||||
inline bool TypedMDRVA<MDType>::CopyIndexAfterObject(unsigned int index,
|
||||
const void *src,
|
||||
const void* src,
|
||||
size_t length) {
|
||||
assert(allocation_state_ == SINGLE_OBJECT_WITH_ARRAY);
|
||||
return writer_->Copy(
|
||||
|
|
|
@ -101,7 +101,7 @@ MinidumpFileWriter::~MinidumpFileWriter() {
|
|||
Close();
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::Open(const char *path) {
|
||||
bool MinidumpFileWriter::Open(const char* path) {
|
||||
assert(file_ == -1);
|
||||
#if defined(__linux__) && __linux__
|
||||
file_ = sys_open(path, O_WRONLY | O_CREAT | O_EXCL, 0600);
|
||||
|
@ -145,9 +145,9 @@ bool MinidumpFileWriter::Close() {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::CopyStringToMDString(const wchar_t *str,
|
||||
bool MinidumpFileWriter::CopyStringToMDString(const wchar_t* str,
|
||||
unsigned int length,
|
||||
TypedMDRVA<MDString> *mdstring) {
|
||||
TypedMDRVA<MDString>* mdstring) {
|
||||
bool result = true;
|
||||
if (sizeof(wchar_t) == sizeof(uint16_t)) {
|
||||
// Shortcut if wchar_t is the same size as MDString's buffer
|
||||
|
@ -178,9 +178,9 @@ bool MinidumpFileWriter::CopyStringToMDString(const wchar_t *str,
|
|||
return result;
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::CopyStringToMDString(const char *str,
|
||||
bool MinidumpFileWriter::CopyStringToMDString(const char* str,
|
||||
unsigned int length,
|
||||
TypedMDRVA<MDString> *mdstring) {
|
||||
TypedMDRVA<MDString>* mdstring) {
|
||||
bool result = true;
|
||||
uint16_t out[2];
|
||||
int out_idx = 0;
|
||||
|
@ -205,9 +205,9 @@ bool MinidumpFileWriter::CopyStringToMDString(const char *str,
|
|||
}
|
||||
|
||||
template <typename CharType>
|
||||
bool MinidumpFileWriter::WriteStringCore(const CharType *str,
|
||||
bool MinidumpFileWriter::WriteStringCore(const CharType* str,
|
||||
unsigned int length,
|
||||
MDLocationDescriptor *location) {
|
||||
MDLocationDescriptor* location) {
|
||||
assert(str);
|
||||
assert(location);
|
||||
// Calculate the mdstring length by either limiting to |length| as passed in
|
||||
|
@ -240,18 +240,18 @@ bool MinidumpFileWriter::WriteStringCore(const CharType *str,
|
|||
return result;
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::WriteString(const wchar_t *str, unsigned int length,
|
||||
MDLocationDescriptor *location) {
|
||||
bool MinidumpFileWriter::WriteString(const wchar_t* str, unsigned int length,
|
||||
MDLocationDescriptor* location) {
|
||||
return WriteStringCore(str, length, location);
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::WriteString(const char *str, unsigned int length,
|
||||
MDLocationDescriptor *location) {
|
||||
bool MinidumpFileWriter::WriteString(const char* str, unsigned int length,
|
||||
MDLocationDescriptor* location) {
|
||||
return WriteStringCore(str, length, location);
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::WriteMemory(const void *src, size_t size,
|
||||
MDMemoryDescriptor *output) {
|
||||
bool MinidumpFileWriter::WriteMemory(const void* src, size_t size,
|
||||
MDMemoryDescriptor* output) {
|
||||
assert(src);
|
||||
assert(output);
|
||||
UntypedMDRVA mem(this);
|
||||
|
@ -307,7 +307,7 @@ MDRVA MinidumpFileWriter::Allocate(size_t size) {
|
|||
return current_position;
|
||||
}
|
||||
|
||||
bool MinidumpFileWriter::Copy(MDRVA position, const void *src, ssize_t size) {
|
||||
bool MinidumpFileWriter::Copy(MDRVA position, const void* src, ssize_t size) {
|
||||
assert(src);
|
||||
assert(size);
|
||||
assert(file_ != -1);
|
||||
|
@ -340,7 +340,7 @@ bool UntypedMDRVA::Allocate(size_t size) {
|
|||
return position_ != MinidumpFileWriter::kInvalidMDRVA;
|
||||
}
|
||||
|
||||
bool UntypedMDRVA::Copy(MDRVA pos, const void *src, size_t size) {
|
||||
bool UntypedMDRVA::Copy(MDRVA pos, const void* src, size_t size) {
|
||||
assert(src);
|
||||
assert(size);
|
||||
assert(pos + size <= position_ + size_);
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
// Open |path| as the destination of the minidump data. If |path| already
|
||||
// exists, then Open() will fail.
|
||||
// Return true on success, or false on failure.
|
||||
bool Open(const char *path);
|
||||
bool Open(const char* path);
|
||||
|
||||
// Sets the file descriptor |file| as the destination of the minidump data.
|
||||
// Can be used as an alternative to Open() when a file descriptor is
|
||||
|
@ -98,20 +98,20 @@ public:
|
|||
// entire NULL terminated string. Copying will stop at the first NULL.
|
||||
// |location| the allocated location
|
||||
// Return true on success, or false on failure
|
||||
bool WriteString(const wchar_t *str, unsigned int length,
|
||||
MDLocationDescriptor *location);
|
||||
bool WriteString(const wchar_t* str, unsigned int length,
|
||||
MDLocationDescriptor* location);
|
||||
|
||||
// Same as above, except with |str| as a UTF-8 string
|
||||
bool WriteString(const char *str, unsigned int length,
|
||||
MDLocationDescriptor *location);
|
||||
bool WriteString(const char* str, unsigned int length,
|
||||
MDLocationDescriptor* location);
|
||||
|
||||
// Write |size| bytes starting at |src| into the current position.
|
||||
// Return true on success and set |output| to position, or false on failure
|
||||
bool WriteMemory(const void *src, size_t size, MDMemoryDescriptor *output);
|
||||
bool WriteMemory(const void* src, size_t size, MDMemoryDescriptor* output);
|
||||
|
||||
// Copies |size| bytes from |src| to |position|
|
||||
// Return true on success, or false on failure
|
||||
bool Copy(MDRVA position, const void *src, ssize_t size);
|
||||
bool Copy(MDRVA position, const void* src, ssize_t size);
|
||||
|
||||
// Return the current position for writing to the minidump
|
||||
inline MDRVA position() const { return position_; }
|
||||
|
@ -141,21 +141,21 @@ public:
|
|||
// variant may need to create a MDString that has more characters than the
|
||||
// source |str|, whereas the UTF-8 variant may coalesce characters to form
|
||||
// a single UTF-16 character.
|
||||
bool CopyStringToMDString(const wchar_t *str, unsigned int length,
|
||||
TypedMDRVA<MDString> *mdstring);
|
||||
bool CopyStringToMDString(const char *str, unsigned int length,
|
||||
TypedMDRVA<MDString> *mdstring);
|
||||
bool CopyStringToMDString(const wchar_t* str, unsigned int length,
|
||||
TypedMDRVA<MDString>* mdstring);
|
||||
bool CopyStringToMDString(const char* str, unsigned int length,
|
||||
TypedMDRVA<MDString>* mdstring);
|
||||
|
||||
// The common templated code for writing a string
|
||||
template <typename CharType>
|
||||
bool WriteStringCore(const CharType *str, unsigned int length,
|
||||
MDLocationDescriptor *location);
|
||||
bool WriteStringCore(const CharType* str, unsigned int length,
|
||||
MDLocationDescriptor* location);
|
||||
};
|
||||
|
||||
// Represents an untyped allocated chunk
|
||||
class UntypedMDRVA {
|
||||
public:
|
||||
explicit UntypedMDRVA(MinidumpFileWriter *writer)
|
||||
explicit UntypedMDRVA(MinidumpFileWriter* writer)
|
||||
: writer_(writer),
|
||||
position_(writer->position()),
|
||||
size_(0) {}
|
||||
|
@ -179,16 +179,16 @@ class UntypedMDRVA {
|
|||
|
||||
// Copy |size| bytes starting at |src| into the minidump at |position|
|
||||
// Return true on success, or false on failure
|
||||
bool Copy(MDRVA position, const void *src, size_t size);
|
||||
bool Copy(MDRVA position, const void* src, size_t size);
|
||||
|
||||
// Copy |size| bytes from |src| to the current position
|
||||
inline bool Copy(const void *src, size_t size) {
|
||||
inline bool Copy(const void* src, size_t size) {
|
||||
return Copy(position_, src, size);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Writer we associate with
|
||||
MinidumpFileWriter *writer_;
|
||||
MinidumpFileWriter* writer_;
|
||||
|
||||
// Position of the start of the data
|
||||
MDRVA position_;
|
||||
|
@ -206,7 +206,7 @@ template<typename MDType>
|
|||
class TypedMDRVA : public UntypedMDRVA {
|
||||
public:
|
||||
// Constructs an unallocated MDRVA
|
||||
explicit TypedMDRVA(MinidumpFileWriter *writer)
|
||||
explicit TypedMDRVA(MinidumpFileWriter* writer)
|
||||
: UntypedMDRVA(writer),
|
||||
data_(),
|
||||
allocation_state_(UNALLOCATED) {}
|
||||
|
@ -220,7 +220,7 @@ class TypedMDRVA : public UntypedMDRVA {
|
|||
// Address of object data_ of MDType. This is not declared const as the
|
||||
// typical usage will be to access the underlying |data_| object as to
|
||||
// alter its contents.
|
||||
MDType *get() { return &data_; }
|
||||
MDType* get() { return &data_; }
|
||||
|
||||
// Allocates minidump_size<MDType>::size() bytes.
|
||||
// Must not call more than once.
|
||||
|
@ -245,12 +245,12 @@ class TypedMDRVA : public UntypedMDRVA {
|
|||
// Copy |item| to |index|
|
||||
// Must have been allocated using AllocateArray().
|
||||
// Return true on success, or false on failure
|
||||
bool CopyIndex(unsigned int index, MDType *item);
|
||||
bool CopyIndex(unsigned int index, MDType* item);
|
||||
|
||||
// Copy |size| bytes starting at |str| to |index|
|
||||
// Must have been allocated using AllocateObjectAndArray().
|
||||
// Return true on success, or false on failure
|
||||
bool CopyIndexAfterObject(unsigned int index, const void *src, size_t size);
|
||||
bool CopyIndexAfterObject(unsigned int index, const void* src, size_t size);
|
||||
|
||||
// Write data_
|
||||
bool Flush();
|
||||
|
|
|
@ -70,16 +70,16 @@ typedef struct {
|
|||
ArrayStructure array[0];
|
||||
} ObjectAndArrayStructure;
|
||||
|
||||
static bool WriteFile(const char *path) {
|
||||
static bool WriteFile(const char* path) {
|
||||
MinidumpFileWriter writer;
|
||||
if (writer.Open(path)) {
|
||||
// Test a single structure
|
||||
google_breakpad::TypedMDRVA<StringStructure> strings(&writer);
|
||||
ASSERT_TRUE(strings.Allocate());
|
||||
strings.get()->integer_value = 0xBEEF;
|
||||
const char *first = "First String";
|
||||
const char* first = "First String";
|
||||
ASSERT_TRUE(writer.WriteString(first, 0, &strings.get()->first_string));
|
||||
const wchar_t *second = L"Second String";
|
||||
const wchar_t* second = L"Second String";
|
||||
ASSERT_TRUE(writer.WriteString(second, 0, &strings.get()->second_string));
|
||||
|
||||
// Test an array structure
|
||||
|
@ -111,7 +111,7 @@ static bool WriteFile(const char *path) {
|
|||
return writer.Close();
|
||||
}
|
||||
|
||||
static bool CompareFile(const char *path) {
|
||||
static bool CompareFile(const char* path) {
|
||||
unsigned long expected[] = {
|
||||
#if defined(__BIG_ENDIAN__)
|
||||
0x0000beef, 0x0000001e, 0x00000018, 0x00000020, 0x00000038, 0x00000000,
|
||||
|
@ -146,13 +146,14 @@ static bool CompareFile(const char *path) {
|
|||
};
|
||||
size_t expected_byte_count = sizeof(expected);
|
||||
int fd = open(path, O_RDONLY, 0600);
|
||||
void *buffer = malloc(expected_byte_count);
|
||||
void* buffer = malloc(expected_byte_count);
|
||||
ASSERT_NE(fd, -1);
|
||||
ASSERT_TRUE(buffer);
|
||||
ASSERT_EQ(read(fd, buffer, expected_byte_count),
|
||||
static_cast<ssize_t>(expected_byte_count));
|
||||
|
||||
char *b1, *b2;
|
||||
char* b1;
|
||||
char* b2;
|
||||
b1 = reinterpret_cast<char*>(buffer);
|
||||
b2 = reinterpret_cast<char*>(expected);
|
||||
while (*b1 == *b2) {
|
||||
|
@ -167,13 +168,13 @@ static bool CompareFile(const char *path) {
|
|||
}
|
||||
|
||||
static bool RunTests() {
|
||||
const char *path = "/tmp/minidump_file_writer_unittest.dmp";
|
||||
const char* path = "/tmp/minidump_file_writer_unittest.dmp";
|
||||
ASSERT_TRUE(WriteFile(path));
|
||||
ASSERT_TRUE(CompareFile(path));
|
||||
unlink(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" int main(int argc, const char *argv[]) {
|
||||
extern "C" int main(int argc, const char* argv[]) {
|
||||
return RunTests() ? 0 : 1;
|
||||
}
|
||||
|
|
|
@ -54,15 +54,15 @@ static const int kSigTable[] = {
|
|||
SIGBUS
|
||||
};
|
||||
|
||||
std::vector<ExceptionHandler*> *ExceptionHandler::handler_stack_ = NULL;
|
||||
std::vector<ExceptionHandler*>* ExceptionHandler::handler_stack_ = NULL;
|
||||
int ExceptionHandler::handler_stack_index_ = 0;
|
||||
pthread_mutex_t ExceptionHandler::handler_stack_mutex_ =
|
||||
PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
ExceptionHandler::ExceptionHandler(const string &dump_path,
|
||||
ExceptionHandler::ExceptionHandler(const string& dump_path,
|
||||
FilterCallback filter,
|
||||
MinidumpCallback callback,
|
||||
void *callback_context,
|
||||
void* callback_context,
|
||||
bool install_handler)
|
||||
: filter_(filter),
|
||||
callback_(callback),
|
||||
|
@ -79,7 +79,7 @@ ExceptionHandler::ExceptionHandler(const string &dump_path,
|
|||
pthread_mutex_lock(&handler_stack_mutex_);
|
||||
|
||||
if (handler_stack_ == NULL)
|
||||
handler_stack_ = new std::vector<ExceptionHandler *>;
|
||||
handler_stack_ = new std::vector<ExceptionHandler*>;
|
||||
handler_stack_->push_back(this);
|
||||
pthread_mutex_unlock(&handler_stack_mutex_);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ ExceptionHandler::~ExceptionHandler() {
|
|||
handler_stack_->pop_back();
|
||||
} else {
|
||||
print_message1(2, "warning: removing Breakpad handler out of order\n");
|
||||
for (std::vector<ExceptionHandler *>::iterator iterator =
|
||||
for (std::vector<ExceptionHandler*>::iterator iterator =
|
||||
handler_stack_->begin();
|
||||
iterator != handler_stack_->end();
|
||||
++iterator) {
|
||||
|
@ -116,9 +116,9 @@ bool ExceptionHandler::WriteMinidump() {
|
|||
}
|
||||
|
||||
// static
|
||||
bool ExceptionHandler::WriteMinidump(const string &dump_path,
|
||||
bool ExceptionHandler::WriteMinidump(const string& dump_path,
|
||||
MinidumpCallback callback,
|
||||
void *callback_context) {
|
||||
void* callback_context) {
|
||||
ExceptionHandler handler(dump_path, NULL, callback,
|
||||
callback_context, false);
|
||||
return handler.InternalWriteMinidump(0, 0, NULL);
|
||||
|
@ -166,7 +166,7 @@ void ExceptionHandler::TeardownAllHandlers() {
|
|||
|
||||
// static
|
||||
void ExceptionHandler::HandleException(int signo) {
|
||||
//void ExceptionHandler::HandleException(int signo, siginfo_t *sip, ucontext_t *sig_ctx) {
|
||||
//void ExceptionHandler::HandleException(int signo, siginfo_t* sip, ucontext_t* sig_ctx) {
|
||||
// The context information about the signal is put on the stack of
|
||||
// the signal handler frame as value parameter. For some reasons, the
|
||||
// prototype of the handler doesn't declare this information as parameter, we
|
||||
|
@ -181,14 +181,14 @@ void ExceptionHandler::HandleException(int signo) {
|
|||
uintptr_t current_ebp = (uintptr_t)_getfp();
|
||||
|
||||
pthread_mutex_lock(&handler_stack_mutex_);
|
||||
ExceptionHandler *current_handler =
|
||||
ExceptionHandler* current_handler =
|
||||
handler_stack_->at(handler_stack_->size() - ++handler_stack_index_);
|
||||
pthread_mutex_unlock(&handler_stack_mutex_);
|
||||
|
||||
// Restore original handler.
|
||||
current_handler->TeardownHandler(signo);
|
||||
|
||||
ucontext_t *sig_ctx = NULL;
|
||||
ucontext_t* sig_ctx = NULL;
|
||||
if (current_handler->InternalWriteMinidump(signo, current_ebp, &sig_ctx)) {
|
||||
// if (current_handler->InternalWriteMinidump(signo, &sig_ctx)) {
|
||||
// Fully handled this exception, safe to exit.
|
||||
|
@ -218,7 +218,7 @@ void ExceptionHandler::HandleException(int signo) {
|
|||
|
||||
bool ExceptionHandler::InternalWriteMinidump(int signo,
|
||||
uintptr_t sighandler_ebp,
|
||||
ucontext_t **sig_ctx) {
|
||||
ucontext_t** sig_ctx) {
|
||||
if (filter_ && !filter_(callback_context_))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class ExceptionHandler {
|
|||
// attempting to write a minidump. If a FilterCallback returns false,
|
||||
// Breakpad will immediately report the exception as unhandled without
|
||||
// writing a minidump, allowing another handler the opportunity to handle it.
|
||||
typedef bool (*FilterCallback)(void *context);
|
||||
typedef bool (*FilterCallback)(void* context);
|
||||
|
||||
// A callback function to run after the minidump has been written.
|
||||
// minidump_id is a unique id for the dump, so the minidump
|
||||
|
@ -97,9 +97,9 @@ class ExceptionHandler {
|
|||
// should normally return the value of |succeeded|, or when they wish to
|
||||
// not report an exception of handled, false. Callbacks will rarely want to
|
||||
// return true directly (unless |succeeded| is true).
|
||||
typedef bool (*MinidumpCallback)(const char *dump_path,
|
||||
const char *minidump_id,
|
||||
void *context,
|
||||
typedef bool (*MinidumpCallback)(const char* dump_path,
|
||||
const char* minidump_id,
|
||||
void* context,
|
||||
bool succeeded);
|
||||
|
||||
// Creates a new ExceptionHandler instance to handle writing minidumps.
|
||||
|
@ -110,15 +110,15 @@ class ExceptionHandler {
|
|||
// If install_handler is true, then a minidump will be written whenever
|
||||
// an unhandled exception occurs. If it is false, minidumps will only
|
||||
// be written when WriteMinidump is called.
|
||||
ExceptionHandler(const string &dump_path,
|
||||
ExceptionHandler(const string& dump_path,
|
||||
FilterCallback filter, MinidumpCallback callback,
|
||||
void *callback_context,
|
||||
void* callback_context,
|
||||
bool install_handler);
|
||||
~ExceptionHandler();
|
||||
|
||||
// Get and Set the minidump path.
|
||||
string dump_path() const { return dump_path_; }
|
||||
void set_dump_path(const string &dump_path) {
|
||||
void set_dump_path(const string& dump_path) {
|
||||
dump_path_ = dump_path;
|
||||
dump_path_c_ = dump_path_.c_str();
|
||||
}
|
||||
|
@ -129,9 +129,9 @@ class ExceptionHandler {
|
|||
|
||||
// Convenience form of WriteMinidump which does not require an
|
||||
// ExceptionHandler instance.
|
||||
static bool WriteMinidump(const string &dump_path,
|
||||
static bool WriteMinidump(const string& dump_path,
|
||||
MinidumpCallback callback,
|
||||
void *callback_context);
|
||||
void* callback_context);
|
||||
|
||||
private:
|
||||
// Setup crash handler.
|
||||
|
@ -144,7 +144,7 @@ class ExceptionHandler {
|
|||
void TeardownAllHandlers();
|
||||
|
||||
// Runs the main loop for the exception handler thread.
|
||||
static void* ExceptionHandlerThreadMain(void *lpParameter);
|
||||
static void* ExceptionHandlerThreadMain(void* lpParameter);
|
||||
|
||||
// Signal handler.
|
||||
static void HandleException(int signo);
|
||||
|
@ -157,20 +157,20 @@ class ExceptionHandler {
|
|||
// for the second and third parameters if you are not calling
|
||||
// this from a signal handler.
|
||||
bool InternalWriteMinidump(int signo, uintptr_t sighandler_ebp,
|
||||
ucontext_t **sig_ctx);
|
||||
ucontext_t** sig_ctx);
|
||||
|
||||
private:
|
||||
// The callbacks before and after writing the dump file.
|
||||
FilterCallback filter_;
|
||||
MinidumpCallback callback_;
|
||||
void *callback_context_;
|
||||
void* callback_context_;
|
||||
|
||||
// The directory in which a minidump will be written, set by the dump_path
|
||||
// argument to the constructor, or set_dump_path.
|
||||
string dump_path_;
|
||||
// C style dump path. Keep this when setting dump path, since calling
|
||||
// c_str() of std::string when crashing may not be safe.
|
||||
const char *dump_path_c_;
|
||||
const char* dump_path_c_;
|
||||
|
||||
// True if the ExceptionHandler installed an unhandled exception filter
|
||||
// when created (with an install_handler parameter set to true).
|
||||
|
@ -183,7 +183,7 @@ class ExceptionHandler {
|
|||
// The global exception handler stack. This is need becuase there may exist
|
||||
// multiple ExceptionHandler instances in a process. Each will have itself
|
||||
// registered in this stack.
|
||||
static std::vector<ExceptionHandler *> *handler_stack_;
|
||||
static std::vector<ExceptionHandler*>* handler_stack_;
|
||||
// The index of the handler that should handle the next exception.
|
||||
static int handler_stack_index_;
|
||||
static pthread_mutex_t handler_stack_mutex_;
|
||||
|
@ -192,8 +192,8 @@ class ExceptionHandler {
|
|||
MinidumpGenerator minidump_generator_;
|
||||
|
||||
// disallow copy ctor and operator=
|
||||
explicit ExceptionHandler(const ExceptionHandler &);
|
||||
void operator=(const ExceptionHandler &);
|
||||
explicit ExceptionHandler(const ExceptionHandler&);
|
||||
void operator=(const ExceptionHandler&);
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
|
|
@ -49,7 +49,7 @@ static int foo2(int arg) {
|
|||
// Stack variable, used for debugging stack dumps.
|
||||
int c = 0xcccccccc;
|
||||
fprintf(stderr, "Thread trying to crash: %x\n", getpid());
|
||||
c = *reinterpret_cast<int *>(0x5);
|
||||
c = *reinterpret_cast<int*>(0x5);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ static int foo(int arg) {
|
|||
return b;
|
||||
}
|
||||
|
||||
static void *thread_crash(void *) {
|
||||
static void* thread_crash(void*) {
|
||||
// Stack variable, used for debugging stack dumps.
|
||||
int a = 0xaaaaaaaa;
|
||||
sleep(3);
|
||||
|
@ -69,7 +69,7 @@ static void *thread_crash(void *) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void *thread_main(void *) {
|
||||
static void* thread_main(void*) {
|
||||
while (!should_exit)
|
||||
sleep(1);
|
||||
return NULL;
|
||||
|
@ -91,9 +91,9 @@ static void CreateThread(int num) {
|
|||
}
|
||||
|
||||
// Callback when minidump written.
|
||||
static bool MinidumpCallback(const char *dump_path,
|
||||
const char *minidump_id,
|
||||
void *context,
|
||||
static bool MinidumpCallback(const char* dump_path,
|
||||
const char* minidump_id,
|
||||
void* context,
|
||||
bool succeeded) {
|
||||
int index = reinterpret_cast<int>(context);
|
||||
if (index == 0) {
|
||||
|
@ -104,7 +104,7 @@ static bool MinidumpCallback(const char *dump_path,
|
|||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
int handler_index = 1;
|
||||
ExceptionHandler handler_ignore(".", NULL, MinidumpCallback,
|
||||
(void*)handler_index, true);
|
||||
|
|
|
@ -50,7 +50,7 @@ using namespace google_breakpad;
|
|||
|
||||
// Argument for the writer function.
|
||||
struct WriterArgument {
|
||||
MinidumpFileWriter *minidump_writer;
|
||||
MinidumpFileWriter* minidump_writer;
|
||||
|
||||
// Pid of the lwp who called WriteMinidumpToFile
|
||||
int requester_pid;
|
||||
|
@ -73,15 +73,15 @@ struct WriterArgument {
|
|||
// User context when crash happens. Can be NULL if this is a requested dump.
|
||||
// This is actually an out parameter, but it will be filled in at the start
|
||||
// of the writer LWP.
|
||||
ucontext_t *sig_ctx;
|
||||
ucontext_t* sig_ctx;
|
||||
|
||||
// Used to get information about the lwps.
|
||||
SolarisLwp *lwp_lister;
|
||||
SolarisLwp* lwp_lister;
|
||||
};
|
||||
|
||||
// Holding context information for the callback of finding the crashing lwp.
|
||||
struct FindCrashLwpContext {
|
||||
const SolarisLwp *lwp_lister;
|
||||
const SolarisLwp* lwp_lister;
|
||||
uintptr_t crashing_stack_bottom;
|
||||
int crashing_lwpid;
|
||||
|
||||
|
@ -96,11 +96,11 @@ struct FindCrashLwpContext {
|
|||
// It will compare the stack bottom of the provided lwp with the stack
|
||||
// bottom of the crashed lwp, it they are eqaul, this lwp is the one
|
||||
// who crashed.
|
||||
bool IsLwpCrashedCallback(lwpstatus_t *lsp, void *context) {
|
||||
FindCrashLwpContext *crashing_context =
|
||||
static_cast<FindCrashLwpContext *>(context);
|
||||
const SolarisLwp *lwp_lister = crashing_context->lwp_lister;
|
||||
const prgregset_t *gregs = &(lsp->pr_reg);
|
||||
bool IsLwpCrashedCallback(lwpstatus_t* lsp, void* context) {
|
||||
FindCrashLwpContext* crashing_context =
|
||||
static_cast<FindCrashLwpContext*>(context);
|
||||
const SolarisLwp* lwp_lister = crashing_context->lwp_lister;
|
||||
const prgregset_t* gregs = &(lsp->pr_reg);
|
||||
#if TARGET_CPU_SPARC
|
||||
uintptr_t last_ebp = (*gregs)[R_FP];
|
||||
#elif TARGET_CPU_X86
|
||||
|
@ -121,7 +121,7 @@ bool IsLwpCrashedCallback(lwpstatus_t *lsp, void *context) {
|
|||
// This is done based on stack bottom comparing.
|
||||
int FindCrashingLwp(uintptr_t crashing_stack_bottom,
|
||||
int requester_pid,
|
||||
const SolarisLwp *lwp_lister) {
|
||||
const SolarisLwp* lwp_lister) {
|
||||
FindCrashLwpContext context;
|
||||
context.lwp_lister = lwp_lister;
|
||||
context.crashing_stack_bottom = crashing_stack_bottom;
|
||||
|
@ -131,17 +131,17 @@ int FindCrashingLwp(uintptr_t crashing_stack_bottom,
|
|||
return context.crashing_lwpid;
|
||||
}
|
||||
|
||||
bool WriteLwpStack(const SolarisLwp *lwp_lister,
|
||||
bool WriteLwpStack(const SolarisLwp* lwp_lister,
|
||||
uintptr_t last_esp,
|
||||
UntypedMDRVA *memory,
|
||||
MDMemoryDescriptor *loc) {
|
||||
UntypedMDRVA* memory,
|
||||
MDMemoryDescriptor* loc) {
|
||||
uintptr_t stack_bottom = lwp_lister->GetLwpStackBottom(last_esp);
|
||||
if (stack_bottom >= last_esp) {
|
||||
int size = stack_bottom - last_esp;
|
||||
if (size > 0) {
|
||||
if (!memory->Allocate(size))
|
||||
return false;
|
||||
memory->Copy(reinterpret_cast<void *>(last_esp), size);
|
||||
memory->Copy(reinterpret_cast<void*>(last_esp), size);
|
||||
loc->start_of_memory_range = last_esp;
|
||||
loc->memory = memory->location();
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ bool WriteLwpStack(const SolarisLwp *lwp_lister,
|
|||
}
|
||||
|
||||
#if TARGET_CPU_SPARC
|
||||
bool WriteContext(MDRawContextSPARC *context, ucontext_t *sig_ctx) {
|
||||
bool WriteContext(MDRawContextSPARC* context, ucontext_t* sig_ctx) {
|
||||
assert(sig_ctx != NULL);
|
||||
int* regs = sig_ctx->uc_mcontext.gregs;
|
||||
context->context_flags = MD_CONTEXT_SPARC_FULL;
|
||||
|
@ -170,13 +170,13 @@ bool WriteContext(MDRawContextSPARC *context, ucontext_t *sig_ctx) {
|
|||
for ( int i = 1 ; i < 16; ++i ) {
|
||||
context->g_r[i] = (uintptr_t)(sig_ctx->uc_mcontext.gregs[i + 3]);
|
||||
}
|
||||
context->g_r[30] = (uintptr_t)(((struct frame *)context->g_r[14])->fr_savfp);
|
||||
context->g_r[30] = (uintptr_t)(((struct frame*)context->g_r[14])->fr_savfp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteContext(MDRawContextSPARC *context, prgregset_t regs,
|
||||
prfpregset_t *fp_regs) {
|
||||
bool WriteContext(MDRawContextSPARC* context, prgregset_t regs,
|
||||
prfpregset_t* fp_regs) {
|
||||
if (!context || !regs)
|
||||
return false;
|
||||
|
||||
|
@ -195,8 +195,8 @@ bool WriteContext(MDRawContextSPARC *context, prgregset_t regs,
|
|||
return true;
|
||||
}
|
||||
#elif TARGET_CPU_X86
|
||||
bool WriteContext(MDRawContextX86 *context, prgregset_t regs,
|
||||
prfpregset_t *fp_regs) {
|
||||
bool WriteContext(MDRawContextX86* context, prgregset_t regs,
|
||||
prfpregset_t* fp_regs) {
|
||||
if (!context || !regs)
|
||||
return false;
|
||||
|
||||
|
@ -228,10 +228,10 @@ bool WriteContext(MDRawContextX86 *context, prgregset_t regs,
|
|||
// signal. This makes the current stack not reliable, and our stack walker
|
||||
// won't figure out the whole call stack for this. So we write the stack at the
|
||||
// time of the crash into the minidump file, not the current stack.
|
||||
bool WriteCrashedLwpStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
const lwpstatus_t *lsp,
|
||||
MDRawThread *lwp) {
|
||||
bool WriteCrashedLwpStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
const lwpstatus_t* lsp,
|
||||
MDRawThread* lwp) {
|
||||
assert(writer_args->sig_ctx != NULL);
|
||||
|
||||
lwp->thread_id = lsp->pr_lwpid;
|
||||
|
@ -264,16 +264,16 @@ bool WriteCrashedLwpStream(MinidumpFileWriter *minidump_writer,
|
|||
lwp->thread_context = context.location();
|
||||
memset(context.get(), 0, sizeof(MDRawContextX86));
|
||||
return WriteContext(context.get(),
|
||||
(int *)&writer_args->sig_ctx->uc_mcontext.gregs,
|
||||
(int*)&writer_args->sig_ctx->uc_mcontext.gregs,
|
||||
&writer_args->sig_ctx->uc_mcontext.fpregs);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WriteLwpStream(MinidumpFileWriter *minidump_writer,
|
||||
const SolarisLwp *lwp_lister,
|
||||
const lwpstatus_t *lsp, MDRawThread *lwp) {
|
||||
bool WriteLwpStream(MinidumpFileWriter* minidump_writer,
|
||||
const SolarisLwp* lwp_lister,
|
||||
const lwpstatus_t* lsp, MDRawThread* lwp) {
|
||||
prfpregset_t fp_regs = lsp->pr_fpreg;
|
||||
const prgregset_t *gregs = &(lsp->pr_reg);
|
||||
const prgregset_t* gregs = &(lsp->pr_reg);
|
||||
UntypedMDRVA memory(minidump_writer);
|
||||
#if TARGET_CPU_SPARC
|
||||
if (!WriteLwpStack(lwp_lister,
|
||||
|
@ -306,10 +306,10 @@ bool WriteLwpStream(MinidumpFileWriter *minidump_writer,
|
|||
lwp->thread_context = context.location();
|
||||
memset(context.get(), 0, sizeof(MDRawContextX86));
|
||||
#endif /* TARGET_CPU_XXX */
|
||||
return WriteContext(context.get(), (int *)gregs, &fp_regs);
|
||||
return WriteContext(context.get(), (int*)gregs, &fp_regs);
|
||||
}
|
||||
|
||||
bool WriteCPUInformation(MDRawSystemInfo *sys_info) {
|
||||
bool WriteCPUInformation(MDRawSystemInfo* sys_info) {
|
||||
struct utsname uts;
|
||||
char *major, *minor, *build;
|
||||
|
||||
|
@ -337,8 +337,8 @@ bool WriteCPUInformation(MDRawSystemInfo *sys_info) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WriteOSInformation(MinidumpFileWriter *minidump_writer,
|
||||
MDRawSystemInfo *sys_info) {
|
||||
bool WriteOSInformation(MinidumpFileWriter* minidump_writer,
|
||||
MDRawSystemInfo* sys_info) {
|
||||
sys_info->platform_id = MD_OS_SOLARIS;
|
||||
|
||||
struct utsname uts;
|
||||
|
@ -346,7 +346,7 @@ bool WriteOSInformation(MinidumpFileWriter *minidump_writer,
|
|||
char os_version[512];
|
||||
size_t space_left = sizeof(os_version);
|
||||
memset(os_version, 0, space_left);
|
||||
const char *os_info_table[] = {
|
||||
const char* os_info_table[] = {
|
||||
uts.sysname,
|
||||
uts.release,
|
||||
uts.version,
|
||||
|
@ -354,7 +354,7 @@ bool WriteOSInformation(MinidumpFileWriter *minidump_writer,
|
|||
"OpenSolaris",
|
||||
NULL
|
||||
};
|
||||
for (const char **cur_os_info = os_info_table;
|
||||
for (const char** cur_os_info = os_info_table;
|
||||
*cur_os_info != NULL;
|
||||
++cur_os_info) {
|
||||
if (cur_os_info != os_info_table && space_left > 1) {
|
||||
|
@ -379,21 +379,21 @@ bool WriteOSInformation(MinidumpFileWriter *minidump_writer,
|
|||
|
||||
// Callback context for get writting lwp information.
|
||||
struct LwpInfoCallbackCtx {
|
||||
MinidumpFileWriter *minidump_writer;
|
||||
const WriterArgument *writer_args;
|
||||
TypedMDRVA<MDRawThreadList> *list;
|
||||
MinidumpFileWriter* minidump_writer;
|
||||
const WriterArgument* writer_args;
|
||||
TypedMDRVA<MDRawThreadList>* list;
|
||||
int lwp_index;
|
||||
};
|
||||
|
||||
bool LwpInformationCallback(lwpstatus_t *lsp, void *context) {
|
||||
bool LwpInformationCallback(lwpstatus_t* lsp, void* context) {
|
||||
bool success = true;
|
||||
LwpInfoCallbackCtx *callback_context =
|
||||
static_cast<LwpInfoCallbackCtx *>(context);
|
||||
LwpInfoCallbackCtx* callback_context =
|
||||
static_cast<LwpInfoCallbackCtx*>(context);
|
||||
|
||||
// The current lwp is the one to handle the crash. Ignore it.
|
||||
if (lsp->pr_lwpid != pthread_self()) {
|
||||
LwpInfoCallbackCtx *callback_context =
|
||||
static_cast<LwpInfoCallbackCtx *>(context);
|
||||
LwpInfoCallbackCtx* callback_context =
|
||||
static_cast<LwpInfoCallbackCtx*>(context);
|
||||
MDRawThread lwp;
|
||||
memset(&lwp, 0, sizeof(MDRawThread));
|
||||
|
||||
|
@ -417,11 +417,11 @@ bool LwpInformationCallback(lwpstatus_t *lsp, void *context) {
|
|||
return success;
|
||||
}
|
||||
|
||||
bool WriteLwpListStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
MDRawDirectory *dir) {
|
||||
bool WriteLwpListStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
MDRawDirectory* dir) {
|
||||
// Get the lwp information.
|
||||
const SolarisLwp *lwp_lister = writer_args->lwp_lister;
|
||||
const SolarisLwp* lwp_lister = writer_args->lwp_lister;
|
||||
int lwp_count = lwp_lister->GetLwpCount();
|
||||
if (lwp_count < 0)
|
||||
return false;
|
||||
|
@ -444,14 +444,14 @@ bool WriteLwpListStream(MinidumpFileWriter *minidump_writer,
|
|||
return written == lwp_count;
|
||||
}
|
||||
|
||||
bool WriteCVRecord(MinidumpFileWriter *minidump_writer,
|
||||
MDRawModule *module,
|
||||
const char *module_path,
|
||||
char *realname) {
|
||||
bool WriteCVRecord(MinidumpFileWriter* minidump_writer,
|
||||
MDRawModule* module,
|
||||
const char* module_path,
|
||||
char* realname) {
|
||||
TypedMDRVA<MDCVInfoPDB70> cv(minidump_writer);
|
||||
|
||||
char path[PATH_MAX];
|
||||
const char *module_name = module_path ? module_path : "<Unknown>";
|
||||
const char* module_name = module_path ? module_path : "<Unknown>";
|
||||
snprintf(path, sizeof(path), "/proc/self/object/%s", module_name);
|
||||
|
||||
size_t module_name_length = strlen(realname);
|
||||
|
@ -461,7 +461,7 @@ bool WriteCVRecord(MinidumpFileWriter *minidump_writer,
|
|||
return false;
|
||||
|
||||
module->cv_record = cv.location();
|
||||
MDCVInfoPDB70 *cv_ptr = cv.get();
|
||||
MDCVInfoPDB70* cv_ptr = cv.get();
|
||||
memset(cv_ptr, 0, sizeof(MDCVInfoPDB70));
|
||||
cv_ptr->cv_signature = MD_CVINFOPDB70_SIGNATURE;
|
||||
cv_ptr->age = 0;
|
||||
|
@ -489,15 +489,15 @@ bool WriteCVRecord(MinidumpFileWriter *minidump_writer,
|
|||
}
|
||||
|
||||
struct ModuleInfoCallbackCtx {
|
||||
MinidumpFileWriter *minidump_writer;
|
||||
const WriterArgument *writer_args;
|
||||
TypedMDRVA<MDRawModuleList> *list;
|
||||
MinidumpFileWriter* minidump_writer;
|
||||
const WriterArgument* writer_args;
|
||||
TypedMDRVA<MDRawModuleList>* list;
|
||||
int module_index;
|
||||
};
|
||||
|
||||
bool ModuleInfoCallback(const ModuleInfo &module_info, void *context) {
|
||||
ModuleInfoCallbackCtx *callback_context =
|
||||
static_cast<ModuleInfoCallbackCtx *>(context);
|
||||
bool ModuleInfoCallback(const ModuleInfo& module_info, void* context) {
|
||||
ModuleInfoCallbackCtx* callback_context =
|
||||
static_cast<ModuleInfoCallbackCtx*>(context);
|
||||
// Skip those modules without name, or those that are not modules.
|
||||
if (strlen(module_info.name) == 0)
|
||||
return true;
|
||||
|
@ -507,7 +507,7 @@ bool ModuleInfoCallback(const ModuleInfo &module_info, void *context) {
|
|||
MDLocationDescriptor loc;
|
||||
char path[PATH_MAX];
|
||||
char buf[PATH_MAX];
|
||||
char *realname;
|
||||
char* realname;
|
||||
int count;
|
||||
|
||||
snprintf(path, sizeof (path), "/proc/self/path/%s", module_info.name);
|
||||
|
@ -535,9 +535,9 @@ bool ModuleInfoCallback(const ModuleInfo &module_info, void *context) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WriteModuleListStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
MDRawDirectory *dir) {
|
||||
bool WriteModuleListStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
MDRawDirectory* dir) {
|
||||
TypedMDRVA<MDRawModuleList> list(minidump_writer);
|
||||
int module_count = writer_args->lwp_lister->GetModuleCount();
|
||||
|
||||
|
@ -558,9 +558,9 @@ bool WriteModuleListStream(MinidumpFileWriter *minidump_writer,
|
|||
return writer_args->lwp_lister->ListModules(&callback) == module_count;
|
||||
}
|
||||
|
||||
bool WriteSystemInfoStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
MDRawDirectory *dir) {
|
||||
bool WriteSystemInfoStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
MDRawDirectory* dir) {
|
||||
TypedMDRVA<MDRawSystemInfo> sys_info(minidump_writer);
|
||||
|
||||
if (!sys_info.Allocate())
|
||||
|
@ -573,9 +573,9 @@ bool WriteSystemInfoStream(MinidumpFileWriter *minidump_writer,
|
|||
WriteOSInformation(minidump_writer, sys_info.get());
|
||||
}
|
||||
|
||||
bool WriteExceptionStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
MDRawDirectory *dir) {
|
||||
bool WriteExceptionStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
MDRawDirectory* dir) {
|
||||
// This happenes when this is not a crash, but a requested dump.
|
||||
if (writer_args->sig_ctx == NULL)
|
||||
return false;
|
||||
|
@ -620,14 +620,14 @@ bool WriteExceptionStream(MinidumpFileWriter *minidump_writer,
|
|||
exception.get()->thread_context = context.location();
|
||||
memset(context.get(), 0, sizeof(MDRawContextX86));
|
||||
return WriteContext(context.get(),
|
||||
(int *)&writer_args->sig_ctx->uc_mcontext.gregs,
|
||||
(int*)&writer_args->sig_ctx->uc_mcontext.gregs,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WriteMiscInfoStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
MDRawDirectory *dir) {
|
||||
bool WriteMiscInfoStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
MDRawDirectory* dir) {
|
||||
TypedMDRVA<MDRawMiscInfo> info(minidump_writer);
|
||||
|
||||
if (!info.Allocate())
|
||||
|
@ -642,9 +642,9 @@ bool WriteMiscInfoStream(MinidumpFileWriter *minidump_writer,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WriteBreakpadInfoStream(MinidumpFileWriter *minidump_writer,
|
||||
const WriterArgument *writer_args,
|
||||
MDRawDirectory *dir) {
|
||||
bool WriteBreakpadInfoStream(MinidumpFileWriter* minidump_writer,
|
||||
const WriterArgument* writer_args,
|
||||
MDRawDirectory* dir) {
|
||||
TypedMDRVA<MDRawBreakpadInfo> info(minidump_writer);
|
||||
|
||||
if (!info.Allocate())
|
||||
|
@ -662,16 +662,16 @@ bool WriteBreakpadInfoStream(MinidumpFileWriter *minidump_writer,
|
|||
|
||||
class AutoLwpResumer {
|
||||
public:
|
||||
AutoLwpResumer(SolarisLwp *lwp) : lwp_(lwp) {}
|
||||
AutoLwpResumer(SolarisLwp* lwp) : lwp_(lwp) {}
|
||||
~AutoLwpResumer() { lwp_->ControlAllLwps(false); }
|
||||
private:
|
||||
SolarisLwp *lwp_;
|
||||
SolarisLwp* lwp_;
|
||||
};
|
||||
|
||||
// Prototype of writer functions.
|
||||
typedef bool (*WriteStreamFN)(MinidumpFileWriter *,
|
||||
const WriterArgument *,
|
||||
MDRawDirectory *);
|
||||
typedef bool (*WriteStreamFN)(MinidumpFileWriter*,
|
||||
const WriterArgument*,
|
||||
MDRawDirectory*);
|
||||
|
||||
// Function table to writer a full minidump.
|
||||
const WriteStreamFN writers[] = {
|
||||
|
@ -684,9 +684,9 @@ const WriteStreamFN writers[] = {
|
|||
};
|
||||
|
||||
// Will call each writer function in the writers table.
|
||||
//void* MinidumpGenerator::Write(void *argument) {
|
||||
void* Write(void *argument) {
|
||||
WriterArgument *writer_args = static_cast<WriterArgument *>(argument);
|
||||
//void* MinidumpGenerator::Write(void* argument) {
|
||||
void* Write(void* argument) {
|
||||
WriterArgument* writer_args = static_cast<WriterArgument*>(argument);
|
||||
|
||||
if (!writer_args->lwp_lister->ControlAllLwps(true))
|
||||
return NULL;
|
||||
|
@ -712,7 +712,7 @@ void* Write(void *argument) {
|
|||
writer_args->crashed_lwpid = crashed_lwpid;
|
||||
}
|
||||
|
||||
MinidumpFileWriter *minidump_writer = writer_args->minidump_writer;
|
||||
MinidumpFileWriter* minidump_writer = writer_args->minidump_writer;
|
||||
TypedMDRVA<MDRawHeader> header(minidump_writer);
|
||||
TypedMDRVA<MDRawDirectory> dir(minidump_writer);
|
||||
if (!header.Allocate())
|
||||
|
@ -750,10 +750,10 @@ MinidumpGenerator::~MinidumpGenerator() {
|
|||
|
||||
// Write minidump into file.
|
||||
// It runs in a different thread from the crashing thread.
|
||||
bool MinidumpGenerator::WriteMinidumpToFile(const char *file_pathname,
|
||||
bool MinidumpGenerator::WriteMinidumpToFile(const char* file_pathname,
|
||||
int signo,
|
||||
uintptr_t sighandler_ebp,
|
||||
ucontext_t **sig_ctx) const {
|
||||
ucontext_t** sig_ctx) const {
|
||||
// The exception handler thread.
|
||||
pthread_t handler_thread;
|
||||
|
||||
|
@ -775,7 +775,7 @@ bool MinidumpGenerator::WriteMinidumpToFile(const char *file_pathname,
|
|||
argument.sighandler_ebp = sighandler_ebp;
|
||||
argument.sig_ctx = NULL;
|
||||
|
||||
pthread_create(&handler_thread, NULL, Write, (void *)&argument);
|
||||
pthread_create(&handler_thread, NULL, Write, (void*)&argument);
|
||||
pthread_join(handler_thread, NULL);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace google_breakpad {
|
|||
//
|
||||
class MinidumpGenerator {
|
||||
// Callback run for writing lwp information in the process.
|
||||
friend bool LwpInformationCallback(lwpstatus_t *lsp, void *context);
|
||||
friend bool LwpInformationCallback(lwpstatus_t* lsp, void* context);
|
||||
|
||||
// Callback run for writing module information in the process.
|
||||
friend bool ModuleInfoCallback(const ModuleInfo &module_info, void *context);
|
||||
friend bool ModuleInfoCallback(const ModuleInfo& module_info, void* context);
|
||||
|
||||
public:
|
||||
MinidumpGenerator();
|
||||
|
@ -59,10 +59,10 @@ class MinidumpGenerator {
|
|||
~MinidumpGenerator();
|
||||
|
||||
// Write minidump.
|
||||
bool WriteMinidumpToFile(const char *file_pathname,
|
||||
bool WriteMinidumpToFile(const char* file_pathname,
|
||||
int signo,
|
||||
uintptr_t sighandler_ebp,
|
||||
ucontext_t **sig_ctx) const;
|
||||
ucontext_t** sig_ctx) const;
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
|
|
@ -40,7 +40,7 @@ using google_breakpad::MinidumpGenerator;
|
|||
|
||||
static bool doneWritingReport = false;
|
||||
|
||||
static void *Reporter(void *) {
|
||||
static void* Reporter(void*) {
|
||||
char buffer[PATH_MAX];
|
||||
MinidumpGenerator md;
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ struct AddressValidatingContext {
|
|||
};
|
||||
|
||||
// Convert from string to int.
|
||||
static bool LocalAtoi(char *s, int *r) {
|
||||
static bool LocalAtoi(char* s, int* r) {
|
||||
assert(s != NULL);
|
||||
assert(r != NULL);
|
||||
char *endptr = NULL;
|
||||
char* endptr = NULL;
|
||||
int ret = strtol(s, &endptr, 10);
|
||||
if (endptr == s)
|
||||
return false;
|
||||
|
@ -82,10 +82,10 @@ static bool LocalAtoi(char *s, int *r) {
|
|||
|
||||
// Callback invoked for each mapped module.
|
||||
// It uses the module's adderss range to validate the address.
|
||||
static bool AddressNotInModuleCallback(const ModuleInfo &module_info,
|
||||
void *context) {
|
||||
AddressValidatingContext *addr =
|
||||
reinterpret_cast<AddressValidatingContext *>(context);
|
||||
static bool AddressNotInModuleCallback(const ModuleInfo& module_info,
|
||||
void* context) {
|
||||
AddressValidatingContext* addr =
|
||||
reinterpret_cast<AddressValidatingContext*>(context);
|
||||
if (addr->is_mapped = ((module_info.start_addr > 0) &&
|
||||
(addr->address >= module_info.start_addr) &&
|
||||
(addr->address <= module_info.start_addr +
|
||||
|
@ -97,16 +97,16 @@ static bool AddressNotInModuleCallback(const ModuleInfo &module_info,
|
|||
}
|
||||
|
||||
static int IterateLwpAll(int pid,
|
||||
CallbackParam<LwpidCallback> *callback_param) {
|
||||
CallbackParam<LwpidCallback>* callback_param) {
|
||||
char lwp_path[40];
|
||||
DIR *dir;
|
||||
DIR* dir;
|
||||
int count = 0;
|
||||
|
||||
snprintf(lwp_path, sizeof (lwp_path), "/proc/%d/lwp", (int)pid);
|
||||
if ((dir = opendir(lwp_path)) == NULL)
|
||||
return -1;
|
||||
|
||||
struct dirent *entry = NULL;
|
||||
struct dirent* entry = NULL;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if ((strcmp(entry->d_name, ".") != 0) &&
|
||||
(strcmp(entry->d_name, "..") != 0)) {
|
||||
|
@ -128,22 +128,22 @@ static int IterateLwpAll(int pid,
|
|||
}
|
||||
|
||||
#if defined(__i386) && !defined(NO_FRAME_POINTER)
|
||||
void *GetNextFrame(void **last_ebp) {
|
||||
void *sp = *last_ebp;
|
||||
void* GetNextFrame(void** last_ebp) {
|
||||
void* sp = *last_ebp;
|
||||
if ((unsigned long)sp == (unsigned long)last_ebp)
|
||||
return NULL;
|
||||
if ((unsigned long)sp & (sizeof(void *) - 1))
|
||||
if ((unsigned long)sp & (sizeof(void*) - 1))
|
||||
return NULL;
|
||||
if ((unsigned long)sp - (unsigned long)last_ebp > 100000)
|
||||
return NULL;
|
||||
return sp;
|
||||
}
|
||||
#elif defined(__sparc)
|
||||
void *GetNextFrame(void *last_ebp) {
|
||||
return reinterpret_cast<struct frame *>(last_ebp)->fr_savfp;
|
||||
void* GetNextFrame(void* last_ebp) {
|
||||
return reinterpret_cast<struct frame*>(last_ebp)->fr_savfp;
|
||||
}
|
||||
#else
|
||||
void *GetNextFrame(void **last_ebp) {
|
||||
void* GetNextFrame(void** last_ebp) {
|
||||
return reinterpret_cast<void*>(last_ebp);
|
||||
}
|
||||
#endif
|
||||
|
@ -159,12 +159,12 @@ class AutoCloser {
|
|||
|
||||
// Control the execution of the lwp.
|
||||
// Suspend/Resume lwp based on the value of context.
|
||||
static bool ControlLwp(int lwpid, void *context) {
|
||||
static bool ControlLwp(int lwpid, void* context) {
|
||||
// The current thread is the one to handle the crash. Ignore it.
|
||||
if (lwpid != pthread_self()) {
|
||||
int ctlfd;
|
||||
char procname[PATH_MAX];
|
||||
bool suspend = *(bool *)context;
|
||||
bool suspend = *(bool*)context;
|
||||
|
||||
// Open the /proc/$pid/lwp/$lwpid/lwpctl files
|
||||
snprintf(procname, sizeof (procname), "/proc/self/lwp/%d/lwpctl", lwpid);
|
||||
|
@ -193,7 +193,7 @@ static bool ControlLwp(int lwpid, void *context) {
|
|||
* prheader_t at the start (/proc/$pid/lstatus or /proc/$pid/lpsinfo).
|
||||
* Return true on success.
|
||||
*/
|
||||
static bool read_lfile(int pid, const char *lname, prheader_t *lhp) {
|
||||
static bool read_lfile(int pid, const char* lname, prheader_t* lhp) {
|
||||
char lpath[PATH_MAX];
|
||||
struct stat statb;
|
||||
int fd;
|
||||
|
@ -242,14 +242,14 @@ int SolarisLwp::GetLwpCount() const {
|
|||
}
|
||||
|
||||
int SolarisLwp::Lwp_iter_all(int pid,
|
||||
CallbackParam<LwpCallback> *callback_param) const {
|
||||
lwpstatus_t *Lsp;
|
||||
lwpstatus_t *sp;
|
||||
CallbackParam<LwpCallback>* callback_param) const {
|
||||
lwpstatus_t* Lsp;
|
||||
lwpstatus_t* sp;
|
||||
prheader_t lphp[HEADER_MAX];
|
||||
prheader_t lhp[HEADER_MAX];
|
||||
prheader_t *Lphp = lphp;
|
||||
prheader_t *Lhp = lhp;
|
||||
lwpsinfo_t *Lpsp;
|
||||
prheader_t* Lphp = lphp;
|
||||
prheader_t* Lhp = lhp;
|
||||
lwpsinfo_t* Lpsp;
|
||||
long nstat;
|
||||
long ninfo;
|
||||
int rv = 0;
|
||||
|
@ -264,13 +264,13 @@ int SolarisLwp::Lwp_iter_all(int pid,
|
|||
return -1;
|
||||
}
|
||||
|
||||
Lsp = (lwpstatus_t *)(uintptr_t)(Lhp + 1);
|
||||
Lpsp = (lwpsinfo_t *)(uintptr_t)(Lphp + 1);
|
||||
Lsp = (lwpstatus_t*)(uintptr_t)(Lhp + 1);
|
||||
Lpsp = (lwpsinfo_t*)(uintptr_t)(Lphp + 1);
|
||||
|
||||
for (ninfo = Lphp->pr_nent; ninfo != 0; --ninfo) {
|
||||
if (Lpsp->pr_sname != 'Z') {
|
||||
sp = Lsp;
|
||||
Lsp = (lwpstatus_t *)((uintptr_t)Lsp + Lhp->pr_entsize);
|
||||
Lsp = (lwpstatus_t*)((uintptr_t)Lsp + Lhp->pr_entsize);
|
||||
} else {
|
||||
sp = NULL;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ int SolarisLwp::Lwp_iter_all(int pid,
|
|||
!(callback_param->call_back)(sp, callback_param->context))
|
||||
break;
|
||||
++rv;
|
||||
Lpsp = (lwpsinfo_t *)((uintptr_t)Lpsp + Lphp->pr_entsize);
|
||||
Lpsp = (lwpsinfo_t*)((uintptr_t)Lpsp + Lphp->pr_entsize);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -298,12 +298,12 @@ int SolarisLwp::GetModuleCount() const {
|
|||
}
|
||||
|
||||
int SolarisLwp::ListModules(
|
||||
CallbackParam<ModuleCallback> *callback_param) const {
|
||||
const char *maps_path = "/proc/self/map";
|
||||
CallbackParam<ModuleCallback>* callback_param) const {
|
||||
const char* maps_path = "/proc/self/map";
|
||||
struct stat status;
|
||||
int fd = 0, num;
|
||||
prmap_t map_array[MAP_MAX];
|
||||
prmap_t *maps = map_array;
|
||||
prmap_t* maps = map_array;
|
||||
size_t size;
|
||||
|
||||
if ((fd = open(maps_path, O_RDONLY)) == -1) {
|
||||
|
@ -326,12 +326,12 @@ int SolarisLwp::ListModules(
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (read(fd, (void *)maps, size) < 0) {
|
||||
if (read(fd, (void*)maps, size) < 0) {
|
||||
print_message2(2, "failed to read %d\n", fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
prmap_t *_maps;
|
||||
prmap_t* _maps;
|
||||
int _num;
|
||||
int module_count = 0;
|
||||
|
||||
|
@ -345,7 +345,7 @@ int SolarisLwp::ListModules(
|
|||
*/
|
||||
for (_num = 0, _maps = maps; _num < num; ++_num, ++_maps) {
|
||||
ModuleInfo module;
|
||||
char *name = _maps->pr_mapname;
|
||||
char* name = _maps->pr_mapname;
|
||||
|
||||
memset(&module, 0, sizeof (module));
|
||||
module.start_addr = _maps->pr_vaddr;
|
||||
|
@ -403,7 +403,7 @@ bool SolarisLwp::IsAddressMapped(uintptr_t address) const {
|
|||
// The Solaris stack looks like this:
|
||||
// http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libproc/common/Pstack.c#81
|
||||
bool SolarisLwp::FindSigContext(uintptr_t sighandler_ebp,
|
||||
ucontext_t **sig_ctx) {
|
||||
ucontext_t** sig_ctx) {
|
||||
uintptr_t previous_ebp;
|
||||
uintptr_t sig_ebp;
|
||||
const int MAX_STACK_DEPTH = 50;
|
||||
|
@ -416,7 +416,7 @@ bool SolarisLwp::FindSigContext(uintptr_t sighandler_ebp,
|
|||
*sig_ctx = reinterpret_cast<ucontext_t*>(sighandler_ebp + sizeof (struct frame));
|
||||
uintptr_t sig_esp = (*sig_ctx)->uc_mcontext.gregs[REG_O6];
|
||||
if (sig_esp < previous_ebp && sig_esp > sighandler_ebp)
|
||||
sig_ebp = (uintptr_t)(((struct frame *)sig_esp)->fr_savfp);
|
||||
sig_ebp = (uintptr_t)(((struct frame*)sig_esp)->fr_savfp);
|
||||
|
||||
#elif TARGET_CPU_X86
|
||||
previous_ebp = reinterpret_cast<uintptr_t>(GetNextFrame(
|
||||
|
|
|
@ -70,17 +70,17 @@ struct ModuleInfo {
|
|||
// A callback to run when getting a lwp in the process.
|
||||
// Return true will go on to the next lwp while return false will stop the
|
||||
// iteration.
|
||||
typedef bool (*LwpCallback)(lwpstatus_t* lsp, void *context);
|
||||
typedef bool (*LwpCallback)(lwpstatus_t* lsp, void* context);
|
||||
|
||||
// A callback to run when a new module is found in the process.
|
||||
// Return true will go on to the next module while return false will stop the
|
||||
// iteration.
|
||||
typedef bool (*ModuleCallback)(const ModuleInfo &module_info, void *context);
|
||||
typedef bool (*ModuleCallback)(const ModuleInfo& module_info, void* context);
|
||||
|
||||
// A callback to run when getting a lwpid in the process.
|
||||
// Return true will go on to the next lwp while return false will stop the
|
||||
// iteration.
|
||||
typedef bool (*LwpidCallback)(int lwpid, void *context);
|
||||
typedef bool (*LwpidCallback)(int lwpid, void* context);
|
||||
|
||||
// Holding the callback information.
|
||||
template<class CallbackFunc>
|
||||
|
@ -88,12 +88,12 @@ struct CallbackParam {
|
|||
// Callback function address.
|
||||
CallbackFunc call_back;
|
||||
// Callback context;
|
||||
void *context;
|
||||
void* context;
|
||||
|
||||
CallbackParam() : call_back(NULL), context(NULL) {
|
||||
}
|
||||
|
||||
CallbackParam(CallbackFunc func, void *func_context) :
|
||||
CallbackParam(CallbackFunc func, void* func_context) :
|
||||
call_back(func), context(func_context) {
|
||||
}
|
||||
};
|
||||
|
@ -129,7 +129,7 @@ class SolarisLwp {
|
|||
// Whenever there is a lwp found, the callback will be invoked to process
|
||||
// the information.
|
||||
// Return the callback return value or -1 on error.
|
||||
int Lwp_iter_all(int pid, CallbackParam<LwpCallback> *callback_param) const;
|
||||
int Lwp_iter_all(int pid, CallbackParam<LwpCallback>* callback_param) const;
|
||||
|
||||
// Get the module count of the current process.
|
||||
int GetModuleCount() const;
|
||||
|
@ -138,13 +138,13 @@ class SolarisLwp {
|
|||
// Whenever a module is found, the callback will be invoked to process the
|
||||
// information.
|
||||
// Return how may modules are found.
|
||||
int ListModules(CallbackParam<ModuleCallback> *callback_param) const;
|
||||
int ListModules(CallbackParam<ModuleCallback>* callback_param) const;
|
||||
|
||||
// Get the bottom of the stack from esp.
|
||||
uintptr_t GetLwpStackBottom(uintptr_t current_esp) const;
|
||||
|
||||
// Finds a signal context on the stack given the ebp of our signal handler.
|
||||
bool FindSigContext(uintptr_t sighandler_ebp, ucontext_t **sig_ctx);
|
||||
bool FindSigContext(uintptr_t sighandler_ebp, ucontext_t** sig_ctx);
|
||||
|
||||
private:
|
||||
// Check if the address is a valid virtual address.
|
||||
|
|
|
@ -118,7 +118,7 @@ ExceptionHandler::ExceptionHandler(
|
|||
NULL); // custom_info - not used
|
||||
}
|
||||
|
||||
ExceptionHandler::ExceptionHandler(const wstring &dump_path,
|
||||
ExceptionHandler::ExceptionHandler(const wstring& dump_path,
|
||||
FilterCallback filter,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context,
|
||||
|
@ -383,7 +383,7 @@ bool ExceptionHandler::RequestUpload(DWORD crash_id) {
|
|||
|
||||
// static
|
||||
DWORD ExceptionHandler::ExceptionHandlerThreadMain(void* lpParameter) {
|
||||
ExceptionHandler* self = reinterpret_cast<ExceptionHandler *>(lpParameter);
|
||||
ExceptionHandler* self = reinterpret_cast<ExceptionHandler*>(lpParameter);
|
||||
assert(self);
|
||||
assert(self->handler_start_semaphore_ != NULL);
|
||||
assert(self->handler_finish_semaphore_ != NULL);
|
||||
|
@ -765,7 +765,7 @@ bool ExceptionHandler::WriteMinidumpForException(EXCEPTION_POINTERS* exinfo) {
|
|||
}
|
||||
|
||||
// static
|
||||
bool ExceptionHandler::WriteMinidump(const wstring &dump_path,
|
||||
bool ExceptionHandler::WriteMinidump(const wstring& dump_path,
|
||||
MinidumpCallback callback,
|
||||
void* callback_context,
|
||||
MINIDUMP_TYPE dump_type) {
|
||||
|
|
|
@ -218,7 +218,7 @@ class ExceptionHandler {
|
|||
|
||||
// Get and set the minidump path.
|
||||
wstring dump_path() const { return dump_path_; }
|
||||
void set_dump_path(const wstring &dump_path) {
|
||||
void set_dump_path(const wstring& dump_path) {
|
||||
dump_path_ = dump_path;
|
||||
dump_path_c_ = dump_path_.c_str();
|
||||
UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_.
|
||||
|
@ -237,7 +237,7 @@ class ExceptionHandler {
|
|||
|
||||
// Convenience form of WriteMinidump which does not require an
|
||||
// ExceptionHandler instance.
|
||||
static bool WriteMinidump(const wstring &dump_path,
|
||||
static bool WriteMinidump(const wstring& dump_path,
|
||||
MinidumpCallback callback, void* callback_context,
|
||||
MINIDUMP_TYPE dump_type = MiniDumpNormal);
|
||||
|
||||
|
@ -513,8 +513,8 @@ class ExceptionHandler {
|
|||
static volatile LONG instance_count_;
|
||||
|
||||
// disallow copy ctor and operator=
|
||||
explicit ExceptionHandler(const ExceptionHandler &);
|
||||
void operator=(const ExceptionHandler &);
|
||||
explicit ExceptionHandler(const ExceptionHandler&);
|
||||
void operator=(const ExceptionHandler&);
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
|
|
@ -45,12 +45,12 @@ namespace google_breakpad {
|
|||
|
||||
static const char kCheckpointSignature[] = "GBP1\n";
|
||||
|
||||
CrashReportSender::CrashReportSender(const wstring &checkpoint_file)
|
||||
CrashReportSender::CrashReportSender(const wstring& checkpoint_file)
|
||||
: checkpoint_file_(checkpoint_file),
|
||||
max_reports_per_day_(-1),
|
||||
last_sent_date_(-1),
|
||||
reports_sent_(0) {
|
||||
FILE *fd;
|
||||
FILE* fd;
|
||||
if (OpenCheckpointFile(L"r", &fd) == 0) {
|
||||
ReadCheckpoint(fd);
|
||||
fclose(fd);
|
||||
|
@ -58,8 +58,8 @@ CrashReportSender::CrashReportSender(const wstring &checkpoint_file)
|
|||
}
|
||||
|
||||
ReportResult CrashReportSender::SendCrashReport(
|
||||
const wstring &url, const map<wstring, wstring> ¶meters,
|
||||
const map<wstring, wstring> &files, wstring *report_code) {
|
||||
const wstring& url, const map<wstring, wstring>& parameters,
|
||||
const map<wstring, wstring>& files, wstring* report_code) {
|
||||
int today = GetCurrentDate();
|
||||
if (today == last_sent_date_ &&
|
||||
max_reports_per_day_ != -1 &&
|
||||
|
@ -82,7 +82,7 @@ ReportResult CrashReportSender::SendCrashReport(
|
|||
}
|
||||
}
|
||||
|
||||
void CrashReportSender::ReadCheckpoint(FILE *fd) {
|
||||
void CrashReportSender::ReadCheckpoint(FILE* fd) {
|
||||
char buf[128];
|
||||
if (!fgets(buf, sizeof(buf), fd) ||
|
||||
strcmp(buf, kCheckpointSignature) != 0) {
|
||||
|
@ -108,7 +108,7 @@ void CrashReportSender::ReportSent(int today) {
|
|||
++reports_sent_;
|
||||
|
||||
// Update the checkpoint file
|
||||
FILE *fd;
|
||||
FILE* fd;
|
||||
if (OpenCheckpointFile(L"w", &fd) == 0) {
|
||||
fputs(kCheckpointSignature, fd);
|
||||
fprintf(fd, "%d\n", last_sent_date_);
|
||||
|
@ -124,7 +124,7 @@ int CrashReportSender::GetCurrentDate() const {
|
|||
system_time.wDay;
|
||||
}
|
||||
|
||||
int CrashReportSender::OpenCheckpointFile(const wchar_t *mode, FILE **fd) {
|
||||
int CrashReportSender::OpenCheckpointFile(const wchar_t* mode, FILE** fd) {
|
||||
if (checkpoint_file_.empty()) {
|
||||
return ENOENT;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class CrashReportSender {
|
|||
// If checkpoint_file is non-empty, breakpad will persist crash report
|
||||
// state to this file. A checkpoint file is required for
|
||||
// set_max_reports_per_day() to function properly.
|
||||
explicit CrashReportSender(const wstring &checkpoint_file);
|
||||
explicit CrashReportSender(const wstring& checkpoint_file);
|
||||
~CrashReportSender() {}
|
||||
|
||||
// Sets the maximum number of crash reports that will be sent in a 24-hour
|
||||
|
@ -87,14 +87,14 @@ class CrashReportSender {
|
|||
// the return value is RESULT_SUCCEEDED), a code uniquely identifying the
|
||||
// report will be returned in report_code.
|
||||
// (Otherwise, report_code will be unchanged.)
|
||||
ReportResult SendCrashReport(const wstring &url,
|
||||
const map<wstring, wstring> ¶meters,
|
||||
const map<wstring, wstring> &files,
|
||||
wstring *report_code);
|
||||
ReportResult SendCrashReport(const wstring& url,
|
||||
const map<wstring, wstring>& parameters,
|
||||
const map<wstring, wstring>& files,
|
||||
wstring* report_code);
|
||||
|
||||
private:
|
||||
// Reads persistent state from a checkpoint file.
|
||||
void ReadCheckpoint(FILE *fd);
|
||||
void ReadCheckpoint(FILE* fd);
|
||||
|
||||
// Called when a new report has been sent, to update the checkpoint state.
|
||||
void ReportSent(int today);
|
||||
|
@ -104,7 +104,7 @@ class CrashReportSender {
|
|||
|
||||
// Opens the checkpoint file with the specified mode.
|
||||
// Returns zero on success, or an error code on failure.
|
||||
int OpenCheckpointFile(const wchar_t *mode, FILE **fd);
|
||||
int OpenCheckpointFile(const wchar_t* mode, FILE** fd);
|
||||
|
||||
wstring checkpoint_file_;
|
||||
int max_reports_per_day_;
|
||||
|
@ -114,8 +114,8 @@ class CrashReportSender {
|
|||
int reports_sent_;
|
||||
|
||||
// Disallow copy constructor and operator=
|
||||
explicit CrashReportSender(const CrashReportSender &);
|
||||
void operator=(const CrashReportSender &);
|
||||
explicit CrashReportSender(const CrashReportSender&);
|
||||
void operator=(const CrashReportSender&);
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
|
|
@ -127,8 +127,8 @@ size_t DumpAnalysis::GetStreamImpl(ULONG stream_number, void** stream) const {
|
|||
return ret ? memory_list_size : 0;
|
||||
}
|
||||
|
||||
bool DumpAnalysis::HasMemoryImpl(const void *addr_in, size_t structuresize,
|
||||
void **structure) const {
|
||||
bool DumpAnalysis::HasMemoryImpl(const void* addr_in, size_t structuresize,
|
||||
void** structure) const {
|
||||
uintptr_t address = reinterpret_cast<uintptr_t>(addr_in);
|
||||
MINIDUMP_MEMORY_LIST* memory_list = NULL;
|
||||
size_t memory_list_size = GetStream(MemoryListStream, &memory_list);
|
||||
|
|
|
@ -52,7 +52,7 @@ const char kSuccessIndicator[] = "success";
|
|||
const char kFailureIndicator[] = "failure";
|
||||
|
||||
// Utility function to test for a path's existence.
|
||||
BOOL DoesPathExist(const TCHAR *path_name);
|
||||
BOOL DoesPathExist(const TCHAR* path_name);
|
||||
|
||||
enum OutOfProcGuarantee {
|
||||
OUT_OF_PROC_GUARANTEED,
|
||||
|
@ -92,7 +92,7 @@ void ExceptionHandlerDeathTest::SetUp() {
|
|||
CreateDirectory(temp_path_, NULL);
|
||||
}
|
||||
|
||||
BOOL DoesPathExist(const TCHAR *path_name) {
|
||||
BOOL DoesPathExist(const TCHAR* path_name) {
|
||||
DWORD flags = GetFileAttributes(path_name);
|
||||
if (flags == INVALID_FILE_ATTRIBUTES) {
|
||||
return FALSE;
|
||||
|
@ -135,15 +135,15 @@ TEST_F(ExceptionHandlerDeathTest, InProcTest) {
|
|||
// Disable GTest SEH handler
|
||||
testing::DisableExceptionHandlerInScope disable_exception_handler;
|
||||
|
||||
int *i = NULL;
|
||||
int* i = NULL;
|
||||
ASSERT_DEATH((*i)++, kSuccessIndicator);
|
||||
}
|
||||
|
||||
static bool gDumpCallbackCalled = false;
|
||||
|
||||
void clientDumpCallback(void *dump_context,
|
||||
const google_breakpad::ClientInfo *client_info,
|
||||
const std::wstring *dump_path) {
|
||||
void clientDumpCallback(void* dump_context,
|
||||
const google_breakpad::ClientInfo* client_info,
|
||||
const std::wstring* dump_path) {
|
||||
gDumpCallbackCalled = true;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ void ExceptionHandlerDeathTest::DoCrashAccessViolation(
|
|||
scoped_ptr<google_breakpad::ExceptionHandler> exc;
|
||||
|
||||
if (out_of_proc_guarantee == OUT_OF_PROC_GUARANTEED) {
|
||||
google_breakpad::CrashGenerationClient *client =
|
||||
google_breakpad::CrashGenerationClient* client =
|
||||
new google_breakpad::CrashGenerationClient(kPipeName,
|
||||
MiniDumpNormal,
|
||||
NULL); // custom_info
|
||||
|
@ -184,7 +184,7 @@ void ExceptionHandlerDeathTest::DoCrashAccessViolation(
|
|||
// if it's not true we'll still get an error rather than the crash
|
||||
// being expected.
|
||||
ASSERT_TRUE(exc->IsOutOfProcess());
|
||||
int *i = NULL;
|
||||
int* i = NULL;
|
||||
printf("%d\n", (*i)++);
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ TEST_F(ExceptionHandlerDeathTest, PureVirtualCallTest) {
|
|||
EXPECT_EXIT(DoCrashPureVirtualCall(), ::testing::ExitedWithCode(0), "");
|
||||
}
|
||||
|
||||
wstring find_minidump_in_directory(const wstring &directory) {
|
||||
wstring find_minidump_in_directory(const wstring& directory) {
|
||||
wstring search_path = directory + L"\\*";
|
||||
WIN32_FIND_DATA find_data;
|
||||
HANDLE find_handle = FindFirstFileW(search_path.c_str(), &find_data);
|
||||
|
|
|
@ -49,7 +49,7 @@ const char kFilterReturnsFalse[] = "filter_returns_false";
|
|||
const char kCallbackReturnsTrue[] = "callback_returns_true";
|
||||
const char kCallbackReturnsFalse[] = "callback_returns_false";
|
||||
|
||||
bool DoesPathExist(const wchar_t *path_name) {
|
||||
bool DoesPathExist(const wchar_t* path_name) {
|
||||
DWORD flags = GetFileAttributes(path_name);
|
||||
if (flags == INVALID_FILE_ATTRIBUTES) {
|
||||
return false;
|
||||
|
@ -128,12 +128,12 @@ bool MinidumpWrittenCallback(const wchar_t* dump_path,
|
|||
}
|
||||
|
||||
|
||||
void DoCrash(const char *message) {
|
||||
void DoCrash(const char* message) {
|
||||
if (message) {
|
||||
fprintf(stderr, "%s", message);
|
||||
fflush(stderr);
|
||||
}
|
||||
int *i = NULL;
|
||||
int* i = NULL;
|
||||
(*i)++;
|
||||
|
||||
ASSERT_TRUE(false);
|
||||
|
|
|
@ -87,13 +87,13 @@ class ExceptionHandlerTest : public ::testing::Test {
|
|||
void DoCrashPureVirtualCall();
|
||||
|
||||
// Utility function to test for a path's existence.
|
||||
static BOOL DoesPathExist(const TCHAR *path_name);
|
||||
static BOOL DoesPathExist(const TCHAR* path_name);
|
||||
|
||||
// Client callback.
|
||||
static void ClientDumpCallback(
|
||||
void *dump_context,
|
||||
const google_breakpad::ClientInfo *client_info,
|
||||
const std::wstring *dump_path);
|
||||
void* dump_context,
|
||||
const google_breakpad::ClientInfo* client_info,
|
||||
const std::wstring* dump_path);
|
||||
|
||||
static bool DumpCallback(const wchar_t* dump_path,
|
||||
const wchar_t* minidump_id,
|
||||
|
@ -141,7 +141,7 @@ void ExceptionHandlerTest::TearDown() {
|
|||
}
|
||||
}
|
||||
|
||||
BOOL ExceptionHandlerTest::DoesPathExist(const TCHAR *path_name) {
|
||||
BOOL ExceptionHandlerTest::DoesPathExist(const TCHAR* path_name) {
|
||||
DWORD flags = GetFileAttributes(path_name);
|
||||
if (flags == INVALID_FILE_ATTRIBUTES) {
|
||||
return FALSE;
|
||||
|
@ -151,9 +151,9 @@ BOOL ExceptionHandlerTest::DoesPathExist(const TCHAR *path_name) {
|
|||
|
||||
// static
|
||||
void ExceptionHandlerTest::ClientDumpCallback(
|
||||
void *dump_context,
|
||||
const google_breakpad::ClientInfo *client_info,
|
||||
const wstring *dump_path) {
|
||||
void* dump_context,
|
||||
const google_breakpad::ClientInfo* client_info,
|
||||
const wstring* dump_path) {
|
||||
dump_file = *dump_path;
|
||||
// Create the full dump file name from the dump path.
|
||||
full_dump_file = dump_file.substr(0, dump_file.length() - 4) + L"-full.dmp";
|
||||
|
@ -174,7 +174,7 @@ bool ExceptionHandlerTest::DumpCallback(const wchar_t* dump_path,
|
|||
}
|
||||
|
||||
void ExceptionHandlerTest::DoCrashInvalidParameter() {
|
||||
google_breakpad::ExceptionHandler *exc =
|
||||
google_breakpad::ExceptionHandler* exc =
|
||||
new google_breakpad::ExceptionHandler(
|
||||
temp_path_, NULL, NULL, NULL,
|
||||
google_breakpad::ExceptionHandler::HANDLER_INVALID_PARAMETER,
|
||||
|
@ -206,7 +206,7 @@ struct PureVirtualCall : public PureVirtualCallBase {
|
|||
};
|
||||
|
||||
void ExceptionHandlerTest::DoCrashPureVirtualCall() {
|
||||
google_breakpad::ExceptionHandler *exc =
|
||||
google_breakpad::ExceptionHandler* exc =
|
||||
new google_breakpad::ExceptionHandler(
|
||||
temp_path_, NULL, NULL, NULL,
|
||||
google_breakpad::ExceptionHandler::HANDLER_PURECALL,
|
||||
|
|
|
@ -80,7 +80,7 @@ int pthread_barrier_wait(pthread_barrier_t* barrier) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pthread_barrier_destroy(pthread_barrier_t *barrier) {
|
||||
int pthread_barrier_destroy(pthread_barrier_t* barrier) {
|
||||
barrier->count = 0;
|
||||
pthread_cond_destroy(&barrier->cond);
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
|
|
|
@ -52,16 +52,16 @@ namespace google_breakpad {
|
|||
// A buffer holding a series of bytes.
|
||||
struct ByteBuffer {
|
||||
ByteBuffer() : start(0), end(0) { }
|
||||
ByteBuffer(const uint8_t *set_start, size_t set_size)
|
||||
ByteBuffer(const uint8_t* set_start, size_t set_size)
|
||||
: start(set_start), end(set_start + set_size) { }
|
||||
~ByteBuffer() { };
|
||||
|
||||
// Equality operators. Useful in unit tests, and when we're using
|
||||
// ByteBuffers to refer to regions of a larger buffer.
|
||||
bool operator==(const ByteBuffer &that) const {
|
||||
bool operator==(const ByteBuffer& that) const {
|
||||
return start == that.start && end == that.end;
|
||||
}
|
||||
bool operator!=(const ByteBuffer &that) const {
|
||||
bool operator!=(const ByteBuffer& that) const {
|
||||
return start != that.start || end != that.end;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,8 @@ struct ByteBuffer {
|
|||
return end - start;
|
||||
}
|
||||
|
||||
const uint8_t *start, *end;
|
||||
const uint8_t* start;
|
||||
const uint8_t* end;
|
||||
};
|
||||
|
||||
// A cursor pointing into a ByteBuffer that can parse numbers of various
|
||||
|
@ -82,8 +83,8 @@ class ByteCursor {
|
|||
public:
|
||||
// Create a cursor reading bytes from the start of BUFFER. By default, the
|
||||
// cursor reads multi-byte values in little-endian form.
|
||||
ByteCursor(const ByteBuffer *buffer, bool big_endian = false)
|
||||
: buffer_(buffer), here_(buffer->start),
|
||||
ByteCursor(const ByteBuffer* buffer, bool big_endian = false)
|
||||
: buffer_(buffer), here_(buffer->start),
|
||||
big_endian_(big_endian), complete_(true) { }
|
||||
|
||||
// Accessor and setter for this cursor's endianness flag.
|
||||
|
@ -92,8 +93,8 @@ class ByteCursor {
|
|||
|
||||
// Accessor and setter for this cursor's current position. The setter
|
||||
// returns a reference to this cursor.
|
||||
const uint8_t *here() const { return here_; }
|
||||
ByteCursor &set_here(const uint8_t *here) {
|
||||
const uint8_t* here() const { return here_; }
|
||||
ByteCursor& set_here(const uint8_t* here) {
|
||||
assert(buffer_->start <= here && here <= buffer_->end);
|
||||
here_ = here;
|
||||
return *this;
|
||||
|
@ -116,7 +117,7 @@ class ByteCursor {
|
|||
// this cursor's complete_ flag, and store a dummy value in *RESULT.
|
||||
// Return a reference to this cursor.
|
||||
template<typename T>
|
||||
ByteCursor &Read(size_t size, bool is_signed, T *result) {
|
||||
ByteCursor& Read(size_t size, bool is_signed, T* result) {
|
||||
if (CheckAvailable(size)) {
|
||||
T v = 0;
|
||||
if (big_endian_) {
|
||||
|
@ -145,7 +146,7 @@ class ByteCursor {
|
|||
// read off the end of our buffer, clear this cursor's complete_ flag.
|
||||
// Return a reference to this cursor.
|
||||
template<typename T>
|
||||
ByteCursor &operator>>(T &result) {
|
||||
ByteCursor& operator>>(T& result) {
|
||||
bool T_is_signed = (T)-1 < 0;
|
||||
return Read(sizeof(T), T_is_signed, &result);
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ class ByteCursor {
|
|||
// cursor to the end of them. If we read off the end of our buffer,
|
||||
// clear this cursor's complete_ flag, and set *POINTER to NULL.
|
||||
// Return a reference to this cursor.
|
||||
ByteCursor &Read(uint8_t *buffer, size_t size) {
|
||||
ByteCursor& Read(uint8_t* buffer, size_t size) {
|
||||
if (CheckAvailable(size)) {
|
||||
memcpy(buffer, here_, size);
|
||||
here_ += size;
|
||||
|
@ -166,11 +167,11 @@ class ByteCursor {
|
|||
// byte buffer does not contain a terminating zero, clear this cursor's
|
||||
// complete_ flag, and set STR to the empty string. Return a reference to
|
||||
// this cursor.
|
||||
ByteCursor &CString(string *str) {
|
||||
const uint8_t *end
|
||||
= static_cast<const uint8_t *>(memchr(here_, '\0', Available()));
|
||||
ByteCursor& CString(string* str) {
|
||||
const uint8_t* end
|
||||
= static_cast<const uint8_t*>(memchr(here_, '\0', Available()));
|
||||
if (end) {
|
||||
str->assign(reinterpret_cast<const char *>(here_), end - here_);
|
||||
str->assign(reinterpret_cast<const char*>(here_), end - here_);
|
||||
here_ = end + 1;
|
||||
} else {
|
||||
str->clear();
|
||||
|
@ -193,14 +194,14 @@ class ByteCursor {
|
|||
//
|
||||
// - Otherwise, set *STR to a copy of those LIMIT bytes, and advance the
|
||||
// cursor by LIMIT bytes.
|
||||
ByteCursor &CString(string *str, size_t limit) {
|
||||
ByteCursor& CString(string* str, size_t limit) {
|
||||
if (CheckAvailable(limit)) {
|
||||
const uint8_t *end
|
||||
= static_cast<const uint8_t *>(memchr(here_, '\0', limit));
|
||||
const uint8_t* end
|
||||
= static_cast<const uint8_t*>(memchr(here_, '\0', limit));
|
||||
if (end)
|
||||
str->assign(reinterpret_cast<const char *>(here_), end - here_);
|
||||
str->assign(reinterpret_cast<const char*>(here_), end - here_);
|
||||
else
|
||||
str->assign(reinterpret_cast<const char *>(here_), limit);
|
||||
str->assign(reinterpret_cast<const char*>(here_), limit);
|
||||
here_ += limit;
|
||||
} else {
|
||||
str->clear();
|
||||
|
@ -213,7 +214,7 @@ class ByteCursor {
|
|||
// cursor. If we read off the end of our buffer, clear this cursor's
|
||||
// complete_ flag, and set *POINTER to NULL. Return a reference to this
|
||||
// cursor.
|
||||
ByteCursor &PointTo(const uint8_t **pointer, size_t size = 0) {
|
||||
ByteCursor& PointTo(const uint8_t** pointer, size_t size = 0) {
|
||||
if (CheckAvailable(size)) {
|
||||
*pointer = here_;
|
||||
here_ += size;
|
||||
|
@ -226,7 +227,7 @@ class ByteCursor {
|
|||
// Skip SIZE bytes at the cursor. If doing so would advance us off
|
||||
// the end of our buffer, clear this cursor's complete_ flag, and
|
||||
// set *POINTER to NULL. Return a reference to this cursor.
|
||||
ByteCursor &Skip(size_t size) {
|
||||
ByteCursor& Skip(size_t size) {
|
||||
if (CheckAvailable(size))
|
||||
here_ += size;
|
||||
return *this;
|
||||
|
@ -247,10 +248,10 @@ class ByteCursor {
|
|||
}
|
||||
|
||||
// The buffer we're reading bytes from.
|
||||
const ByteBuffer *buffer_;
|
||||
const ByteBuffer* buffer_;
|
||||
|
||||
// The next byte within buffer_ that we'll read.
|
||||
const uint8_t *here_;
|
||||
const uint8_t* here_;
|
||||
|
||||
// True if we should read numbers in big-endian form; false if we
|
||||
// should read in little-endian form.
|
||||
|
|
|
@ -593,7 +593,7 @@ TEST(Extractor, Signed4) {
|
|||
int32_t a;
|
||||
// For some reason, G++ 4.4.1 complains:
|
||||
// warning: array subscript is above array bounds
|
||||
// in ByteCursor::Read(size_t, bool, T *) as it inlines this call, but
|
||||
// in ByteCursor::Read(size_t, bool, T*) as it inlines this call, but
|
||||
// I'm not able to see how such a reference would occur.
|
||||
EXPECT_TRUE(cursor >> a);
|
||||
EXPECT_EQ(-380377902, a);
|
||||
|
@ -627,7 +627,7 @@ TEST(Extractor, Unsigned4) {
|
|||
uint32_t a;
|
||||
// For some reason, G++ 4.4.1 complains:
|
||||
// warning: array subscript is above array bounds
|
||||
// in ByteCursor::Read(size_t, bool, T *) as it inlines this call, but
|
||||
// in ByteCursor::Read(size_t, bool, T*) as it inlines this call, but
|
||||
// I'm not able to see how such a reference would occur.
|
||||
EXPECT_TRUE(cursor >> a);
|
||||
EXPECT_EQ(0xe953e4d2, a);
|
||||
|
@ -718,10 +718,10 @@ TEST(Strings, PointTo) {
|
|||
ByteBuffer buffer(data, sizeof(data));
|
||||
ByteCursor cursor(&buffer);
|
||||
|
||||
const uint8_t *received1;
|
||||
const uint8_t *received2;
|
||||
const uint8_t *received3;
|
||||
const uint8_t *received4;
|
||||
const uint8_t* received1;
|
||||
const uint8_t* received2;
|
||||
const uint8_t* received3;
|
||||
const uint8_t* received4;
|
||||
EXPECT_FALSE(cursor
|
||||
.PointTo(&received1, 3)
|
||||
.PointTo(&received2, 3)
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
|
||||
namespace dwarf2reader {
|
||||
|
||||
inline uint8_t ByteReader::ReadOneByte(const uint8_t *buffer) const {
|
||||
inline uint8_t ByteReader::ReadOneByte(const uint8_t* buffer) const {
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
inline uint16_t ByteReader::ReadTwoBytes(const uint8_t *buffer) const {
|
||||
inline uint16_t ByteReader::ReadTwoBytes(const uint8_t* buffer) const {
|
||||
const uint16_t buffer0 = buffer[0];
|
||||
const uint16_t buffer1 = buffer[1];
|
||||
if (endian_ == ENDIANNESS_LITTLE) {
|
||||
|
@ -61,7 +61,7 @@ inline uint64_t ByteReader::ReadThreeBytes(const uint8_t* buffer) const {
|
|||
}
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadFourBytes(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadFourBytes(const uint8_t* buffer) const {
|
||||
const uint32_t buffer0 = buffer[0];
|
||||
const uint32_t buffer1 = buffer[1];
|
||||
const uint32_t buffer2 = buffer[2];
|
||||
|
@ -73,7 +73,7 @@ inline uint64_t ByteReader::ReadFourBytes(const uint8_t *buffer) const {
|
|||
}
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadEightBytes(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadEightBytes(const uint8_t* buffer) const {
|
||||
const uint64_t buffer0 = buffer[0];
|
||||
const uint64_t buffer1 = buffer[1];
|
||||
const uint64_t buffer2 = buffer[2];
|
||||
|
@ -95,7 +95,7 @@ inline uint64_t ByteReader::ReadEightBytes(const uint8_t *buffer) const {
|
|||
// information, plus one bit saying whether the number continues or
|
||||
// not.
|
||||
|
||||
inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t *buffer,
|
||||
inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t* buffer,
|
||||
size_t* len) const {
|
||||
uint64_t result = 0;
|
||||
size_t num_read = 0;
|
||||
|
@ -120,7 +120,7 @@ inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t *buffer,
|
|||
// Read a signed LEB128 number. These are like regular LEB128
|
||||
// numbers, except the last byte may have a sign bit set.
|
||||
|
||||
inline int64_t ByteReader::ReadSignedLEB128(const uint8_t *buffer,
|
||||
inline int64_t ByteReader::ReadSignedLEB128(const uint8_t* buffer,
|
||||
size_t* len) const {
|
||||
int64_t result = 0;
|
||||
unsigned int shift = 0;
|
||||
|
@ -140,18 +140,18 @@ inline int64_t ByteReader::ReadSignedLEB128(const uint8_t *buffer,
|
|||
return result;
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadOffset(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadOffset(const uint8_t* buffer) const {
|
||||
assert(this->offset_reader_);
|
||||
return (this->*offset_reader_)(buffer);
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadAddress(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadAddress(const uint8_t* buffer) const {
|
||||
assert(this->address_reader_);
|
||||
return (this->*address_reader_)(buffer);
|
||||
}
|
||||
|
||||
inline void ByteReader::SetCFIDataBase(uint64_t section_base,
|
||||
const uint8_t *buffer_base) {
|
||||
const uint8_t* buffer_base) {
|
||||
section_base_ = section_base;
|
||||
buffer_base_ = buffer_base;
|
||||
have_section_base_ = true;
|
||||
|
|
|
@ -63,7 +63,7 @@ void ByteReader::SetAddressSize(uint8_t size) {
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t ByteReader::ReadInitialLength(const uint8_t *start, size_t* len) {
|
||||
uint64_t ByteReader::ReadInitialLength(const uint8_t* start, size_t* len) {
|
||||
const uint64_t initial_length = ReadFourBytes(start);
|
||||
start += 4;
|
||||
|
||||
|
@ -101,9 +101,9 @@ bool ByteReader::UsableEncoding(DwarfPointerEncoding encoding) const {
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t ByteReader::ReadEncodedPointer(const uint8_t *buffer,
|
||||
uint64_t ByteReader::ReadEncodedPointer(const uint8_t* buffer,
|
||||
DwarfPointerEncoding encoding,
|
||||
size_t *len) const {
|
||||
size_t* len) const {
|
||||
// UsableEncoding doesn't approve of DW_EH_PE_omit, so we shouldn't
|
||||
// see it here.
|
||||
assert(encoding != DW_EH_PE_omit);
|
||||
|
@ -130,7 +130,7 @@ uint64_t ByteReader::ReadEncodedPointer(const uint8_t *buffer,
|
|||
// Round up to the next boundary.
|
||||
uint64_t aligned = (offset + AddressSize() - 1) & -AddressSize();
|
||||
// Convert back to a pointer.
|
||||
const uint8_t *aligned_buffer = buffer_base_ + (aligned - skew);
|
||||
const uint8_t* aligned_buffer = buffer_base_ + (aligned - skew);
|
||||
// Finally, store the length and actually fetch the pointer.
|
||||
*len = aligned_buffer - buffer + AddressSize();
|
||||
return ReadAddress(aligned_buffer);
|
||||
|
|
|
@ -62,11 +62,11 @@ class ByteReader {
|
|||
|
||||
// Read a single byte from BUFFER and return it as an unsigned 8 bit
|
||||
// number.
|
||||
uint8_t ReadOneByte(const uint8_t *buffer) const;
|
||||
uint8_t ReadOneByte(const uint8_t* buffer) const;
|
||||
|
||||
// Read two bytes from BUFFER and return them as an unsigned 16 bit
|
||||
// number, using this ByteReader's endianness.
|
||||
uint16_t ReadTwoBytes(const uint8_t *buffer) const;
|
||||
uint16_t ReadTwoBytes(const uint8_t* buffer) const;
|
||||
|
||||
// Read three bytes from BUFFER and return them as an unsigned 64 bit
|
||||
// number, using this ByteReader's endianness. DWARF 5 uses this encoding
|
||||
|
@ -78,11 +78,11 @@ class ByteReader {
|
|||
// a uint64_t so that it is compatible with ReadAddress and
|
||||
// ReadOffset. The number it returns will never be outside the range
|
||||
// of an unsigned 32 bit integer.
|
||||
uint64_t ReadFourBytes(const uint8_t *buffer) const;
|
||||
uint64_t ReadFourBytes(const uint8_t* buffer) const;
|
||||
|
||||
// Read eight bytes from BUFFER and return them as an unsigned 64
|
||||
// bit number, using this ByteReader's endianness.
|
||||
uint64_t ReadEightBytes(const uint8_t *buffer) const;
|
||||
uint64_t ReadEightBytes(const uint8_t* buffer) const;
|
||||
|
||||
// Read an unsigned LEB128 (Little Endian Base 128) number from
|
||||
// BUFFER and return it as an unsigned 64 bit integer. Set LEN to
|
||||
|
@ -101,7 +101,7 @@ class ByteReader {
|
|||
// In other words, we break VALUE into groups of seven bits, put
|
||||
// them in little-endian order, and then write them as eight-bit
|
||||
// bytes with the high bit on all but the last.
|
||||
uint64_t ReadUnsignedLEB128(const uint8_t *buffer, size_t *len) const;
|
||||
uint64_t ReadUnsignedLEB128(const uint8_t* buffer, size_t* len) const;
|
||||
|
||||
// Read a signed LEB128 number from BUFFER and return it as an
|
||||
// signed 64 bit integer. Set LEN to the number of bytes read.
|
||||
|
@ -120,7 +120,7 @@ class ByteReader {
|
|||
// In other words, we break VALUE into groups of seven bits, put
|
||||
// them in little-endian order, and then write them as eight-bit
|
||||
// bytes with the high bit on all but the last.
|
||||
int64_t ReadSignedLEB128(const uint8_t *buffer, size_t *len) const;
|
||||
int64_t ReadSignedLEB128(const uint8_t* buffer, size_t* len) const;
|
||||
|
||||
// Indicate that addresses on this architecture are SIZE bytes long. SIZE
|
||||
// must be either 4 or 8. (DWARF allows addresses to be any number of
|
||||
|
@ -143,7 +143,7 @@ class ByteReader {
|
|||
// Read an address from BUFFER and return it as an unsigned 64 bit
|
||||
// integer, respecting this ByteReader's endianness and address size. You
|
||||
// must call SetAddressSize before calling this function.
|
||||
uint64_t ReadAddress(const uint8_t *buffer) const;
|
||||
uint64_t ReadAddress(const uint8_t* buffer) const;
|
||||
|
||||
// DWARF actually defines two slightly different formats: 32-bit DWARF
|
||||
// and 64-bit DWARF. This is *not* related to the size of registers or
|
||||
|
@ -180,14 +180,14 @@ class ByteReader {
|
|||
// - The 32-bit value 0xffffffff, followed by a 64-bit byte count,
|
||||
// indicating that the data whose length is being measured uses
|
||||
// the 64-bit DWARF format.
|
||||
uint64_t ReadInitialLength(const uint8_t *start, size_t *len);
|
||||
uint64_t ReadInitialLength(const uint8_t* start, size_t* len);
|
||||
|
||||
// Read an offset from BUFFER and return it as an unsigned 64 bit
|
||||
// integer, respecting the ByteReader's endianness. In 32-bit DWARF, the
|
||||
// offset is 4 bytes long; in 64-bit DWARF, the offset is eight bytes
|
||||
// long. You must call ReadInitialLength or SetOffsetSize before calling
|
||||
// this function; see the comments above for details.
|
||||
uint64_t ReadOffset(const uint8_t *buffer) const;
|
||||
uint64_t ReadOffset(const uint8_t* buffer) const;
|
||||
|
||||
// Return the current offset size, in bytes.
|
||||
// A return value of 4 indicates that we are reading 32-bit DWARF.
|
||||
|
@ -242,7 +242,7 @@ class ByteReader {
|
|||
// is BUFFER_BASE. This allows us to find the address that a given
|
||||
// byte in our buffer would have when loaded into the program the
|
||||
// data describes. We need this to resolve DW_EH_PE_pcrel pointers.
|
||||
void SetCFIDataBase(uint64_t section_base, const uint8_t *buffer_base);
|
||||
void SetCFIDataBase(uint64_t section_base, const uint8_t* buffer_base);
|
||||
|
||||
// Indicate that the base address of the program's ".text" section
|
||||
// is TEXT_BASE. We need this to resolve DW_EH_PE_textrel pointers.
|
||||
|
@ -281,15 +281,15 @@ class ByteReader {
|
|||
// base address this reader hasn't been given, so you should check
|
||||
// with ValidEncoding and UsableEncoding first if you would rather
|
||||
// die in a more helpful way.
|
||||
uint64_t ReadEncodedPointer(const uint8_t *buffer,
|
||||
uint64_t ReadEncodedPointer(const uint8_t* buffer,
|
||||
DwarfPointerEncoding encoding,
|
||||
size_t *len) const;
|
||||
size_t* len) const;
|
||||
|
||||
Endianness GetEndianness() const;
|
||||
private:
|
||||
|
||||
// Function pointer type for our address and offset readers.
|
||||
typedef uint64_t (ByteReader::*AddressReader)(const uint8_t *) const;
|
||||
typedef uint64_t (ByteReader::*AddressReader)(const uint8_t*) const;
|
||||
|
||||
// Read an offset from BUFFER and return it as an unsigned 64 bit
|
||||
// integer. DWARF2/3 define offsets as either 4 or 8 bytes,
|
||||
|
@ -312,7 +312,7 @@ class ByteReader {
|
|||
bool have_section_base_, have_text_base_, have_data_base_;
|
||||
bool have_function_base_;
|
||||
uint64_t section_base_, text_base_, data_base_, function_base_;
|
||||
const uint8_t *buffer_base_;
|
||||
const uint8_t* buffer_base_;
|
||||
};
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
|
|
@ -73,7 +73,7 @@ TEST_F(Reader, SimpleConstructor) {
|
|||
.LEB128(-0x4f337badf4483f83LL)
|
||||
.D32(0xfec319c9);
|
||||
ASSERT_TRUE(section.GetContents(&contents));
|
||||
const uint8_t *data = reinterpret_cast<const uint8_t *>(contents.data());
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(contents.data());
|
||||
EXPECT_EQ(0xc0U, reader.ReadOneByte(data));
|
||||
EXPECT_EQ(0xcf0dU, reader.ReadTwoBytes(data + 1));
|
||||
EXPECT_EQ(0x96fdd219U, reader.ReadFourBytes(data + 3));
|
||||
|
|
|
@ -41,11 +41,11 @@ namespace google_breakpad {
|
|||
|
||||
using dwarf2reader::DwarfPointerEncoding;
|
||||
|
||||
CFISection &CFISection::CIEHeader(uint64_t code_alignment_factor,
|
||||
CFISection& CFISection::CIEHeader(uint64_t code_alignment_factor,
|
||||
int data_alignment_factor,
|
||||
unsigned return_address_register,
|
||||
uint8_t version,
|
||||
const string &augmentation,
|
||||
const string& augmentation,
|
||||
bool dwarf64,
|
||||
uint8_t address_size,
|
||||
uint8_t segment_size) {
|
||||
|
@ -78,7 +78,7 @@ CFISection &CFISection::CIEHeader(uint64_t code_alignment_factor,
|
|||
return *this;
|
||||
}
|
||||
|
||||
CFISection &CFISection::FDEHeader(Label cie_pointer,
|
||||
CFISection& CFISection::FDEHeader(Label cie_pointer,
|
||||
uint64_t initial_location,
|
||||
uint64_t address_range,
|
||||
bool dwarf64) {
|
||||
|
@ -113,7 +113,7 @@ CFISection &CFISection::FDEHeader(Label cie_pointer,
|
|||
return *this;
|
||||
}
|
||||
|
||||
CFISection &CFISection::FinishEntry() {
|
||||
CFISection& CFISection::FinishEntry() {
|
||||
assert(entry_length_);
|
||||
Align(address_size_, dwarf2reader::DW_CFA_nop);
|
||||
entry_length_->length = Here() - entry_length_->start;
|
||||
|
@ -123,9 +123,9 @@ CFISection &CFISection::FinishEntry() {
|
|||
return *this;
|
||||
}
|
||||
|
||||
CFISection &CFISection::EncodedPointer(uint64_t address,
|
||||
CFISection& CFISection::EncodedPointer(uint64_t address,
|
||||
DwarfPointerEncoding encoding,
|
||||
const EncodedPointerBases &bases) {
|
||||
const EncodedPointerBases& bases) {
|
||||
// Omitted data is extremely easy to emit.
|
||||
if (encoding == dwarf2reader::DW_EH_PE_omit)
|
||||
return *this;
|
||||
|
|
|
@ -120,7 +120,7 @@ class CFISection: public Section {
|
|||
// Use the addresses in BASES as the base addresses for encoded
|
||||
// pointers in subsequent calls to FDEHeader or EncodedPointer.
|
||||
// This function makes a copy of BASES.
|
||||
void SetEncodedPointerBases(const EncodedPointerBases &bases) {
|
||||
void SetEncodedPointerBases(const EncodedPointerBases& bases) {
|
||||
encoded_pointer_bases_ = bases;
|
||||
}
|
||||
|
||||
|
@ -133,11 +133,11 @@ class CFISection: public Section {
|
|||
// Before calling this function, you will typically want to use Mark
|
||||
// or Here to make a label to pass to FDEHeader that refers to this
|
||||
// CIE's position in the section.
|
||||
CFISection &CIEHeader(uint64_t code_alignment_factor,
|
||||
CFISection& CIEHeader(uint64_t code_alignment_factor,
|
||||
int data_alignment_factor,
|
||||
unsigned return_address_register,
|
||||
uint8_t version = 3,
|
||||
const string &augmentation = "",
|
||||
const string& augmentation = "",
|
||||
bool dwarf64 = false,
|
||||
uint8_t address_size = 8,
|
||||
uint8_t segment_size = 0);
|
||||
|
@ -152,7 +152,7 @@ class CFISection: public Section {
|
|||
// 0xffffff00 bytes. (The "initial length" is always a 32-bit
|
||||
// value.) Nor does it support .debug_frame sections longer than
|
||||
// 0xffffff00 bytes.
|
||||
CFISection &FDEHeader(Label cie_pointer,
|
||||
CFISection& FDEHeader(Label cie_pointer,
|
||||
uint64_t initial_location,
|
||||
uint64_t address_range,
|
||||
bool dwarf64 = false);
|
||||
|
@ -161,11 +161,11 @@ class CFISection: public Section {
|
|||
// started, after padding with DW_CFA_nops for alignment. This
|
||||
// defines the label representing the entry's length, cited in the
|
||||
// entry's header. Return a reference to this section.
|
||||
CFISection &FinishEntry();
|
||||
CFISection& FinishEntry();
|
||||
|
||||
// Append the contents of BLOCK as a DW_FORM_block value: an
|
||||
// unsigned LEB128 length, followed by that many bytes of data.
|
||||
CFISection &Block(const string &block) {
|
||||
CFISection& Block(const string& block) {
|
||||
ULEB128(block.size());
|
||||
Append(block);
|
||||
return *this;
|
||||
|
@ -173,11 +173,11 @@ class CFISection: public Section {
|
|||
|
||||
// Append ADDRESS to this section, in the appropriate size and
|
||||
// endianness. Return a reference to this section.
|
||||
CFISection &Address(uint64_t address) {
|
||||
CFISection& Address(uint64_t address) {
|
||||
Section::Append(endianness(), address_size_, address);
|
||||
return *this;
|
||||
}
|
||||
CFISection &Address(Label address) {
|
||||
CFISection& Address(Label address) {
|
||||
Section::Append(endianness(), address_size_, address);
|
||||
return *this;
|
||||
}
|
||||
|
@ -191,26 +191,26 @@ class CFISection: public Section {
|
|||
//
|
||||
// (C++ doesn't let me use default arguments here, because I want to
|
||||
// refer to members of *this in the default argument expression.)
|
||||
CFISection &EncodedPointer(uint64_t address) {
|
||||
CFISection& EncodedPointer(uint64_t address) {
|
||||
return EncodedPointer(address, pointer_encoding_, encoded_pointer_bases_);
|
||||
}
|
||||
CFISection &EncodedPointer(uint64_t address, DwarfPointerEncoding encoding) {
|
||||
CFISection& EncodedPointer(uint64_t address, DwarfPointerEncoding encoding) {
|
||||
return EncodedPointer(address, encoding, encoded_pointer_bases_);
|
||||
}
|
||||
CFISection &EncodedPointer(uint64_t address, DwarfPointerEncoding encoding,
|
||||
const EncodedPointerBases &bases);
|
||||
CFISection& EncodedPointer(uint64_t address, DwarfPointerEncoding encoding,
|
||||
const EncodedPointerBases& bases);
|
||||
|
||||
// Restate some member functions, to keep chaining working nicely.
|
||||
CFISection &Mark(Label *label) { Section::Mark(label); return *this; }
|
||||
CFISection &D8(uint8_t v) { Section::D8(v); return *this; }
|
||||
CFISection &D16(uint16_t v) { Section::D16(v); return *this; }
|
||||
CFISection &D16(Label v) { Section::D16(v); return *this; }
|
||||
CFISection &D32(uint32_t v) { Section::D32(v); return *this; }
|
||||
CFISection &D32(const Label &v) { Section::D32(v); return *this; }
|
||||
CFISection &D64(uint64_t v) { Section::D64(v); return *this; }
|
||||
CFISection &D64(const Label &v) { Section::D64(v); return *this; }
|
||||
CFISection &LEB128(long long v) { Section::LEB128(v); return *this; }
|
||||
CFISection &ULEB128(uint64_t v) { Section::ULEB128(v); return *this; }
|
||||
CFISection& Mark(Label* label) { Section::Mark(label); return *this; }
|
||||
CFISection& D8(uint8_t v) { Section::D8(v); return *this; }
|
||||
CFISection& D16(uint16_t v) { Section::D16(v); return *this; }
|
||||
CFISection& D16(Label v) { Section::D16(v); return *this; }
|
||||
CFISection& D32(uint32_t v) { Section::D32(v); return *this; }
|
||||
CFISection& D32(const Label& v) { Section::D32(v); return *this; }
|
||||
CFISection& D64(uint64_t v) { Section::D64(v); return *this; }
|
||||
CFISection& D64(const Label& v) { Section::D64(v); return *this; }
|
||||
CFISection& LEB128(long long v) { Section::LEB128(v); return *this; }
|
||||
CFISection& ULEB128(uint64_t v) { Section::ULEB128(v); return *this; }
|
||||
|
||||
private:
|
||||
// A length value that we've appended to the section, but is not yet
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace dwarf2reader {
|
|||
|
||||
DIEDispatcher::~DIEDispatcher() {
|
||||
while (!die_handlers_.empty()) {
|
||||
HandlerStack &entry = die_handlers_.top();
|
||||
HandlerStack& entry = die_handlers_.top();
|
||||
if (entry.handler_ != root_handler_)
|
||||
delete entry.handler_;
|
||||
die_handlers_.pop();
|
||||
|
@ -60,7 +60,7 @@ bool DIEDispatcher::StartCompilationUnit(uint64_t offset, uint8_t address_size,
|
|||
|
||||
bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
||||
// The stack entry for the parent of this DIE, if there is one.
|
||||
HandlerStack *parent = die_handlers_.empty() ? NULL : &die_handlers_.top();
|
||||
HandlerStack* parent = die_handlers_.empty() ? NULL : &die_handlers_.top();
|
||||
|
||||
// Does this call indicate that we're done receiving the parent's
|
||||
// attributes' values? If so, call its EndAttributes member function.
|
||||
|
@ -78,7 +78,7 @@ bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
|||
}
|
||||
|
||||
// Find a handler for this DIE.
|
||||
DIEHandler *handler;
|
||||
DIEHandler* handler;
|
||||
if (parent) {
|
||||
if (parent->handler_)
|
||||
// Ask the parent to find a handler.
|
||||
|
@ -115,7 +115,7 @@ bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
|||
|
||||
void DIEDispatcher::EndDIE(uint64_t offset) {
|
||||
assert(!die_handlers_.empty());
|
||||
HandlerStack *entry = &die_handlers_.top();
|
||||
HandlerStack* entry = &die_handlers_.top();
|
||||
if (entry->handler_) {
|
||||
// This entry had better be the handler for this DIE.
|
||||
assert(entry->offset_ == offset);
|
||||
|
@ -139,7 +139,7 @@ void DIEDispatcher::ProcessAttributeUnsigned(uint64_t offset,
|
|||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
uint64_t data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeUnsigned(attr, form, data);
|
||||
|
@ -149,7 +149,7 @@ void DIEDispatcher::ProcessAttributeSigned(uint64_t offset,
|
|||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
int64_t data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeSigned(attr, form, data);
|
||||
|
@ -159,7 +159,7 @@ void DIEDispatcher::ProcessAttributeReference(uint64_t offset,
|
|||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
uint64_t data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeReference(attr, form, data);
|
||||
|
@ -168,9 +168,9 @@ void DIEDispatcher::ProcessAttributeReference(uint64_t offset,
|
|||
void DIEDispatcher::ProcessAttributeBuffer(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeBuffer(attr, form, data, len);
|
||||
|
@ -180,7 +180,7 @@ void DIEDispatcher::ProcessAttributeString(uint64_t offset,
|
|||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string& data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeString(attr, form, data);
|
||||
|
@ -190,7 +190,7 @@ void DIEDispatcher::ProcessAttributeSignature(uint64_t offset,
|
|||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
uint64_t signature) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeSignature(attr, form, signature);
|
||||
|
|
|
@ -208,7 +208,7 @@ class DIEHandler {
|
|||
uint64_t data) { }
|
||||
virtual void ProcessAttributeBuffer(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len) { }
|
||||
virtual void ProcessAttributeString(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
|
@ -244,7 +244,7 @@ class DIEHandler {
|
|||
// it is.
|
||||
//
|
||||
// The default definition skips all children.
|
||||
virtual DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag) {
|
||||
virtual DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ class DIEDispatcher: public Dwarf2Handler {
|
|||
// Create a Dwarf2Handler which uses ROOT_HANDLER as the handler for
|
||||
// the compilation unit's root die, as described for the DIEHandler
|
||||
// class.
|
||||
DIEDispatcher(RootDIEHandler *root_handler) : root_handler_(root_handler) { }
|
||||
DIEDispatcher(RootDIEHandler* root_handler) : root_handler_(root_handler) { }
|
||||
// Destroying a DIEDispatcher destroys all active handler objects
|
||||
// except the root handler.
|
||||
~DIEDispatcher();
|
||||
|
@ -311,12 +311,12 @@ class DIEDispatcher: public Dwarf2Handler {
|
|||
void ProcessAttributeBuffer(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len);
|
||||
void ProcessAttributeString(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data);
|
||||
const string& data);
|
||||
void ProcessAttributeSignature(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
|
@ -335,7 +335,7 @@ class DIEDispatcher: public Dwarf2Handler {
|
|||
|
||||
// The handler object interested in this DIE's attributes and
|
||||
// children. If NULL, we're not interested in either.
|
||||
DIEHandler *handler_;
|
||||
DIEHandler* handler_;
|
||||
|
||||
// Have we reported the end of this DIE's attributes to the handler?
|
||||
bool reported_attributes_end_;
|
||||
|
@ -358,7 +358,7 @@ class DIEDispatcher: public Dwarf2Handler {
|
|||
|
||||
// The root handler. We don't push it on die_handlers_ until we
|
||||
// actually get the StartDIE call for the root.
|
||||
RootDIEHandler *root_handler_;
|
||||
RootDIEHandler* root_handler_;
|
||||
};
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
|
|
@ -69,9 +69,9 @@ class MockDIEHandler: public DIEHandler {
|
|||
MOCK_METHOD3(ProcessAttributeReference,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD4(ProcessAttributeBuffer,
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t *, uint64_t));
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t*, uint64_t));
|
||||
MOCK_METHOD3(ProcessAttributeString,
|
||||
void(DwarfAttribute, DwarfForm, const string &));
|
||||
void(DwarfAttribute, DwarfForm, const string&));
|
||||
MOCK_METHOD3(ProcessAttributeSignature,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD0(EndAttributes, bool());
|
||||
|
@ -88,9 +88,9 @@ class MockRootDIEHandler: public RootDIEHandler {
|
|||
MOCK_METHOD3(ProcessAttributeReference,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD4(ProcessAttributeBuffer,
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t *, uint64_t));
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t*, uint64_t));
|
||||
MOCK_METHOD3(ProcessAttributeString,
|
||||
void(DwarfAttribute, DwarfForm, const string &));
|
||||
void(DwarfAttribute, DwarfForm, const string&));
|
||||
MOCK_METHOD3(ProcessAttributeSignature,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD0(EndAttributes, bool());
|
||||
|
@ -339,7 +339,7 @@ TEST(Dwarf2DIEHandler, FindAndSkipChildren) {
|
|||
EXPECT_CALL(mock_root_handler,
|
||||
FindChildHandler(0x97412be24875de9dLL,
|
||||
(DwarfTag) 0x505a068b))
|
||||
.WillOnce(Return((DIEHandler *) NULL));
|
||||
.WillOnce(Return((DIEHandler*) NULL));
|
||||
|
||||
// Third child DIE.
|
||||
EXPECT_CALL(mock_root_handler,
|
||||
|
|
|
@ -122,9 +122,9 @@ void CompilationUnit::ReadAbbrevs() {
|
|||
// The only way to check whether we are reading over the end of the
|
||||
// buffer would be to first compute the size of the leb128 data by
|
||||
// reading it, then go back and read it again.
|
||||
const uint8_t *abbrev_start = iter->second.first +
|
||||
const uint8_t* abbrev_start = iter->second.first +
|
||||
header_.abbrev_offset;
|
||||
const uint8_t *abbrevptr = abbrev_start;
|
||||
const uint8_t* abbrevptr = abbrev_start;
|
||||
#ifndef NDEBUG
|
||||
const uint64_t abbrev_length = iter->second.second - header_.abbrev_offset;
|
||||
#endif
|
||||
|
@ -171,7 +171,7 @@ void CompilationUnit::ReadAbbrevs() {
|
|||
}
|
||||
|
||||
// Skips a single DIE's attributes.
|
||||
const uint8_t *CompilationUnit::SkipDIE(const uint8_t* start,
|
||||
const uint8_t* CompilationUnit::SkipDIE(const uint8_t* start,
|
||||
const Abbrev& abbrev) {
|
||||
for (AttributeList::const_iterator i = abbrev.attributes.begin();
|
||||
i != abbrev.attributes.end();
|
||||
|
@ -182,7 +182,7 @@ const uint8_t *CompilationUnit::SkipDIE(const uint8_t* start,
|
|||
}
|
||||
|
||||
// Skips a single attribute form's data.
|
||||
const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
|
||||
const uint8_t* CompilationUnit::SkipAttribute(const uint8_t* start,
|
||||
enum DwarfForm form) {
|
||||
size_t len;
|
||||
|
||||
|
@ -219,7 +219,7 @@ const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
|
|||
case DW_FORM_ref_sig8:
|
||||
return start + 8;
|
||||
case DW_FORM_string:
|
||||
return start + strlen(reinterpret_cast<const char *>(start)) + 1;
|
||||
return start + strlen(reinterpret_cast<const char*>(start)) + 1;
|
||||
case DW_FORM_udata:
|
||||
case DW_FORM_ref_udata:
|
||||
case DW_FORM_strx:
|
||||
|
@ -311,7 +311,7 @@ size_t CompilationUnit::ReadTypeOffset(const uint8_t* headerptr) {
|
|||
// abbrevs, and an address size. DWARF5 adds a unit_type to distinguish
|
||||
// between partial-, full-, skeleton-, split-, and type- compilation units.
|
||||
void CompilationUnit::ReadHeader() {
|
||||
const uint8_t *headerptr = buffer_;
|
||||
const uint8_t* headerptr = buffer_;
|
||||
size_t initial_length_size;
|
||||
|
||||
assert(headerptr + 4 < buffer_ + buffer_length_);
|
||||
|
@ -455,8 +455,8 @@ void CompilationUnit::ProcessFormStringIndex(
|
|||
// If one really wanted, you could merge SkipAttribute and
|
||||
// ProcessAttribute
|
||||
// This is all boring data manipulation and calling of the handler.
|
||||
const uint8_t *CompilationUnit::ProcessAttribute(
|
||||
uint64_t dieoffset, const uint8_t *start, enum DwarfAttribute attr,
|
||||
const uint8_t* CompilationUnit::ProcessAttribute(
|
||||
uint64_t dieoffset, const uint8_t* start, enum DwarfAttribute attr,
|
||||
enum DwarfForm form) {
|
||||
size_t len;
|
||||
|
||||
|
@ -490,7 +490,7 @@ const uint8_t *CompilationUnit::ProcessAttribute(
|
|||
reader_->ReadEightBytes(start));
|
||||
return start + 8;
|
||||
case DW_FORM_string: {
|
||||
const char *str = reinterpret_cast<const char *>(start);
|
||||
const char* str = reinterpret_cast<const char*>(start);
|
||||
ProcessAttributeString(dieoffset, attr, form, str);
|
||||
return start + strlen(str) + 1;
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ const uint8_t *CompilationUnit::ProcessAttribute(
|
|||
const uint64_t offset = reader_->ReadOffset(start);
|
||||
assert(string_buffer_ + offset < string_buffer_ + string_buffer_length_);
|
||||
|
||||
const char *str = reinterpret_cast<const char *>(string_buffer_ + offset);
|
||||
const char* str = reinterpret_cast<const char*>(string_buffer_ + offset);
|
||||
ProcessAttributeString(dieoffset, attr, form, str);
|
||||
return start + reader_->OffsetSize();
|
||||
}
|
||||
|
@ -662,8 +662,8 @@ const uint8_t *CompilationUnit::ProcessAttribute(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const uint8_t *CompilationUnit::ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t *start,
|
||||
const uint8_t* CompilationUnit::ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t* start,
|
||||
const Abbrev& abbrev) {
|
||||
for (AttributeList::const_iterator i = abbrev.attributes.begin();
|
||||
i != abbrev.attributes.end();
|
||||
|
@ -684,12 +684,12 @@ const uint8_t *CompilationUnit::ProcessDIE(uint64_t dieoffset,
|
|||
}
|
||||
|
||||
void CompilationUnit::ProcessDIEs() {
|
||||
const uint8_t *dieptr = after_header_;
|
||||
const uint8_t* dieptr = after_header_;
|
||||
size_t len;
|
||||
|
||||
// lengthstart is the place the length field is based on.
|
||||
// It is the point in the header after the initial length field
|
||||
const uint8_t *lengthstart = buffer_;
|
||||
const uint8_t* lengthstart = buffer_;
|
||||
|
||||
// In 64 bit dwarf, the initial length is 12 bytes, because of the
|
||||
// 0xffffffff at the start.
|
||||
|
@ -827,7 +827,7 @@ void CompilationUnit::ReadDebugSectionsFromDwo(ElfReader* elf_reader,
|
|||
if (section_data != NULL)
|
||||
sections->insert(std::make_pair(
|
||||
base_name, std::make_pair(
|
||||
reinterpret_cast<const uint8_t *>(section_data),
|
||||
reinterpret_cast<const uint8_t*>(section_data),
|
||||
section_size)));
|
||||
}
|
||||
}
|
||||
|
@ -856,11 +856,11 @@ void DwpReader::Initialize() {
|
|||
&string_buffer_size_);
|
||||
|
||||
version_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_));
|
||||
|
||||
if (version_ == 1) {
|
||||
nslots_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_)
|
||||
reinterpret_cast<const uint8_t*>(cu_index_)
|
||||
+ 3 * sizeof(uint32_t));
|
||||
phash_ = cu_index_ + 4 * sizeof(uint32_t);
|
||||
pindex_ = phash_ + nslots_ * sizeof(uint64_t);
|
||||
|
@ -870,11 +870,11 @@ void DwpReader::Initialize() {
|
|||
}
|
||||
} else if (version_ == 2) {
|
||||
ncolumns_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_) + sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_) + sizeof(uint32_t));
|
||||
nunits_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_) + 2 * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_) + 2 * sizeof(uint32_t));
|
||||
nslots_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_) + 3 * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_) + 3 * sizeof(uint32_t));
|
||||
phash_ = cu_index_ + 4 * sizeof(uint32_t);
|
||||
pindex_ = phash_ + nslots_ * sizeof(uint64_t);
|
||||
offset_table_ = pindex_ + nslots_ * sizeof(uint32_t);
|
||||
|
@ -902,7 +902,7 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
|||
// can read a list of section indexes for the debug sections
|
||||
// for the CU whose dwo_id we are looking for.
|
||||
int index = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(pindex_)
|
||||
reinterpret_cast<const uint8_t*>(pindex_)
|
||||
+ slot * sizeof(uint32_t));
|
||||
const char* shndx_list = shndx_pool_ + index * sizeof(uint32_t);
|
||||
for (;;) {
|
||||
|
@ -911,7 +911,7 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
|||
return;
|
||||
}
|
||||
unsigned int shndx = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(shndx_list));
|
||||
reinterpret_cast<const uint8_t*>(shndx_list));
|
||||
shndx_list += sizeof(uint32_t);
|
||||
if (shndx == 0)
|
||||
break;
|
||||
|
@ -925,26 +925,26 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
|||
section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size);
|
||||
sections->insert(std::make_pair(
|
||||
".debug_abbrev",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (section_data),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (section_data),
|
||||
section_size)));
|
||||
} else if (!strncmp(section_name, ".debug_info", strlen(".debug_info"))) {
|
||||
section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size);
|
||||
sections->insert(std::make_pair(
|
||||
".debug_info",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (section_data),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (section_data),
|
||||
section_size)));
|
||||
} else if (!strncmp(section_name, ".debug_str_offsets",
|
||||
strlen(".debug_str_offsets"))) {
|
||||
section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size);
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str_offsets",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (section_data),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (section_data),
|
||||
section_size)));
|
||||
}
|
||||
}
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (string_buffer_),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (string_buffer_),
|
||||
string_buffer_size_)));
|
||||
} else if (version_ == 2) {
|
||||
uint32_t index = LookupCUv2(dwo_id);
|
||||
|
@ -969,33 +969,33 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
|||
}
|
||||
for (unsigned int col = 0u; col < ncolumns_; ++col) {
|
||||
uint32_t section_id =
|
||||
byte_reader_.ReadFourBytes(reinterpret_cast<const uint8_t *>(id_row)
|
||||
byte_reader_.ReadFourBytes(reinterpret_cast<const uint8_t*>(id_row)
|
||||
+ col * sizeof(uint32_t));
|
||||
uint32_t offset = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(offset_row)
|
||||
reinterpret_cast<const uint8_t*>(offset_row)
|
||||
+ col * sizeof(uint32_t));
|
||||
uint32_t size = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(size_row) + col * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(size_row) + col * sizeof(uint32_t));
|
||||
if (section_id == DW_SECT_ABBREV) {
|
||||
sections->insert(std::make_pair(
|
||||
".debug_abbrev",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (abbrev_data_)
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (abbrev_data_)
|
||||
+ offset, size)));
|
||||
} else if (section_id == DW_SECT_INFO) {
|
||||
sections->insert(std::make_pair(
|
||||
".debug_info",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (info_data_)
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (info_data_)
|
||||
+ offset, size)));
|
||||
} else if (section_id == DW_SECT_STR_OFFSETS) {
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str_offsets",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (str_offsets_data_)
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (str_offsets_data_)
|
||||
+ offset, size)));
|
||||
}
|
||||
}
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (string_buffer_),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (string_buffer_),
|
||||
string_buffer_size_)));
|
||||
}
|
||||
}
|
||||
|
@ -1003,14 +1003,14 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
|||
int DwpReader::LookupCU(uint64_t dwo_id) {
|
||||
uint32_t slot = static_cast<uint32_t>(dwo_id) & (nslots_ - 1);
|
||||
uint64_t probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
if (probe != 0 && probe != dwo_id) {
|
||||
uint32_t secondary_hash =
|
||||
(static_cast<uint32_t>(dwo_id >> 32) & (nslots_ - 1)) | 1;
|
||||
do {
|
||||
slot = (slot + secondary_hash) & (nslots_ - 1);
|
||||
probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
} while (probe != 0 && probe != dwo_id);
|
||||
}
|
||||
if (probe == 0)
|
||||
|
@ -1021,24 +1021,24 @@ int DwpReader::LookupCU(uint64_t dwo_id) {
|
|||
uint32_t DwpReader::LookupCUv2(uint64_t dwo_id) {
|
||||
uint32_t slot = static_cast<uint32_t>(dwo_id) & (nslots_ - 1);
|
||||
uint64_t probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
uint32_t index = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(pindex_) + slot * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(pindex_) + slot * sizeof(uint32_t));
|
||||
if (index != 0 && probe != dwo_id) {
|
||||
uint32_t secondary_hash =
|
||||
(static_cast<uint32_t>(dwo_id >> 32) & (nslots_ - 1)) | 1;
|
||||
do {
|
||||
slot = (slot + secondary_hash) & (nslots_ - 1);
|
||||
probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
index = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(pindex_) + slot * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(pindex_) + slot * sizeof(uint32_t));
|
||||
} while (index != 0 && probe != dwo_id);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
LineInfo::LineInfo(const uint8_t *buffer, uint64_t buffer_length,
|
||||
LineInfo::LineInfo(const uint8_t* buffer, uint64_t buffer_length,
|
||||
ByteReader* reader, const uint8_t* string_buffer,
|
||||
size_t string_buffer_length,
|
||||
const uint8_t* line_string_buffer,
|
||||
|
@ -1185,7 +1185,7 @@ void LineInfo::ReadFileRow(const uint8_t** lineptr,
|
|||
// The header for a debug_line section is mildly complicated, because
|
||||
// the line info is very tightly encoded.
|
||||
void LineInfo::ReadHeader() {
|
||||
const uint8_t *lineptr = buffer_;
|
||||
const uint8_t* lineptr = buffer_;
|
||||
size_t initial_length_size;
|
||||
|
||||
const uint64_t initial_length
|
||||
|
@ -1331,12 +1331,12 @@ void LineInfo::ReadHeader() {
|
|||
/* static */
|
||||
bool LineInfo::ProcessOneOpcode(ByteReader* reader,
|
||||
LineInfoHandler* handler,
|
||||
const struct LineInfoHeader &header,
|
||||
const uint8_t *start,
|
||||
const struct LineInfoHeader& header,
|
||||
const uint8_t* start,
|
||||
struct LineStateMachine* lsm,
|
||||
size_t* len,
|
||||
uintptr pc,
|
||||
bool *lsm_passes_pc) {
|
||||
bool* lsm_passes_pc) {
|
||||
size_t oplen = 0;
|
||||
size_t templen;
|
||||
uint8_t opcode = reader->ReadOneByte(start);
|
||||
|
@ -1473,7 +1473,7 @@ bool LineInfo::ProcessOneOpcode(ByteReader* reader,
|
|||
}
|
||||
break;
|
||||
case DW_LNE_define_file: {
|
||||
const char *filename = reinterpret_cast<const char *>(start);
|
||||
const char* filename = reinterpret_cast<const char*>(start);
|
||||
|
||||
templen = strlen(filename) + 1;
|
||||
start += templen;
|
||||
|
@ -1520,7 +1520,7 @@ void LineInfo::ReadLines() {
|
|||
|
||||
// lengthstart is the place the length field is based on.
|
||||
// It is the point in the header after the initial length field
|
||||
const uint8_t *lengthstart = buffer_;
|
||||
const uint8_t* lengthstart = buffer_;
|
||||
|
||||
// In 64 bit dwarf, the initial length is 12 bytes, because of the
|
||||
// 0xffffffff at the start.
|
||||
|
@ -1529,7 +1529,7 @@ void LineInfo::ReadLines() {
|
|||
else
|
||||
lengthstart += 4;
|
||||
|
||||
const uint8_t *lineptr = after_header_;
|
||||
const uint8_t* lineptr = after_header_;
|
||||
lsm.Reset(header_.default_is_stmt);
|
||||
|
||||
// The LineInfoHandler interface expects each line's length along
|
||||
|
@ -1568,8 +1568,8 @@ void LineInfo::ReadLines() {
|
|||
after_header_ = lengthstart + header_.total_length;
|
||||
}
|
||||
|
||||
RangeListReader::RangeListReader(const uint8_t *buffer, uint64_t size,
|
||||
ByteReader *reader, RangeListHandler *handler)
|
||||
RangeListReader::RangeListReader(const uint8_t* buffer, uint64_t size,
|
||||
ByteReader* reader, RangeListHandler* handler)
|
||||
: buffer_(buffer), size_(size), reader_(reader), handler_(handler) { }
|
||||
|
||||
bool RangeListReader::ReadRangeList(uint64_t offset) {
|
||||
|
@ -1625,17 +1625,17 @@ class CallFrameInfo::Rule {
|
|||
// this rule. If REG is kCFARegister, then this rule describes how to compute
|
||||
// the canonical frame address. Return what the HANDLER member function
|
||||
// returned.
|
||||
virtual bool Handle(Handler *handler,
|
||||
virtual bool Handle(Handler* handler,
|
||||
uint64_t address, int reg) const = 0;
|
||||
|
||||
// Equality on rules. We use these to decide which rules we need
|
||||
// to report after a DW_CFA_restore_state instruction.
|
||||
virtual bool operator==(const Rule &rhs) const = 0;
|
||||
virtual bool operator==(const Rule& rhs) const = 0;
|
||||
|
||||
bool operator!=(const Rule &rhs) const { return ! (*this == rhs); }
|
||||
bool operator!=(const Rule& rhs) const { return ! (*this == rhs); }
|
||||
|
||||
// Return a pointer to a copy of this rule.
|
||||
virtual Rule *Copy() const = 0;
|
||||
virtual Rule* Copy() const = 0;
|
||||
|
||||
// If this is a base+offset rule, change its base register to REG.
|
||||
// Otherwise, do nothing. (Ugly, but required for DW_CFA_def_cfa_register.)
|
||||
|
@ -1651,16 +1651,16 @@ class CallFrameInfo::UndefinedRule: public CallFrameInfo::Rule {
|
|||
public:
|
||||
UndefinedRule() { }
|
||||
~UndefinedRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->UndefinedRule(address, reg);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const UndefinedRule *our_rhs = dynamic_cast<const UndefinedRule *>(&rhs);
|
||||
const UndefinedRule* our_rhs = dynamic_cast<const UndefinedRule*>(&rhs);
|
||||
return (our_rhs != NULL);
|
||||
}
|
||||
Rule *Copy() const { return new UndefinedRule(*this); }
|
||||
Rule* Copy() const { return new UndefinedRule(*this); }
|
||||
};
|
||||
|
||||
// Rule: the register's value is the same as that it had in the caller.
|
||||
|
@ -1668,16 +1668,16 @@ class CallFrameInfo::SameValueRule: public CallFrameInfo::Rule {
|
|||
public:
|
||||
SameValueRule() { }
|
||||
~SameValueRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->SameValueRule(address, reg);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const SameValueRule *our_rhs = dynamic_cast<const SameValueRule *>(&rhs);
|
||||
const SameValueRule* our_rhs = dynamic_cast<const SameValueRule*>(&rhs);
|
||||
return (our_rhs != NULL);
|
||||
}
|
||||
Rule *Copy() const { return new SameValueRule(*this); }
|
||||
Rule* Copy() const { return new SameValueRule(*this); }
|
||||
};
|
||||
|
||||
// Rule: the register is saved at OFFSET from BASE_REGISTER. BASE_REGISTER
|
||||
|
@ -1687,18 +1687,18 @@ class CallFrameInfo::OffsetRule: public CallFrameInfo::Rule {
|
|||
OffsetRule(int base_register, long offset)
|
||||
: base_register_(base_register), offset_(offset) { }
|
||||
~OffsetRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->OffsetRule(address, reg, base_register_, offset_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const OffsetRule *our_rhs = dynamic_cast<const OffsetRule *>(&rhs);
|
||||
const OffsetRule* our_rhs = dynamic_cast<const OffsetRule*>(&rhs);
|
||||
return (our_rhs &&
|
||||
base_register_ == our_rhs->base_register_ &&
|
||||
offset_ == our_rhs->offset_);
|
||||
}
|
||||
Rule *Copy() const { return new OffsetRule(*this); }
|
||||
Rule* Copy() const { return new OffsetRule(*this); }
|
||||
// We don't actually need SetBaseRegister or SetOffset here, since they
|
||||
// are only ever applied to CFA rules, for DW_CFA_def_cfa_offset, and it
|
||||
// doesn't make sense to use OffsetRule for computing the CFA: it
|
||||
|
@ -1716,18 +1716,18 @@ class CallFrameInfo::ValOffsetRule: public CallFrameInfo::Rule {
|
|||
ValOffsetRule(int base_register, long offset)
|
||||
: base_register_(base_register), offset_(offset) { }
|
||||
~ValOffsetRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->ValOffsetRule(address, reg, base_register_, offset_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const ValOffsetRule *our_rhs = dynamic_cast<const ValOffsetRule *>(&rhs);
|
||||
const ValOffsetRule* our_rhs = dynamic_cast<const ValOffsetRule*>(&rhs);
|
||||
return (our_rhs &&
|
||||
base_register_ == our_rhs->base_register_ &&
|
||||
offset_ == our_rhs->offset_);
|
||||
}
|
||||
Rule *Copy() const { return new ValOffsetRule(*this); }
|
||||
Rule* Copy() const { return new ValOffsetRule(*this); }
|
||||
void SetBaseRegister(unsigned reg) { base_register_ = reg; }
|
||||
void SetOffset(long long offset) { offset_ = offset; }
|
||||
private:
|
||||
|
@ -1741,16 +1741,16 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule {
|
|||
explicit RegisterRule(int register_number)
|
||||
: register_number_(register_number) { }
|
||||
~RegisterRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->RegisterRule(address, reg, register_number_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const RegisterRule *our_rhs = dynamic_cast<const RegisterRule *>(&rhs);
|
||||
const RegisterRule* our_rhs = dynamic_cast<const RegisterRule*>(&rhs);
|
||||
return (our_rhs && register_number_ == our_rhs->register_number_);
|
||||
}
|
||||
Rule *Copy() const { return new RegisterRule(*this); }
|
||||
Rule* Copy() const { return new RegisterRule(*this); }
|
||||
private:
|
||||
int register_number_;
|
||||
};
|
||||
|
@ -1758,19 +1758,19 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule {
|
|||
// Rule: EXPRESSION evaluates to the address at which the register is saved.
|
||||
class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule {
|
||||
public:
|
||||
explicit ExpressionRule(const string &expression)
|
||||
explicit ExpressionRule(const string& expression)
|
||||
: expression_(expression) { }
|
||||
~ExpressionRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->ExpressionRule(address, reg, expression_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const ExpressionRule *our_rhs = dynamic_cast<const ExpressionRule *>(&rhs);
|
||||
const ExpressionRule* our_rhs = dynamic_cast<const ExpressionRule*>(&rhs);
|
||||
return (our_rhs && expression_ == our_rhs->expression_);
|
||||
}
|
||||
Rule *Copy() const { return new ExpressionRule(*this); }
|
||||
Rule* Copy() const { return new ExpressionRule(*this); }
|
||||
private:
|
||||
string expression_;
|
||||
};
|
||||
|
@ -1778,20 +1778,20 @@ class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule {
|
|||
// Rule: EXPRESSION evaluates to the address at which the register is saved.
|
||||
class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule {
|
||||
public:
|
||||
explicit ValExpressionRule(const string &expression)
|
||||
explicit ValExpressionRule(const string& expression)
|
||||
: expression_(expression) { }
|
||||
~ValExpressionRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->ValExpressionRule(address, reg, expression_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const ValExpressionRule *our_rhs =
|
||||
dynamic_cast<const ValExpressionRule *>(&rhs);
|
||||
const ValExpressionRule* our_rhs =
|
||||
dynamic_cast<const ValExpressionRule*>(&rhs);
|
||||
return (our_rhs && expression_ == our_rhs->expression_);
|
||||
}
|
||||
Rule *Copy() const { return new ValExpressionRule(*this); }
|
||||
Rule* Copy() const { return new ValExpressionRule(*this); }
|
||||
private:
|
||||
string expression_;
|
||||
};
|
||||
|
@ -1800,51 +1800,51 @@ class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule {
|
|||
class CallFrameInfo::RuleMap {
|
||||
public:
|
||||
RuleMap() : cfa_rule_(NULL) { }
|
||||
RuleMap(const RuleMap &rhs) : cfa_rule_(NULL) { *this = rhs; }
|
||||
RuleMap(const RuleMap& rhs) : cfa_rule_(NULL) { *this = rhs; }
|
||||
~RuleMap() { Clear(); }
|
||||
|
||||
RuleMap &operator=(const RuleMap &rhs);
|
||||
RuleMap& operator=(const RuleMap& rhs);
|
||||
|
||||
// Set the rule for computing the CFA to RULE. Take ownership of RULE.
|
||||
void SetCFARule(Rule *rule) { delete cfa_rule_; cfa_rule_ = rule; }
|
||||
void SetCFARule(Rule* rule) { delete cfa_rule_; cfa_rule_ = rule; }
|
||||
|
||||
// Return the current CFA rule. Unlike RegisterRule, this RuleMap retains
|
||||
// ownership of the rule. We use this for DW_CFA_def_cfa_offset and
|
||||
// DW_CFA_def_cfa_register, and for detecting references to the CFA before
|
||||
// a rule for it has been established.
|
||||
Rule *CFARule() const { return cfa_rule_; }
|
||||
Rule* CFARule() const { return cfa_rule_; }
|
||||
|
||||
// Return the rule for REG, or NULL if there is none. The caller takes
|
||||
// ownership of the result.
|
||||
Rule *RegisterRule(int reg) const;
|
||||
Rule* RegisterRule(int reg) const;
|
||||
|
||||
// Set the rule for computing REG to RULE. Take ownership of RULE.
|
||||
void SetRegisterRule(int reg, Rule *rule);
|
||||
void SetRegisterRule(int reg, Rule* rule);
|
||||
|
||||
// Make all the appropriate calls to HANDLER as if we were changing from
|
||||
// this RuleMap to NEW_RULES at ADDRESS. We use this to implement
|
||||
// DW_CFA_restore_state, where lots of rules can change simultaneously.
|
||||
// Return true if all handlers returned true; otherwise, return false.
|
||||
bool HandleTransitionTo(Handler *handler, uint64_t address,
|
||||
const RuleMap &new_rules) const;
|
||||
bool HandleTransitionTo(Handler* handler, uint64_t address,
|
||||
const RuleMap& new_rules) const;
|
||||
|
||||
private:
|
||||
// A map from register numbers to Rules.
|
||||
typedef std::map<int, Rule *> RuleByNumber;
|
||||
typedef std::map<int, Rule*> RuleByNumber;
|
||||
|
||||
// Remove all register rules and clear cfa_rule_.
|
||||
void Clear();
|
||||
|
||||
// The rule for computing the canonical frame address. This RuleMap owns
|
||||
// this rule.
|
||||
Rule *cfa_rule_;
|
||||
Rule* cfa_rule_;
|
||||
|
||||
// A map from register numbers to postfix expressions to recover
|
||||
// their values. This RuleMap owns the Rules the map refers to.
|
||||
RuleByNumber registers_;
|
||||
};
|
||||
|
||||
CallFrameInfo::RuleMap &CallFrameInfo::RuleMap::operator=(const RuleMap &rhs) {
|
||||
CallFrameInfo::RuleMap& CallFrameInfo::RuleMap::operator=(const RuleMap& rhs) {
|
||||
Clear();
|
||||
// Since each map owns the rules it refers to, assignment must copy them.
|
||||
if (rhs.cfa_rule_) cfa_rule_ = rhs.cfa_rule_->Copy();
|
||||
|
@ -1854,7 +1854,7 @@ CallFrameInfo::RuleMap &CallFrameInfo::RuleMap::operator=(const RuleMap &rhs) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
CallFrameInfo::Rule *CallFrameInfo::RuleMap::RegisterRule(int reg) const {
|
||||
CallFrameInfo::Rule* CallFrameInfo::RuleMap::RegisterRule(int reg) const {
|
||||
assert(reg != Handler::kCFARegister);
|
||||
RuleByNumber::const_iterator it = registers_.find(reg);
|
||||
if (it != registers_.end())
|
||||
|
@ -1863,18 +1863,18 @@ CallFrameInfo::Rule *CallFrameInfo::RuleMap::RegisterRule(int reg) const {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void CallFrameInfo::RuleMap::SetRegisterRule(int reg, Rule *rule) {
|
||||
void CallFrameInfo::RuleMap::SetRegisterRule(int reg, Rule* rule) {
|
||||
assert(reg != Handler::kCFARegister);
|
||||
assert(rule);
|
||||
Rule **slot = ®isters_[reg];
|
||||
Rule** slot = ®isters_[reg];
|
||||
delete *slot;
|
||||
*slot = rule;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::RuleMap::HandleTransitionTo(
|
||||
Handler *handler,
|
||||
Handler* handler,
|
||||
uint64_t address,
|
||||
const RuleMap &new_rules) const {
|
||||
const RuleMap& new_rules) const {
|
||||
// Transition from cfa_rule_ to new_rules.cfa_rule_.
|
||||
if (cfa_rule_ && new_rules.cfa_rule_) {
|
||||
if (*cfa_rule_ != *new_rules.cfa_rule_ &&
|
||||
|
@ -1954,7 +1954,7 @@ class CallFrameInfo::State {
|
|||
public:
|
||||
// Create a call frame information interpreter state with the given
|
||||
// reporter, reader, handler, and initial call frame info address.
|
||||
State(ByteReader *reader, Handler *handler, Reporter *reporter,
|
||||
State(ByteReader* reader, Handler* handler, Reporter* reporter,
|
||||
uint64_t address)
|
||||
: reader_(reader), handler_(handler), reporter_(reporter),
|
||||
address_(address), entry_(NULL), cursor_(NULL) { }
|
||||
|
@ -1962,11 +1962,11 @@ class CallFrameInfo::State {
|
|||
// Interpret instructions from CIE, save the resulting rule set for
|
||||
// DW_CFA_restore instructions, and return true. On error, report
|
||||
// the problem to reporter_ and return false.
|
||||
bool InterpretCIE(const CIE &cie);
|
||||
bool InterpretCIE(const CIE& cie);
|
||||
|
||||
// Interpret instructions from FDE, and return true. On error,
|
||||
// report the problem to reporter_ and return false.
|
||||
bool InterpretFDE(const FDE &fde);
|
||||
bool InterpretFDE(const FDE& fde);
|
||||
|
||||
private:
|
||||
// The operands of a CFI instruction, for ParseOperands.
|
||||
|
@ -1996,7 +1996,7 @@ class CallFrameInfo::State {
|
|||
// '8' an eight-byte offset (OPERANDS->offset)
|
||||
// 'e' a DW_FORM_block holding a (OPERANDS->expression)
|
||||
// DWARF expression
|
||||
bool ParseOperands(const char *format, Operands *operands);
|
||||
bool ParseOperands(const char* format, Operands* operands);
|
||||
|
||||
// Interpret one CFI instruction from STATE's instruction stream, update
|
||||
// STATE, report any rule changes to handler_, and return true. On
|
||||
|
@ -2019,7 +2019,7 @@ class CallFrameInfo::State {
|
|||
|
||||
// Specify that REG can be recovered using RULE, and return true. On
|
||||
// failure, report and return false.
|
||||
bool DoRule(unsigned reg, Rule *rule);
|
||||
bool DoRule(unsigned reg, Rule* rule);
|
||||
|
||||
// Specify that REG can be found at OFFSET from the CFA, and return true.
|
||||
// On failure, report and return false. (Subroutine for DW_CFA_offset,
|
||||
|
@ -2047,23 +2047,23 @@ class CallFrameInfo::State {
|
|||
}
|
||||
|
||||
// For reading multi-byte values with the appropriate endianness.
|
||||
ByteReader *reader_;
|
||||
ByteReader* reader_;
|
||||
|
||||
// The handler to which we should report the data we find.
|
||||
Handler *handler_;
|
||||
Handler* handler_;
|
||||
|
||||
// For reporting problems in the info we're parsing.
|
||||
Reporter *reporter_;
|
||||
Reporter* reporter_;
|
||||
|
||||
// The code address to which the next instruction in the stream applies.
|
||||
uint64_t address_;
|
||||
|
||||
// The entry whose instructions we are currently processing. This is
|
||||
// first a CIE, and then an FDE.
|
||||
const Entry *entry_;
|
||||
const Entry* entry_;
|
||||
|
||||
// The next instruction to process.
|
||||
const uint8_t *cursor_;
|
||||
const uint8_t* cursor_;
|
||||
|
||||
// The current set of rules.
|
||||
RuleMap rules_;
|
||||
|
@ -2078,7 +2078,7 @@ class CallFrameInfo::State {
|
|||
std::stack<RuleMap> saved_rules_;
|
||||
};
|
||||
|
||||
bool CallFrameInfo::State::InterpretCIE(const CIE &cie) {
|
||||
bool CallFrameInfo::State::InterpretCIE(const CIE& cie) {
|
||||
entry_ = &cie;
|
||||
cursor_ = entry_->instructions;
|
||||
while (cursor_ < entry_->end)
|
||||
|
@ -2090,7 +2090,7 @@ bool CallFrameInfo::State::InterpretCIE(const CIE &cie) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::InterpretFDE(const FDE &fde) {
|
||||
bool CallFrameInfo::State::InterpretFDE(const FDE& fde) {
|
||||
entry_ = &fde;
|
||||
cursor_ = entry_->instructions;
|
||||
while (cursor_ < entry_->end)
|
||||
|
@ -2099,10 +2099,10 @@ bool CallFrameInfo::State::InterpretFDE(const FDE &fde) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::ParseOperands(const char *format,
|
||||
Operands *operands) {
|
||||
bool CallFrameInfo::State::ParseOperands(const char* format,
|
||||
Operands* operands) {
|
||||
size_t len;
|
||||
const char *operand;
|
||||
const char* operand;
|
||||
|
||||
for (operand = format; *operand; operand++) {
|
||||
size_t bytes_left = entry_->end - cursor_;
|
||||
|
@ -2161,7 +2161,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format,
|
|||
if (len > bytes_left || expression_length > bytes_left - len)
|
||||
return ReportIncomplete();
|
||||
cursor_ += len;
|
||||
operands->expression = string(reinterpret_cast<const char *>(cursor_),
|
||||
operands->expression = string(reinterpret_cast<const char*>(cursor_),
|
||||
expression_length);
|
||||
cursor_ += expression_length;
|
||||
break;
|
||||
|
@ -2176,7 +2176,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format,
|
|||
}
|
||||
|
||||
bool CallFrameInfo::State::DoInstruction() {
|
||||
CIE *cie = entry_->cie;
|
||||
CIE* cie = entry_->cie;
|
||||
Operands ops;
|
||||
|
||||
// Our entry's kind should have been set by now.
|
||||
|
@ -2266,7 +2266,7 @@ bool CallFrameInfo::State::DoInstruction() {
|
|||
// Change the base register used to compute the CFA.
|
||||
case DW_CFA_def_cfa_register: {
|
||||
if (!ParseOperands("r", &ops)) return false;
|
||||
Rule *cfa_rule = rules_.CFARule();
|
||||
Rule* cfa_rule = rules_.CFARule();
|
||||
if (!cfa_rule) {
|
||||
if (!DoDefCFA(ops.register_number, ops.offset)) {
|
||||
reporter_->NoCFARule(entry_->offset, entry_->kind, CursorOffset());
|
||||
|
@ -2299,7 +2299,7 @@ bool CallFrameInfo::State::DoInstruction() {
|
|||
case DW_CFA_def_cfa_expression: {
|
||||
if (!ParseOperands("e", &ops))
|
||||
return false;
|
||||
Rule *rule = new ValExpressionRule(ops.expression);
|
||||
Rule* rule = new ValExpressionRule(ops.expression);
|
||||
rules_.SetCFARule(rule);
|
||||
if (!rule->Handle(handler_, address_,
|
||||
Handler::kCFARegister))
|
||||
|
@ -2406,7 +2406,7 @@ bool CallFrameInfo::State::DoInstruction() {
|
|||
CursorOffset());
|
||||
return false;
|
||||
}
|
||||
const RuleMap &new_rules = saved_rules_.top();
|
||||
const RuleMap& new_rules = saved_rules_.top();
|
||||
if (rules_.CFARule() && !new_rules.CFARule()) {
|
||||
reporter_->ClearingCFARule(entry_->offset, entry_->kind,
|
||||
CursorOffset());
|
||||
|
@ -2458,14 +2458,14 @@ bool CallFrameInfo::State::DoInstruction() {
|
|||
}
|
||||
|
||||
bool CallFrameInfo::State::DoDefCFA(unsigned base_register, long offset) {
|
||||
Rule *rule = new ValOffsetRule(base_register, offset);
|
||||
Rule* rule = new ValOffsetRule(base_register, offset);
|
||||
rules_.SetCFARule(rule);
|
||||
return rule->Handle(handler_, address_,
|
||||
Handler::kCFARegister);
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::DoDefCFAOffset(long offset) {
|
||||
Rule *cfa_rule = rules_.CFARule();
|
||||
Rule* cfa_rule = rules_.CFARule();
|
||||
if (!cfa_rule) {
|
||||
reporter_->NoCFARule(entry_->offset, entry_->kind, CursorOffset());
|
||||
return false;
|
||||
|
@ -2475,7 +2475,7 @@ bool CallFrameInfo::State::DoDefCFAOffset(long offset) {
|
|||
Handler::kCFARegister);
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::DoRule(unsigned reg, Rule *rule) {
|
||||
bool CallFrameInfo::State::DoRule(unsigned reg, Rule* rule) {
|
||||
rules_.SetRegisterRule(reg, rule);
|
||||
return rule->Handle(handler_, address_, reg);
|
||||
}
|
||||
|
@ -2504,7 +2504,7 @@ bool CallFrameInfo::State::DoRestore(unsigned reg) {
|
|||
reporter_->RestoreInCIE(entry_->offset, CursorOffset());
|
||||
return false;
|
||||
}
|
||||
Rule *rule = cie_rules_.RegisterRule(reg);
|
||||
Rule* rule = cie_rules_.RegisterRule(reg);
|
||||
if (!rule) {
|
||||
// This isn't really the right thing to do, but since CFI generally
|
||||
// only mentions callee-saves registers, and GCC's convention for
|
||||
|
@ -2515,8 +2515,8 @@ bool CallFrameInfo::State::DoRestore(unsigned reg) {
|
|||
return DoRule(reg, rule);
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReadEntryPrologue(const uint8_t *cursor, Entry *entry) {
|
||||
const uint8_t *buffer_end = buffer_ + buffer_length_;
|
||||
bool CallFrameInfo::ReadEntryPrologue(const uint8_t* cursor, Entry* entry) {
|
||||
const uint8_t* buffer_end = buffer_ + buffer_length_;
|
||||
|
||||
// Initialize enough of ENTRY for use in error reporting.
|
||||
entry->offset = cursor - buffer_;
|
||||
|
@ -2593,8 +2593,8 @@ bool CallFrameInfo::ReadEntryPrologue(const uint8_t *cursor, Entry *entry) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
||||
const uint8_t *cursor = cie->fields;
|
||||
bool CallFrameInfo::ReadCIEFields(CIE* cie) {
|
||||
const uint8_t* cursor = cie->fields;
|
||||
size_t len;
|
||||
|
||||
assert(cie->kind == kCIE);
|
||||
|
@ -2625,13 +2625,13 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
|||
return false;
|
||||
}
|
||||
|
||||
const uint8_t *augmentation_start = cursor;
|
||||
const uint8_t *augmentation_end =
|
||||
reinterpret_cast<const uint8_t *>(memchr(augmentation_start, '\0',
|
||||
const uint8_t* augmentation_start = cursor;
|
||||
const uint8_t* augmentation_end =
|
||||
reinterpret_cast<const uint8_t*>(memchr(augmentation_start, '\0',
|
||||
cie->end - augmentation_start));
|
||||
if (! augmentation_end) return ReportIncomplete(cie);
|
||||
cursor = augmentation_end;
|
||||
cie->augmentation = string(reinterpret_cast<const char *>(augmentation_start),
|
||||
cie->augmentation = string(reinterpret_cast<const char*>(augmentation_start),
|
||||
cursor - augmentation_start);
|
||||
// Skip the terminating '\0'.
|
||||
cursor++;
|
||||
|
@ -2692,9 +2692,9 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
|||
if (size_t(cie->end - cursor) < len + data_size)
|
||||
return ReportIncomplete(cie);
|
||||
cursor += len;
|
||||
const uint8_t *data = cursor;
|
||||
const uint8_t* data = cursor;
|
||||
cursor += data_size;
|
||||
const uint8_t *data_end = cursor;
|
||||
const uint8_t* data_end = cursor;
|
||||
|
||||
cie->has_z_lsda = false;
|
||||
cie->has_z_personality = false;
|
||||
|
@ -2785,8 +2785,8 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReadFDEFields(FDE *fde) {
|
||||
const uint8_t *cursor = fde->fields;
|
||||
bool CallFrameInfo::ReadFDEFields(FDE* fde) {
|
||||
const uint8_t* cursor = fde->fields;
|
||||
size_t size;
|
||||
|
||||
fde->address = reader_->ReadEncodedPointer(cursor, fde->cie->pointer_encoding,
|
||||
|
@ -2852,10 +2852,10 @@ bool CallFrameInfo::ReadFDEFields(FDE *fde) {
|
|||
}
|
||||
|
||||
bool CallFrameInfo::Start() {
|
||||
const uint8_t *buffer_end = buffer_ + buffer_length_;
|
||||
const uint8_t *cursor;
|
||||
const uint8_t* buffer_end = buffer_ + buffer_length_;
|
||||
const uint8_t* cursor;
|
||||
bool all_ok = true;
|
||||
const uint8_t *entry_end;
|
||||
const uint8_t* entry_end;
|
||||
bool ok;
|
||||
|
||||
// Traverse all the entries in buffer_, skipping CIEs and offering
|
||||
|
@ -2986,7 +2986,7 @@ bool CallFrameInfo::Start() {
|
|||
return all_ok;
|
||||
}
|
||||
|
||||
const char *CallFrameInfo::KindName(EntryKind kind) {
|
||||
const char* CallFrameInfo::KindName(EntryKind kind) {
|
||||
if (kind == CallFrameInfo::kUnknown)
|
||||
return "entry";
|
||||
else if (kind == CallFrameInfo::kCIE)
|
||||
|
@ -2999,7 +2999,7 @@ const char *CallFrameInfo::KindName(EntryKind kind) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReportIncomplete(Entry *entry) {
|
||||
bool CallFrameInfo::ReportIncomplete(Entry* entry) {
|
||||
reporter_->Incomplete(entry->offset, entry->kind);
|
||||
return false;
|
||||
}
|
||||
|
@ -3058,7 +3058,7 @@ void CallFrameInfo::Reporter::UnrecognizedVersion(uint64_t offset, int version)
|
|||
}
|
||||
|
||||
void CallFrameInfo::Reporter::UnrecognizedAugmentation(uint64_t offset,
|
||||
const string &aug) {
|
||||
const string& aug) {
|
||||
fprintf(stderr,
|
||||
"%s: CFI frame description entry at offset 0x%" PRIx64 " in '%s':"
|
||||
" CIE specifies unrecognized augmentation: '%s'\n",
|
||||
|
|
|
@ -64,13 +64,13 @@ class DwpReader;
|
|||
|
||||
// This maps from a string naming a section to a pair containing a
|
||||
// the data for the section, and the size of the section.
|
||||
typedef std::map<string, std::pair<const uint8_t *, uint64_t> > SectionMap;
|
||||
typedef std::map<string, std::pair<const uint8_t*, uint64_t> > SectionMap;
|
||||
|
||||
// Abstract away the difference between elf and mach-o section names.
|
||||
// Elf-names use ".section_name, mach-o uses "__section_name". Pass "name" in
|
||||
// the elf form, ".section_name".
|
||||
const SectionMap::const_iterator GetSectionByName(const SectionMap&
|
||||
sections, const char *name);
|
||||
sections, const char* name);
|
||||
|
||||
typedef std::list<std::pair<enum DwarfAttribute, enum DwarfForm> >
|
||||
AttributeList;
|
||||
|
@ -88,7 +88,7 @@ struct LineInfoHeader {
|
|||
uint8_t opcode_base;
|
||||
// Use a pointer so that signalsafe_addr2line is able to use this structure
|
||||
// without heap allocation problem.
|
||||
std::vector<unsigned char> *std_opcode_lengths;
|
||||
std::vector<unsigned char>* std_opcode_lengths;
|
||||
};
|
||||
|
||||
class LineInfo {
|
||||
|
@ -125,12 +125,12 @@ class LineInfo {
|
|||
// lsm's old address < PC <= lsm's new address
|
||||
static bool ProcessOneOpcode(ByteReader* reader,
|
||||
LineInfoHandler* handler,
|
||||
const struct LineInfoHeader &header,
|
||||
const uint8_t *start,
|
||||
const struct LineInfoHeader& header,
|
||||
const uint8_t* start,
|
||||
struct LineStateMachine* lsm,
|
||||
size_t* len,
|
||||
uintptr pc,
|
||||
bool *lsm_passes_pc);
|
||||
bool* lsm_passes_pc);
|
||||
|
||||
private:
|
||||
// Reads the DWARF2/3 header for this line info.
|
||||
|
@ -171,7 +171,7 @@ class LineInfo {
|
|||
// buffer is the buffer for our line info, starting at exactly where
|
||||
// the line info to read is. after_header is the place right after
|
||||
// the end of the line information header.
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
#ifndef NDEBUG
|
||||
uint64_t buffer_length_;
|
||||
#endif
|
||||
|
@ -182,7 +182,7 @@ class LineInfo {
|
|||
const uint8_t* line_string_buffer_;
|
||||
uint64_t line_string_buffer_length_;
|
||||
|
||||
const uint8_t *after_header_;
|
||||
const uint8_t* after_header_;
|
||||
};
|
||||
|
||||
// This class is the main interface between the line info reader and
|
||||
|
@ -239,16 +239,16 @@ class RangeListHandler {
|
|||
|
||||
class RangeListReader {
|
||||
public:
|
||||
RangeListReader(const uint8_t *buffer, uint64_t size, ByteReader *reader,
|
||||
RangeListHandler *handler);
|
||||
RangeListReader(const uint8_t* buffer, uint64_t size, ByteReader* reader,
|
||||
RangeListHandler* handler);
|
||||
|
||||
bool ReadRangeList(uint64_t offset);
|
||||
|
||||
private:
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
uint64_t size_;
|
||||
ByteReader* reader_;
|
||||
RangeListHandler *handler_;
|
||||
RangeListHandler* handler_;
|
||||
};
|
||||
|
||||
// This class is the main interface between the reader and the
|
||||
|
@ -322,7 +322,7 @@ class Dwarf2Handler {
|
|||
virtual void ProcessAttributeBuffer(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len) { }
|
||||
|
||||
// Called when we have an attribute with string data to give to our handler.
|
||||
|
@ -461,14 +461,14 @@ class CompilationUnit {
|
|||
|
||||
// Processes a single DIE for this compilation unit and return a new
|
||||
// pointer just past the end of it
|
||||
const uint8_t *ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t *start,
|
||||
const uint8_t* ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t* start,
|
||||
const Abbrev& abbrev);
|
||||
|
||||
// Processes a single attribute and return a new pointer just past the
|
||||
// end of it
|
||||
const uint8_t *ProcessAttribute(uint64_t dieoffset,
|
||||
const uint8_t *start,
|
||||
const uint8_t* ProcessAttribute(uint64_t dieoffset,
|
||||
const uint8_t* start,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form);
|
||||
|
||||
|
@ -564,11 +564,11 @@ class CompilationUnit {
|
|||
|
||||
// Skips the die with attributes specified in ABBREV starting at
|
||||
// START, and return the new place to position the stream to.
|
||||
const uint8_t *SkipDIE(const uint8_t *start, const Abbrev& abbrev);
|
||||
const uint8_t* SkipDIE(const uint8_t* start, const Abbrev& abbrev);
|
||||
|
||||
// Skips the attribute starting at START, with FORM, and return the
|
||||
// new place to position the stream to.
|
||||
const uint8_t *SkipAttribute(const uint8_t *start, enum DwarfForm form);
|
||||
const uint8_t* SkipAttribute(const uint8_t* start, enum DwarfForm form);
|
||||
|
||||
// Process the actual debug information in a split DWARF file.
|
||||
void ProcessSplitDwarf();
|
||||
|
@ -587,9 +587,9 @@ class CompilationUnit {
|
|||
// buffer is the buffer for our CU, starting at .debug_info + offset
|
||||
// passed in from constructor.
|
||||
// after_header points to right after the compilation unit header.
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
uint64_t buffer_length_;
|
||||
const uint8_t *after_header_;
|
||||
const uint8_t* after_header_;
|
||||
|
||||
// The associated ByteReader that handles endianness issues for us
|
||||
ByteReader* reader_;
|
||||
|
@ -608,7 +608,7 @@ class CompilationUnit {
|
|||
// String section buffer and length, if we have a string section.
|
||||
// This is here to avoid doing a section lookup for strings in
|
||||
// ProcessAttribute, which is in the hot path for DWARF2 reading.
|
||||
const uint8_t *string_buffer_;
|
||||
const uint8_t* string_buffer_;
|
||||
uint64_t string_buffer_length_;
|
||||
|
||||
// Similarly for .debug_line_string.
|
||||
|
@ -984,8 +984,8 @@ class CallFrameInfo {
|
|||
// The mechanics of C++ exception handling, personality routines,
|
||||
// and language-specific data areas are described here, rather nicely:
|
||||
// http://www.codesourcery.com/public/cxx-abi/abi-eh.html
|
||||
CallFrameInfo(const uint8_t *buffer, size_t buffer_length,
|
||||
ByteReader *reader, Handler *handler, Reporter *reporter,
|
||||
CallFrameInfo(const uint8_t* buffer, size_t buffer_length,
|
||||
ByteReader* reader, Handler* handler, Reporter* reporter,
|
||||
bool eh_frame = false)
|
||||
: buffer_(buffer), buffer_length_(buffer_length),
|
||||
reader_(reader), handler_(handler), reporter_(reporter),
|
||||
|
@ -999,7 +999,7 @@ class CallFrameInfo {
|
|||
bool Start();
|
||||
|
||||
// Return the textual name of KIND. For error reporting.
|
||||
static const char *KindName(EntryKind kind);
|
||||
static const char* KindName(EntryKind kind);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -1012,7 +1012,7 @@ class CallFrameInfo {
|
|||
size_t offset;
|
||||
|
||||
// The start of this entry in the buffer.
|
||||
const uint8_t *start;
|
||||
const uint8_t* start;
|
||||
|
||||
// Which kind of entry this is.
|
||||
//
|
||||
|
@ -1023,16 +1023,16 @@ class CallFrameInfo {
|
|||
|
||||
// The end of this entry's common prologue (initial length and id), and
|
||||
// the start of this entry's kind-specific fields.
|
||||
const uint8_t *fields;
|
||||
const uint8_t* fields;
|
||||
|
||||
// The start of this entry's instructions.
|
||||
const uint8_t *instructions;
|
||||
const uint8_t* instructions;
|
||||
|
||||
// The address past the entry's last byte in the buffer. (Note that
|
||||
// since offset points to the entry's initial length field, and the
|
||||
// length field is the number of bytes after that field, this is not
|
||||
// simply buffer_ + offset + length.)
|
||||
const uint8_t *end;
|
||||
const uint8_t* end;
|
||||
|
||||
// For both DWARF CFI and .eh_frame sections, this is the CIE id in a
|
||||
// CIE, and the offset of the associated CIE in an FDE.
|
||||
|
@ -1040,7 +1040,7 @@ class CallFrameInfo {
|
|||
|
||||
// The CIE that applies to this entry, if we've parsed it. If this is a
|
||||
// CIE, then this field points to this structure.
|
||||
CIE *cie;
|
||||
CIE* cie;
|
||||
};
|
||||
|
||||
// A common information entry (CIE).
|
||||
|
@ -1114,14 +1114,14 @@ class CallFrameInfo {
|
|||
// true. On failure, report the problem, and return false. Even if we
|
||||
// return false, set ENTRY->end to the first byte after the entry if we
|
||||
// were able to figure that out, or NULL if we weren't.
|
||||
bool ReadEntryPrologue(const uint8_t *cursor, Entry *entry);
|
||||
bool ReadEntryPrologue(const uint8_t* cursor, Entry* entry);
|
||||
|
||||
// Parse the fields of a CIE after the entry prologue, including any 'z'
|
||||
// augmentation data. Assume that the 'Entry' fields of CIE are
|
||||
// populated; use CIE->fields and CIE->end as the start and limit for
|
||||
// parsing. On success, populate the rest of *CIE, and return true; on
|
||||
// failure, report the problem and return false.
|
||||
bool ReadCIEFields(CIE *cie);
|
||||
bool ReadCIEFields(CIE* cie);
|
||||
|
||||
// Parse the fields of an FDE after the entry prologue, including any 'z'
|
||||
// augmentation data. Assume that the 'Entry' fields of *FDE are
|
||||
|
@ -1129,12 +1129,12 @@ class CallFrameInfo {
|
|||
// parsing. Assume that FDE->cie is fully initialized. On success,
|
||||
// populate the rest of *FDE, and return true; on failure, report the
|
||||
// problem and return false.
|
||||
bool ReadFDEFields(FDE *fde);
|
||||
bool ReadFDEFields(FDE* fde);
|
||||
|
||||
// Report that ENTRY is incomplete, and return false. This is just a
|
||||
// trivial wrapper for invoking reporter_->Incomplete; it provides a
|
||||
// little brevity.
|
||||
bool ReportIncomplete(Entry *entry);
|
||||
bool ReportIncomplete(Entry* entry);
|
||||
|
||||
// Return true if ENCODING has the DW_EH_PE_indirect bit set.
|
||||
static bool IsIndirectEncoding(DwarfPointerEncoding encoding) {
|
||||
|
@ -1142,17 +1142,17 @@ class CallFrameInfo {
|
|||
}
|
||||
|
||||
// The contents of the DWARF .debug_info section we're parsing.
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
size_t buffer_length_;
|
||||
|
||||
// For reading multi-byte values with the appropriate endianness.
|
||||
ByteReader *reader_;
|
||||
ByteReader* reader_;
|
||||
|
||||
// The handler to which we should report the data we find.
|
||||
Handler *handler_;
|
||||
Handler* handler_;
|
||||
|
||||
// For reporting problems in the info we're parsing.
|
||||
Reporter *reporter_;
|
||||
Reporter* reporter_;
|
||||
|
||||
// True if we are processing .eh_frame-format data.
|
||||
bool eh_frame_;
|
||||
|
@ -1185,7 +1185,7 @@ class CallFrameInfo::Handler {
|
|||
// process a given FDE, the parser reiterates the appropriate CIE's
|
||||
// contents at the beginning of the FDE's rules.
|
||||
virtual bool Entry(size_t offset, uint64_t address, uint64_t length,
|
||||
uint8_t version, const string &augmentation,
|
||||
uint8_t version, const string& augmentation,
|
||||
unsigned return_address) = 0;
|
||||
|
||||
// When the Entry function returns true, the parser calls these
|
||||
|
@ -1234,13 +1234,13 @@ class CallFrameInfo::Handler {
|
|||
// At ADDRESS, the DWARF expression EXPRESSION yields the address at
|
||||
// which REG was saved.
|
||||
virtual bool ExpressionRule(uint64_t address, int reg,
|
||||
const string &expression) = 0;
|
||||
const string& expression) = 0;
|
||||
|
||||
// At ADDRESS, the DWARF expression EXPRESSION yields the caller's
|
||||
// value for REG. (This rule doesn't provide an address at which the
|
||||
// register's value is saved.)
|
||||
virtual bool ValExpressionRule(uint64_t address, int reg,
|
||||
const string &expression) = 0;
|
||||
const string& expression) = 0;
|
||||
|
||||
// Indicate that the rules for the address range reported by the
|
||||
// last call to Entry are complete. End should return true if
|
||||
|
@ -1317,8 +1317,8 @@ class CallFrameInfo::Reporter {
|
|||
// in a Mach-O section named __debug_frame. If we support
|
||||
// Linux-style exception handling data, we could be reading an
|
||||
// .eh_frame section.
|
||||
Reporter(const string &filename,
|
||||
const string §ion = ".debug_frame")
|
||||
Reporter(const string& filename,
|
||||
const string& section = ".debug_frame")
|
||||
: filename_(filename), section_(section) { }
|
||||
virtual ~Reporter() { }
|
||||
|
||||
|
@ -1358,7 +1358,7 @@ class CallFrameInfo::Reporter {
|
|||
// which we don't recognize. We cannot parse DWARF CFI if it uses
|
||||
// augmentations we don't recognize.
|
||||
virtual void UnrecognizedAugmentation(uint64_t offset,
|
||||
const string &augmentation);
|
||||
const string& augmentation);
|
||||
|
||||
// The pointer encoding ENCODING, specified by the CIE at OFFSET, is not
|
||||
// a valid encoding.
|
||||
|
|
|
@ -87,7 +87,7 @@ using testing::_;
|
|||
|
||||
#ifdef WRITE_ELF
|
||||
void WriteELFFrameSection(const char *filename, const char *section_name,
|
||||
const CFISection §ion);
|
||||
const CFISection& section);
|
||||
#define PERHAPS_WRITE_DEBUG_FRAME_FILE(name, section) \
|
||||
WriteELFFrameSection("cfitest-" name, ".debug_frame", section);
|
||||
#define PERHAPS_WRITE_EH_FRAME_FILE(name, section) \
|
||||
|
@ -100,7 +100,7 @@ void WriteELFFrameSection(const char *filename, const char *section_name,
|
|||
class MockCallFrameInfoHandler: public CallFrameInfo::Handler {
|
||||
public:
|
||||
MOCK_METHOD6(Entry, bool(size_t offset, uint64_t address, uint64_t length,
|
||||
uint8_t version, const string &augmentation,
|
||||
uint8_t version, const string& augmentation,
|
||||
unsigned return_address));
|
||||
MOCK_METHOD2(UndefinedRule, bool(uint64_t address, int reg));
|
||||
MOCK_METHOD2(SameValueRule, bool(uint64_t address, int reg));
|
||||
|
@ -110,9 +110,9 @@ class MockCallFrameInfoHandler: public CallFrameInfo::Handler {
|
|||
long offset));
|
||||
MOCK_METHOD3(RegisterRule, bool(uint64_t address, int reg, int base_register));
|
||||
MOCK_METHOD3(ExpressionRule, bool(uint64_t address, int reg,
|
||||
const string &expression));
|
||||
const string& expression));
|
||||
MOCK_METHOD3(ValExpressionRule, bool(uint64_t address, int reg,
|
||||
const string &expression));
|
||||
const string& expression));
|
||||
MOCK_METHOD0(End, bool());
|
||||
MOCK_METHOD2(PersonalityRoutine, bool(uint64_t address, bool indirect));
|
||||
MOCK_METHOD2(LanguageSpecificDataArea, bool(uint64_t address, bool indirect));
|
||||
|
@ -129,7 +129,7 @@ class MockCallFrameErrorReporter: public CallFrameInfo::Reporter {
|
|||
MOCK_METHOD2(UnexpectedAddressSize, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(UnexpectedSegmentSize, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(UnrecognizedVersion, void(uint64_t, int version));
|
||||
MOCK_METHOD2(UnrecognizedAugmentation, void(uint64_t, const string &));
|
||||
MOCK_METHOD2(UnrecognizedAugmentation, void(uint64_t, const string&));
|
||||
MOCK_METHOD2(InvalidPointerEncoding, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(UnusablePointerEncoding, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(RestoreInCIE, void(uint64_t, uint64_t));
|
||||
|
@ -218,7 +218,7 @@ TEST_F(CFI, IncompleteLength32) {
|
|||
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size() - 2,
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -244,7 +244,7 @@ TEST_F(CFI, IncompleteLength64) {
|
|||
|
||||
ByteReader byte_reader(ENDIANNESS_LITTLE);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size() - 4,
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -269,7 +269,7 @@ TEST_F(CFI, IncompleteId32) {
|
|||
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -296,7 +296,7 @@ TEST_F(CFI, BadId32) {
|
|||
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -318,7 +318,7 @@ TEST_F(CFI, SingleCIE) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_LITTLE);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -349,7 +349,7 @@ TEST_F(CFI, OneFDE) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -393,7 +393,7 @@ TEST_F(CFI, TwoFDEsOneCIE) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -443,7 +443,7 @@ TEST_F(CFI, TwoFDEsTwoCIEs) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_LITTLE);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -488,7 +488,7 @@ TEST_F(CFI, BadVersion) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -533,7 +533,7 @@ TEST_F(CFI, BadAugmentation) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -568,7 +568,7 @@ TEST_F(CFI, CIEVersion1ReturnColumn) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -603,7 +603,7 @@ TEST_F(CFI, CIEVersion3ReturnColumn) {
|
|||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -633,7 +633,7 @@ TEST_F(CFI, CIEVersion4AdditionalFields) {
|
|||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -663,7 +663,7 @@ TEST_F(CFI, CIEVersion4AdditionalFields32BitAddress) {
|
|||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
|
@ -690,7 +690,7 @@ TEST_F(CFI, CIEVersion4AdditionalFieldsUnexpectedAddressSize) {
|
|||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -715,7 +715,7 @@ TEST_F(CFI, CIEVersion4AdditionalFieldsUnexpectedSegmentSize) {
|
|||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
|
@ -797,7 +797,7 @@ struct CFIInsnFixture: public CFIFixture {
|
|||
}
|
||||
ByteReader byte_reader(endianness);
|
||||
byte_reader.SetAddressSize(section->AddressSize());
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
if (succeeds)
|
||||
|
@ -2120,10 +2120,10 @@ struct EHFrameFixture: public CFIInsnFixture {
|
|||
ByteReader byte_reader(endianness);
|
||||
byte_reader.SetAddressSize(section->AddressSize());
|
||||
byte_reader.SetCFIDataBase(encoded_pointer_bases.cfi,
|
||||
reinterpret_cast<const uint8_t *>(contents.data()));
|
||||
reinterpret_cast<const uint8_t*>(contents.data()));
|
||||
byte_reader.SetTextBase(encoded_pointer_bases.text);
|
||||
byte_reader.SetDataBase(encoded_pointer_bases.data);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter, true);
|
||||
if (succeeds)
|
||||
|
@ -2468,7 +2468,7 @@ struct ELFSectionHeader {
|
|||
uint64_t entry_size;
|
||||
};
|
||||
|
||||
void AppendSectionHeader(CFISection *table, const ELFSectionHeader &header) {
|
||||
void AppendSectionHeader(CFISection* table, const ELFSectionHeader& header) {
|
||||
(*table)
|
||||
.D32(header.name) // name, index in string tbl
|
||||
.D32(header.type) // type
|
||||
|
@ -2483,7 +2483,7 @@ void AppendSectionHeader(CFISection *table, const ELFSectionHeader &header) {
|
|||
}
|
||||
|
||||
void WriteELFFrameSection(const char *filename, const char *cfi_name,
|
||||
const CFISection &cfi) {
|
||||
const CFISection& cfi) {
|
||||
int elf_class = cfi.AddressSize() == 4 ? ELFCLASS32 : ELFCLASS64;
|
||||
int elf_data = (cfi.endianness() == kBigEndian
|
||||
? ELFDATA2MSB : ELFDATA2LSB);
|
||||
|
|
|
@ -93,7 +93,7 @@ class MockDwarf2Handler: public Dwarf2Handler {
|
|||
MOCK_METHOD5(ProcessAttributeBuffer, void(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len));
|
||||
MOCK_METHOD4(ProcessAttributeString, void(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
|
@ -128,17 +128,17 @@ struct DIEFixture {
|
|||
// to |info|, and whose .debug_abbrev section refers to |abbrevs|. This
|
||||
// function returns a reference to the same SectionMap each time; new
|
||||
// calls wipe out maps established by earlier calls.
|
||||
const SectionMap &MakeSectionMap() {
|
||||
const SectionMap& MakeSectionMap() {
|
||||
// Copy the sections' contents into strings that will live as long as
|
||||
// the map itself.
|
||||
assert(info.GetContents(&info_contents));
|
||||
assert(abbrevs.GetContents(&abbrevs_contents));
|
||||
section_map.clear();
|
||||
section_map[".debug_info"].first
|
||||
= reinterpret_cast<const uint8_t *>(info_contents.data());
|
||||
= reinterpret_cast<const uint8_t*>(info_contents.data());
|
||||
section_map[".debug_info"].second = info_contents.size();
|
||||
section_map[".debug_abbrev"].first
|
||||
= reinterpret_cast<const uint8_t *>(abbrevs_contents.data());
|
||||
= reinterpret_cast<const uint8_t*>(abbrevs_contents.data());
|
||||
section_map[".debug_abbrev"].second = abbrevs_contents.size();
|
||||
return section_map;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ struct DwarfFormsFixture: public DIEFixture {
|
|||
// childless DIE of the given tag, with one attribute of the given name
|
||||
// and form. The 'info' fixture member is left just after the abbrev
|
||||
// code, waiting for the attribute value to be appended.
|
||||
void StartSingleAttributeDIE(const DwarfHeaderParams ¶ms,
|
||||
void StartSingleAttributeDIE(const DwarfHeaderParams& params,
|
||||
DwarfTag tag, DwarfAttribute name,
|
||||
DwarfForm form) {
|
||||
// Create the abbreviation table.
|
||||
|
@ -260,7 +260,7 @@ struct DwarfFormsFixture: public DIEFixture {
|
|||
// Set up handler to expect a compilation unit matching |params|,
|
||||
// containing one childless DIE of the given tag, in the sequence s. Stop
|
||||
// just before the expectations.
|
||||
void ExpectBeginCompilationUnit(const DwarfHeaderParams ¶ms,
|
||||
void ExpectBeginCompilationUnit(const DwarfHeaderParams& params,
|
||||
DwarfTag tag, uint64_t offset=0) {
|
||||
EXPECT_CALL(handler,
|
||||
StartCompilationUnit(offset, params.address_size,
|
||||
|
@ -279,7 +279,7 @@ struct DwarfFormsFixture: public DIEFixture {
|
|||
.WillOnce(Return());
|
||||
}
|
||||
|
||||
void ParseCompilationUnit(const DwarfHeaderParams ¶ms,
|
||||
void ParseCompilationUnit(const DwarfHeaderParams& params,
|
||||
uint64_t offset=0) {
|
||||
ByteReader byte_reader(params.endianness == kLittleEndian ?
|
||||
ENDIANNESS_LITTLE : ENDIANNESS_BIG);
|
||||
|
|
|
@ -70,7 +70,7 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section {
|
|||
|
||||
// Append a DWARF compilation unit header to the section, with the given
|
||||
// DWARF version, abbrev table offset, and address size.
|
||||
TestCompilationUnit &Header(int version, const Label &abbrev_offset,
|
||||
TestCompilationUnit& Header(int version, const Label& abbrev_offset,
|
||||
size_t address_size) {
|
||||
if (format_size_ == 4) {
|
||||
D32(length_);
|
||||
|
@ -92,7 +92,7 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section {
|
|||
}
|
||||
|
||||
// Mark the end of this header's DIEs.
|
||||
TestCompilationUnit &Finish() {
|
||||
TestCompilationUnit& Finish() {
|
||||
length_ = Size() - post_length_offset_;
|
||||
return *this;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class TestAbbrevTable: public google_breakpad::test_assembler::Section {
|
|||
// Start a new abbreviation table entry for abbreviation code |code|,
|
||||
// encoding a DIE whose tag is |tag|, and which has children if and only
|
||||
// if |has_children| is true.
|
||||
TestAbbrevTable &Abbrev(int code, DwarfTag tag, DwarfHasChild has_children) {
|
||||
TestAbbrevTable& Abbrev(int code, DwarfTag tag, DwarfHasChild has_children) {
|
||||
assert(code != 0);
|
||||
ULEB128(code);
|
||||
ULEB128(static_cast<unsigned>(tag));
|
||||
|
@ -132,21 +132,21 @@ class TestAbbrevTable: public google_breakpad::test_assembler::Section {
|
|||
|
||||
// Add an attribute to the current abbreviation code whose name is |name|
|
||||
// and whose form is |form|.
|
||||
TestAbbrevTable &Attribute(DwarfAttribute name, DwarfForm form) {
|
||||
TestAbbrevTable& Attribute(DwarfAttribute name, DwarfForm form) {
|
||||
ULEB128(static_cast<unsigned>(name));
|
||||
ULEB128(static_cast<unsigned>(form));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Finish the current abbreviation code.
|
||||
TestAbbrevTable &EndAbbrev() {
|
||||
TestAbbrevTable& EndAbbrev() {
|
||||
ULEB128(0);
|
||||
ULEB128(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Finish the current abbreviation table.
|
||||
TestAbbrevTable &EndTable() {
|
||||
TestAbbrevTable& EndTable() {
|
||||
ULEB128(0);
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -130,11 +130,11 @@ class Elf32 {
|
|||
static const int kElfClass = ELFCLASS32;
|
||||
|
||||
// Given a symbol pointer, return the binding type (eg STB_WEAK).
|
||||
static char Bind(const Elf32_Sym *sym) {
|
||||
static char Bind(const Elf32_Sym* sym) {
|
||||
return ELF32_ST_BIND(sym->st_info);
|
||||
}
|
||||
// Given a symbol pointer, return the symbol type (eg STT_FUNC).
|
||||
static char Type(const Elf32_Sym *sym) {
|
||||
static char Type(const Elf32_Sym* sym) {
|
||||
return ELF32_ST_TYPE(sym->st_info);
|
||||
}
|
||||
|
||||
|
@ -158,10 +158,10 @@ class Elf64 {
|
|||
// What should be in the EI_CLASS header.
|
||||
static const int kElfClass = ELFCLASS64;
|
||||
|
||||
static char Bind(const Elf64_Sym *sym) {
|
||||
static char Bind(const Elf64_Sym* sym) {
|
||||
return ELF64_ST_BIND(sym->st_info);
|
||||
}
|
||||
static char Type(const Elf64_Sym *sym) {
|
||||
static char Type(const Elf64_Sym* sym) {
|
||||
return ELF64_ST_TYPE(sym->st_info);
|
||||
}
|
||||
static int r_sym(const Elf64_Xword r_info) {
|
||||
|
@ -182,8 +182,8 @@ class Elf64 {
|
|||
template<class ElfArch>
|
||||
class ElfSectionReader {
|
||||
public:
|
||||
ElfSectionReader(const char *name, const string &path, int fd,
|
||||
const typename ElfArch::Shdr §ion_header)
|
||||
ElfSectionReader(const char* name, const string& path, int fd,
|
||||
const typename ElfArch::Shdr& section_header)
|
||||
: contents_aligned_(NULL),
|
||||
contents_(NULL),
|
||||
header_(section_header) {
|
||||
|
@ -199,7 +199,7 @@ class ElfSectionReader {
|
|||
contents_aligned_ = mmap(NULL, size_aligned_, PROT_READ, MAP_SHARED,
|
||||
fd, offset_aligned);
|
||||
// Set where the offset really should begin.
|
||||
contents_ = reinterpret_cast<char *>(contents_aligned_) +
|
||||
contents_ = reinterpret_cast<char*>(contents_aligned_) +
|
||||
(header_.sh_offset - offset_aligned);
|
||||
|
||||
// Check for and handle any compressed contents.
|
||||
|
@ -217,24 +217,24 @@ class ElfSectionReader {
|
|||
}
|
||||
|
||||
// Return the section header for this section.
|
||||
typename ElfArch::Shdr const &header() const { return header_; }
|
||||
typename ElfArch::Shdr const& header() const { return header_; }
|
||||
|
||||
// Return memory at the given offset within this section.
|
||||
const char *GetOffset(typename ElfArch::Word bytes) const {
|
||||
const char* GetOffset(typename ElfArch::Word bytes) const {
|
||||
return contents_ + bytes;
|
||||
}
|
||||
|
||||
const char *contents() const { return contents_; }
|
||||
const char* contents() const { return contents_; }
|
||||
size_t section_size() const { return section_size_; }
|
||||
|
||||
private:
|
||||
// page-aligned file contents
|
||||
void *contents_aligned_;
|
||||
void* contents_aligned_;
|
||||
// contents as usable by the client. For non-compressed sections,
|
||||
// pointer within contents_aligned_ to where the section data
|
||||
// begins; for compressed sections, pointer to the decompressed
|
||||
// data.
|
||||
char *contents_;
|
||||
char* contents_;
|
||||
// size of contents_aligned_
|
||||
size_t size_aligned_;
|
||||
// size of contents.
|
||||
|
@ -249,7 +249,7 @@ class ElfSectionReader {
|
|||
template<class ElfArch>
|
||||
class SymbolIterator {
|
||||
public:
|
||||
SymbolIterator(ElfReaderImpl<ElfArch> *reader,
|
||||
SymbolIterator(ElfReaderImpl<ElfArch>* reader,
|
||||
typename ElfArch::Word section_type)
|
||||
: symbol_section_(reader->GetSectionByType(section_type)),
|
||||
string_section_(NULL),
|
||||
|
@ -280,7 +280,7 @@ class SymbolIterator {
|
|||
|
||||
// Return a pointer to the current symbol.
|
||||
// REQUIRES: !done()
|
||||
const typename ElfArch::Sym *GetSymbol() const {
|
||||
const typename ElfArch::Sym* GetSymbol() const {
|
||||
return reinterpret_cast<const typename ElfArch::Sym*>(
|
||||
symbol_section_->GetOffset(symbol_within_section_ *
|
||||
symbol_section_->header().sh_entsize));
|
||||
|
@ -288,7 +288,7 @@ class SymbolIterator {
|
|||
|
||||
// Return the name of the current symbol, NULL if it has none.
|
||||
// REQUIRES: !done()
|
||||
const char *GetSymbolName() const {
|
||||
const char* GetSymbolName() const {
|
||||
int name_offset = GetSymbol()->st_name;
|
||||
if (name_offset == 0)
|
||||
return NULL;
|
||||
|
@ -300,8 +300,8 @@ class SymbolIterator {
|
|||
}
|
||||
|
||||
private:
|
||||
const ElfSectionReader<ElfArch> *const symbol_section_;
|
||||
const ElfSectionReader<ElfArch> *string_section_;
|
||||
const ElfSectionReader<ElfArch>* const symbol_section_;
|
||||
const ElfSectionReader<ElfArch>* string_section_;
|
||||
int num_symbols_in_section_;
|
||||
int symbol_within_section_;
|
||||
};
|
||||
|
@ -326,7 +326,7 @@ static inline bool MyHasSuffixString(const string& str, const string& suffix) {
|
|||
template<class ElfArch>
|
||||
class ElfReaderImpl {
|
||||
public:
|
||||
explicit ElfReaderImpl(const string &path, int fd)
|
||||
explicit ElfReaderImpl(const string& path, int fd)
|
||||
: path_(path),
|
||||
fd_(fd),
|
||||
section_headers_(NULL),
|
||||
|
@ -347,7 +347,7 @@ class ElfReaderImpl {
|
|||
// "opd_section_" must always be checked for NULL before use.
|
||||
opd_section_ = GetSectionInfoByName(".opd", &opd_info_);
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
const char *name = GetSectionName(section_headers_[k].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[k].sh_name);
|
||||
if (strncmp(name, ".text", strlen(".text")) == 0) {
|
||||
base_for_text_ =
|
||||
section_headers_[k].sh_addr - section_headers_[k].sh_offset;
|
||||
|
@ -384,7 +384,7 @@ class ElfReaderImpl {
|
|||
// to see if the ELF file appears to match the current
|
||||
// architecture. If error is non-NULL, it will be set with a reason
|
||||
// in case of failure.
|
||||
static bool IsArchElfFile(int fd, string *error) {
|
||||
static bool IsArchElfFile(int fd, string* error) {
|
||||
unsigned char header[EI_NIDENT];
|
||||
if (pread(fd, header, sizeof(header), 0) != sizeof(header)) {
|
||||
if (error != NULL) *error = "Could not read header";
|
||||
|
@ -415,7 +415,7 @@ class ElfReaderImpl {
|
|||
}
|
||||
|
||||
// Return true if we can use this symbol in Address-to-Symbol map.
|
||||
bool CanUseSymbol(const char *name, const typename ElfArch::Sym *sym) {
|
||||
bool CanUseSymbol(const char* name, const typename ElfArch::Sym* sym) {
|
||||
// For now we only save FUNC and NOTYPE symbols. For now we just
|
||||
// care about functions, but some functions written in assembler
|
||||
// don't have a proper ELF type attached to them, so we store
|
||||
|
@ -444,7 +444,7 @@ class ElfReaderImpl {
|
|||
// Iterate over the symbols in a section, either SHT_DYNSYM or
|
||||
// SHT_SYMTAB. Add all symbols to the given SymbolMap.
|
||||
/*
|
||||
void GetSymbolPositions(SymbolMap *symbols,
|
||||
void GetSymbolPositions(SymbolMap* symbols,
|
||||
typename ElfArch::Word section_type,
|
||||
uint64_t mem_offset,
|
||||
uint64_t file_offset) {
|
||||
|
@ -453,10 +453,10 @@ class ElfReaderImpl {
|
|||
AddrToSymMap addr_to_sym_map;
|
||||
for (SymbolIterator<ElfArch> it(this, section_type);
|
||||
!it.done(); it.Next()) {
|
||||
const char *name = it.GetSymbolName();
|
||||
const char* name = it.GetSymbolName();
|
||||
if (name == NULL)
|
||||
continue;
|
||||
const typename ElfArch::Sym *sym = it.GetSymbol();
|
||||
const typename ElfArch::Sym* sym = it.GetSymbol();
|
||||
if (CanUseSymbol(name, sym)) {
|
||||
const int sec = sym->st_shndx;
|
||||
|
||||
|
@ -519,9 +519,9 @@ class ElfReaderImpl {
|
|||
if (addr_to_sym_map.empty()) {
|
||||
return;
|
||||
}
|
||||
const ElfSectionReader<ElfArch> *const symbol_section =
|
||||
const ElfSectionReader<ElfArch>* const symbol_section =
|
||||
this->GetSectionByType(section_type);
|
||||
const ElfSectionReader<ElfArch> *const string_section =
|
||||
const ElfSectionReader<ElfArch>* const string_section =
|
||||
this->GetSection(symbol_section->header().sh_link);
|
||||
|
||||
typename AddrToSymMap::iterator curr = addr_to_sym_map.begin();
|
||||
|
@ -532,8 +532,8 @@ class ElfReaderImpl {
|
|||
for (; curr != addr_to_sym_map.end(); ++curr) {
|
||||
const uint64_t prev_addr = prev->first;
|
||||
const uint64_t curr_addr = curr->first;
|
||||
const typename ElfArch::Sym *const prev_sym = prev->second;
|
||||
const typename ElfArch::Sym *const curr_sym = curr->second;
|
||||
const typename ElfArch::Sym* const prev_sym = prev->second;
|
||||
const typename ElfArch::Sym* const curr_sym = curr->second;
|
||||
if (prev_addr + prev_sym->st_size <= curr_addr ||
|
||||
// The next condition is true if two symbols overlap like this:
|
||||
//
|
||||
|
@ -552,7 +552,7 @@ class ElfReaderImpl {
|
|||
// (e.g. 0619e071) will produce the current symbol,
|
||||
// which is the desired outcome.
|
||||
prev_addr + prev_sym->st_size < curr_addr + curr_sym->st_size) {
|
||||
const char *name = string_section->GetOffset(curr_sym->st_name);
|
||||
const char* name = string_section->GetOffset(curr_sym->st_name);
|
||||
symbols->AddSymbol(name, curr_addr, curr_sym->st_size);
|
||||
prev = curr;
|
||||
} else {
|
||||
|
@ -572,20 +572,20 @@ class ElfReaderImpl {
|
|||
*/
|
||||
|
||||
void VisitSymbols(typename ElfArch::Word section_type,
|
||||
ElfReader::SymbolSink *sink) {
|
||||
ElfReader::SymbolSink* sink) {
|
||||
VisitSymbols(section_type, sink, -1, -1, false);
|
||||
}
|
||||
|
||||
void VisitSymbols(typename ElfArch::Word section_type,
|
||||
ElfReader::SymbolSink *sink,
|
||||
ElfReader::SymbolSink* sink,
|
||||
int symbol_binding,
|
||||
int symbol_type,
|
||||
bool get_raw_symbol_values) {
|
||||
for (SymbolIterator<ElfArch> it(this, section_type);
|
||||
!it.done(); it.Next()) {
|
||||
const char *name = it.GetSymbolName();
|
||||
const char* name = it.GetSymbolName();
|
||||
if (!name) continue;
|
||||
const typename ElfArch::Sym *sym = it.GetSymbol();
|
||||
const typename ElfArch::Sym* sym = it.GetSymbol();
|
||||
if ((symbol_binding < 0 || ElfArch::Bind(sym) == symbol_binding) &&
|
||||
(symbol_type < 0 || ElfArch::Type(sym) == symbol_type)) {
|
||||
typename ElfArch::Sym symbol = *sym;
|
||||
|
@ -691,7 +691,7 @@ class ElfReaderImpl {
|
|||
// Return an ElfSectionReader for the first section of the given
|
||||
// type by iterating through all section headers. Returns NULL if
|
||||
// the section type is not found.
|
||||
const ElfSectionReader<ElfArch> *GetSectionByType(
|
||||
const ElfSectionReader<ElfArch>* GetSectionByType(
|
||||
typename ElfArch::Word section_type) {
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
if (section_headers_[k].sh_type == section_type) {
|
||||
|
@ -703,14 +703,14 @@ class ElfReaderImpl {
|
|||
|
||||
// Return the name of section "shndx". Returns NULL if the section
|
||||
// is not found.
|
||||
const char *GetSectionNameByIndex(int shndx) {
|
||||
const char* GetSectionNameByIndex(int shndx) {
|
||||
return GetSectionName(section_headers_[shndx].sh_name);
|
||||
}
|
||||
|
||||
// Return a pointer to section "shndx", and store the size in
|
||||
// "size". Returns NULL if the section is not found.
|
||||
const char *GetSectionContentsByIndex(int shndx, size_t *size) {
|
||||
const ElfSectionReader<ElfArch> *section = GetSection(shndx);
|
||||
const char* GetSectionContentsByIndex(int shndx, size_t* size) {
|
||||
const ElfSectionReader<ElfArch>* section = GetSection(shndx);
|
||||
if (section != NULL) {
|
||||
*size = section->section_size();
|
||||
return section->contents();
|
||||
|
@ -721,16 +721,16 @@ class ElfReaderImpl {
|
|||
// Return a pointer to the first section of the given name by
|
||||
// iterating through all section headers, and store the size in
|
||||
// "size". Returns NULL if the section name is not found.
|
||||
const char *GetSectionContentsByName(const string §ion_name,
|
||||
size_t *size) {
|
||||
const char* GetSectionContentsByName(const string& section_name,
|
||||
size_t* size) {
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
// When searching for sections in a .dwp file, the sections
|
||||
// we're looking for will always be at the end of the section
|
||||
// table, so reverse the direction of iteration.
|
||||
int shndx = is_dwp_ ? GetNumSections() - k - 1 : k;
|
||||
const char *name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
if (name != NULL && ElfReader::SectionNamesMatch(section_name, name)) {
|
||||
const ElfSectionReader<ElfArch> *section = GetSection(shndx);
|
||||
const ElfSectionReader<ElfArch>* section = GetSection(shndx);
|
||||
if (section == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -744,16 +744,16 @@ class ElfReaderImpl {
|
|||
|
||||
// This is like GetSectionContentsByName() but it returns a lot of extra
|
||||
// information about the section.
|
||||
const char *GetSectionInfoByName(const string §ion_name,
|
||||
ElfReader::SectionInfo *info) {
|
||||
const char* GetSectionInfoByName(const string& section_name,
|
||||
ElfReader::SectionInfo* info) {
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
// When searching for sections in a .dwp file, the sections
|
||||
// we're looking for will always be at the end of the section
|
||||
// table, so reverse the direction of iteration.
|
||||
int shndx = is_dwp_ ? GetNumSections() - k - 1 : k;
|
||||
const char *name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
if (name != NULL && ElfReader::SectionNamesMatch(section_name, name)) {
|
||||
const ElfSectionReader<ElfArch> *section = GetSection(shndx);
|
||||
const ElfSectionReader<ElfArch>* section = GetSection(shndx);
|
||||
if (section == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -797,7 +797,7 @@ class ElfReaderImpl {
|
|||
// Debug sections are likely to be near the end, so reverse the
|
||||
// direction of iteration.
|
||||
for (int k = GetNumSections() - 1; k >= 0; --k) {
|
||||
const char *name = GetSectionName(section_headers_[k].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[k].sh_name);
|
||||
if (strncmp(name, ".debug", strlen(".debug")) == 0) return true;
|
||||
if (strncmp(name, ".zdebug", strlen(".zdebug")) == 0) return true;
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ class ElfReaderImpl {
|
|||
}
|
||||
|
||||
private:
|
||||
typedef vector<pair<uint64_t, const typename ElfArch::Sym *> > AddrToSymMap;
|
||||
typedef vector<pair<uint64_t, const typename ElfArch::Sym*> > AddrToSymMap;
|
||||
|
||||
static bool AddrToSymSorter(const typename AddrToSymMap::value_type& lhs,
|
||||
const typename AddrToSymMap::value_type& rhs) {
|
||||
|
@ -854,8 +854,8 @@ class ElfReaderImpl {
|
|||
|
||||
// Given an offset into the section header string table, return the
|
||||
// section name.
|
||||
const char *GetSectionName(typename ElfArch::Word sh_name) {
|
||||
const ElfSectionReader<ElfArch> *shstrtab =
|
||||
const char* GetSectionName(typename ElfArch::Word sh_name) {
|
||||
const ElfSectionReader<ElfArch>* shstrtab =
|
||||
GetSection(GetStringTableIndex());
|
||||
if (shstrtab != NULL) {
|
||||
return shstrtab->GetOffset(sh_name);
|
||||
|
@ -865,15 +865,15 @@ class ElfReaderImpl {
|
|||
|
||||
// Return an ElfSectionReader for the given section. The reader will
|
||||
// be freed when this object is destroyed.
|
||||
const ElfSectionReader<ElfArch> *GetSection(int num) {
|
||||
const char *name;
|
||||
const ElfSectionReader<ElfArch>* GetSection(int num) {
|
||||
const char* name;
|
||||
// Hard-coding the name for the section-name string table prevents
|
||||
// infinite recursion.
|
||||
if (num == GetStringTableIndex())
|
||||
name = ".shstrtab";
|
||||
else
|
||||
name = GetSectionNameByIndex(num);
|
||||
ElfSectionReader<ElfArch> *& reader = sections_[num];
|
||||
ElfSectionReader<ElfArch>*& reader = sections_[num];
|
||||
if (reader == NULL)
|
||||
reader = new ElfSectionReader<ElfArch>(name, path_, fd_,
|
||||
section_headers_[num]);
|
||||
|
@ -883,7 +883,7 @@ class ElfReaderImpl {
|
|||
// Parse out the overall header information from the file and assert
|
||||
// that it looks sane. This contains information like the magic
|
||||
// number and target architecture.
|
||||
bool ParseHeaders(int fd, const string &path) {
|
||||
bool ParseHeaders(int fd, const string& path) {
|
||||
// Read in the global ELF header.
|
||||
if (pread(fd, &header_, sizeof(header_), 0) != sizeof(header_)) {
|
||||
return false;
|
||||
|
@ -985,11 +985,11 @@ class ElfReaderImpl {
|
|||
|
||||
// Array of GetNumSections() section headers, allocated when we read
|
||||
// in the global header.
|
||||
typename ElfArch::Shdr *section_headers_;
|
||||
typename ElfArch::Shdr* section_headers_;
|
||||
|
||||
// Array of GetNumProgramHeaders() program headers, allocated when we read
|
||||
// in the global header.
|
||||
typename ElfArch::Phdr *program_headers_;
|
||||
typename ElfArch::Phdr* program_headers_;
|
||||
|
||||
// An array of pointers to ElfSectionReaders. Sections are
|
||||
// mmaped as they're needed and not released until this object is
|
||||
|
@ -1000,7 +1000,7 @@ class ElfReaderImpl {
|
|||
// values for funtion symbols values. Function descriptors are kept in the
|
||||
// .opd section and are dereferenced to find the function address.
|
||||
ElfReader::SectionInfo opd_info_;
|
||||
const char *opd_section_; // Must be checked for NULL before use.
|
||||
const char* opd_section_; // Must be checked for NULL before use.
|
||||
int64_t base_for_text_;
|
||||
|
||||
// Read PLT-related sections for the current architecture.
|
||||
|
@ -1026,7 +1026,7 @@ class ElfReaderImpl {
|
|||
bool is_dwp_;
|
||||
};
|
||||
|
||||
ElfReader::ElfReader(const string &path)
|
||||
ElfReader::ElfReader(const string& path)
|
||||
: path_(path), fd_(-1), impl32_(NULL), impl64_(NULL) {
|
||||
// linux 2.6.XX kernel can show deleted files like this:
|
||||
// /var/run/nscd/dbYLJYaE (deleted)
|
||||
|
@ -1063,7 +1063,7 @@ ElfReader::~ElfReader() {
|
|||
#endif
|
||||
|
||||
template <typename ElfArch>
|
||||
static bool IsElfFile(const int fd, const string &path) {
|
||||
static bool IsElfFile(const int fd, const string& path) {
|
||||
if (fd < 0)
|
||||
return false;
|
||||
if (!ElfReaderImpl<ElfArch>::IsArchElfFile(fd, NULL)) {
|
||||
|
@ -1086,7 +1086,7 @@ bool ElfReader::IsElf64File() const {
|
|||
}
|
||||
|
||||
/*
|
||||
void ElfReader::AddSymbols(SymbolMap *symbols,
|
||||
void ElfReader::AddSymbols(SymbolMap* symbols,
|
||||
uint64_t mem_offset, uint64_t file_offset,
|
||||
uint64_t length) {
|
||||
if (fd_ < 0)
|
||||
|
@ -1109,17 +1109,17 @@ void ElfReader::AddSymbols(SymbolMap *symbols,
|
|||
}
|
||||
*/
|
||||
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink) {
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink) {
|
||||
VisitSymbols(sink, -1, -1);
|
||||
}
|
||||
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink,
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink,
|
||||
int symbol_binding,
|
||||
int symbol_type) {
|
||||
VisitSymbols(sink, symbol_binding, symbol_type, false);
|
||||
}
|
||||
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink,
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink,
|
||||
int symbol_binding,
|
||||
int symbol_type,
|
||||
bool get_raw_symbol_values) {
|
||||
|
@ -1148,7 +1148,7 @@ uint64_t ElfReader::VaddrOfFirstLoadSegment() {
|
|||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionName(int shndx) {
|
||||
const char* ElfReader::GetSectionName(int shndx) {
|
||||
if (shndx < 0 || static_cast<unsigned int>(shndx) >= GetNumSections()) return NULL;
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionNameByIndex(shndx);
|
||||
|
@ -1169,7 +1169,7 @@ uint64_t ElfReader::GetNumSections() {
|
|||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionByIndex(int shndx, size_t *size) {
|
||||
const char* ElfReader::GetSectionByIndex(int shndx, size_t* size) {
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionContentsByIndex(shndx, size);
|
||||
} else if (IsElf64File()) {
|
||||
|
@ -1179,8 +1179,8 @@ const char *ElfReader::GetSectionByIndex(int shndx, size_t *size) {
|
|||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionByName(const string §ion_name,
|
||||
size_t *size) {
|
||||
const char* ElfReader::GetSectionByName(const string& section_name,
|
||||
size_t* size) {
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionContentsByName(section_name, size);
|
||||
} else if (IsElf64File()) {
|
||||
|
@ -1190,8 +1190,8 @@ const char *ElfReader::GetSectionByName(const string §ion_name,
|
|||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionInfoByName(const string §ion_name,
|
||||
SectionInfo *info) {
|
||||
const char* ElfReader::GetSectionInfoByName(const string& section_name,
|
||||
SectionInfo* info) {
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionInfoByName(section_name, info);
|
||||
} else if (IsElf64File()) {
|
||||
|
@ -1201,7 +1201,7 @@ const char *ElfReader::GetSectionInfoByName(const string §ion_name,
|
|||
}
|
||||
}
|
||||
|
||||
bool ElfReader::SectionNamesMatch(const string &name, const string &sh_name) {
|
||||
bool ElfReader::SectionNamesMatch(const string& name, const string& sh_name) {
|
||||
if ((name.find(".debug_", 0) == 0) && (sh_name.find(".zdebug_", 0) == 0)) {
|
||||
const string name_suffix(name, strlen(".debug_"));
|
||||
const string sh_name_suffix(sh_name, strlen(".zdebug_"));
|
||||
|
@ -1220,14 +1220,14 @@ bool ElfReader::IsDynamicSharedObject() {
|
|||
}
|
||||
}
|
||||
|
||||
ElfReaderImpl<Elf32> *ElfReader::GetImpl32() {
|
||||
ElfReaderImpl<Elf32>* ElfReader::GetImpl32() {
|
||||
if (impl32_ == NULL) {
|
||||
impl32_ = new ElfReaderImpl<Elf32>(path_, fd_);
|
||||
}
|
||||
return impl32_;
|
||||
}
|
||||
|
||||
ElfReaderImpl<Elf64> *ElfReader::GetImpl64() {
|
||||
ElfReaderImpl<Elf64>* ElfReader::GetImpl64() {
|
||||
if (impl64_ == NULL) {
|
||||
impl64_ = new ElfReaderImpl<Elf64>(path_, fd_);
|
||||
}
|
||||
|
@ -1238,7 +1238,7 @@ ElfReaderImpl<Elf64> *ElfReader::GetImpl64() {
|
|||
// debug info (debug_only=true) or symbol table (debug_only=false).
|
||||
// Otherwise, return false.
|
||||
template <typename ElfArch>
|
||||
static bool IsNonStrippedELFBinaryImpl(const string &path, const int fd,
|
||||
static bool IsNonStrippedELFBinaryImpl(const string& path, const int fd,
|
||||
bool debug_only) {
|
||||
if (!ElfReaderImpl<ElfArch>::IsArchElfFile(fd, NULL)) return false;
|
||||
ElfReaderImpl<ElfArch> elf_reader(path, fd);
|
||||
|
@ -1248,7 +1248,7 @@ static bool IsNonStrippedELFBinaryImpl(const string &path, const int fd,
|
|||
}
|
||||
|
||||
// Helper for the IsNon[Debug]StrippedELFBinary functions.
|
||||
static bool IsNonStrippedELFBinaryHelper(const string &path,
|
||||
static bool IsNonStrippedELFBinaryHelper(const string& path,
|
||||
bool debug_only) {
|
||||
const int fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
@ -1264,11 +1264,11 @@ static bool IsNonStrippedELFBinaryHelper(const string &path,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ElfReader::IsNonStrippedELFBinary(const string &path) {
|
||||
bool ElfReader::IsNonStrippedELFBinary(const string& path) {
|
||||
return IsNonStrippedELFBinaryHelper(path, false);
|
||||
}
|
||||
|
||||
bool ElfReader::IsNonDebugStrippedELFBinary(const string &path) {
|
||||
bool ElfReader::IsNonDebugStrippedELFBinary(const string& path) {
|
||||
return IsNonStrippedELFBinaryHelper(path, true);
|
||||
}
|
||||
} // namespace dwarf2reader
|
||||
|
|
|
@ -34,7 +34,7 @@ class ElfReaderImpl;
|
|||
|
||||
class ElfReader {
|
||||
public:
|
||||
explicit ElfReader(const string &path);
|
||||
explicit ElfReader(const string& path);
|
||||
~ElfReader();
|
||||
|
||||
// Parse the ELF prologue of this file and return whether it was
|
||||
|
@ -62,29 +62,29 @@ class ElfReader {
|
|||
// mem_offset - position at which the segment is mapped into memory
|
||||
// file_offset - offset in the file where the mapping begins
|
||||
// length - length of the mapped segment
|
||||
void AddSymbols(SymbolMap *symbols,
|
||||
void AddSymbols(SymbolMap* symbols,
|
||||
uint64_t mem_offset, uint64_t file_offset,
|
||||
uint64_t length);
|
||||
|
||||
class SymbolSink {
|
||||
public:
|
||||
virtual ~SymbolSink() {}
|
||||
virtual void AddSymbol(const char *name, uint64_t address,
|
||||
virtual void AddSymbol(const char* name, uint64_t address,
|
||||
uint64_t size) = 0;
|
||||
};
|
||||
|
||||
// Like AddSymbols above, but with no address correction.
|
||||
// Processes any SHT_SYMTAB section, followed by any SHT_DYNSYM section.
|
||||
void VisitSymbols(SymbolSink *sink);
|
||||
void VisitSymbols(SymbolSink* sink);
|
||||
|
||||
// Like VisitSymbols above, but for a specific symbol binding/type.
|
||||
// A negative value for the binding and type parameters means any
|
||||
// binding or type.
|
||||
void VisitSymbols(SymbolSink *sink, int symbol_binding, int symbol_type);
|
||||
void VisitSymbols(SymbolSink* sink, int symbol_binding, int symbol_type);
|
||||
|
||||
// Like VisitSymbols above but can optionally export raw symbol values instead
|
||||
// of adjusted ones.
|
||||
void VisitSymbols(SymbolSink *sink, int symbol_binding, int symbol_type,
|
||||
void VisitSymbols(SymbolSink* sink, int symbol_binding, int symbol_type,
|
||||
bool get_raw_symbol_values);
|
||||
|
||||
// p_vaddr of the first PT_LOAD segment (if any), or 0 if no PT_LOAD
|
||||
|
@ -95,7 +95,7 @@ class ElfReader {
|
|||
|
||||
// Return the name of section "shndx". Returns NULL if the section
|
||||
// is not found.
|
||||
const char *GetSectionName(int shndx);
|
||||
const char* GetSectionName(int shndx);
|
||||
|
||||
// Return the number of sections in the given ELF file.
|
||||
uint64_t GetNumSections();
|
||||
|
@ -104,14 +104,14 @@ class ElfReader {
|
|||
// the pointer to the section and store the size in "size".
|
||||
// On error, return NULL. The returned section data is only valid
|
||||
// until the ElfReader gets destroyed.
|
||||
const char *GetSectionByIndex(int shndx, size_t *size);
|
||||
const char* GetSectionByIndex(int shndx, size_t* size);
|
||||
|
||||
// Get section with "section_name" (ex. ".text", ".symtab") in the
|
||||
// given ELF file. On success, return the pointer to the section
|
||||
// and store the size in "size". On error, return NULL. The
|
||||
// returned section data is only valid until the ElfReader gets
|
||||
// destroyed.
|
||||
const char *GetSectionByName(const string §ion_name, size_t *size);
|
||||
const char* GetSectionByName(const string& section_name, size_t* size);
|
||||
|
||||
// This is like GetSectionByName() but it returns a lot of extra information
|
||||
// about the section. The SectionInfo structure is almost identical to
|
||||
|
@ -129,37 +129,37 @@ class ElfReader {
|
|||
uint64_t addralign; // Section alignment.
|
||||
uint64_t entsize; // Entry size if section holds a table.
|
||||
};
|
||||
const char *GetSectionInfoByName(const string §ion_name,
|
||||
SectionInfo *info);
|
||||
const char* GetSectionInfoByName(const string& section_name,
|
||||
SectionInfo* info);
|
||||
|
||||
// Check if "path" is an ELF binary that has not been stripped of symbol
|
||||
// tables. This function supports both 32-bit and 64-bit ELF binaries.
|
||||
static bool IsNonStrippedELFBinary(const string &path);
|
||||
static bool IsNonStrippedELFBinary(const string& path);
|
||||
|
||||
// Check if "path" is an ELF binary that has not been stripped of debug
|
||||
// info. Unlike IsNonStrippedELFBinary, this function will return
|
||||
// false for binaries passed through "strip -S".
|
||||
static bool IsNonDebugStrippedELFBinary(const string &path);
|
||||
static bool IsNonDebugStrippedELFBinary(const string& path);
|
||||
|
||||
// Match a requested section name with the section name as it
|
||||
// appears in the elf-file, adjusting for compressed debug section
|
||||
// names. For example, returns true if name == ".debug_abbrev" and
|
||||
// sh_name == ".zdebug_abbrev"
|
||||
static bool SectionNamesMatch(const string &name, const string &sh_name);
|
||||
static bool SectionNamesMatch(const string& name, const string& sh_name);
|
||||
|
||||
private:
|
||||
// Lazily initialize impl32_ and return it.
|
||||
ElfReaderImpl<Elf32> *GetImpl32();
|
||||
ElfReaderImpl<Elf32>* GetImpl32();
|
||||
// Ditto for impl64_.
|
||||
ElfReaderImpl<Elf64> *GetImpl64();
|
||||
ElfReaderImpl<Elf64>* GetImpl64();
|
||||
|
||||
// Path of the file we're reading.
|
||||
const string path_;
|
||||
// Read-only file descriptor for the file. May be -1 if there was an
|
||||
// error during open.
|
||||
int fd_;
|
||||
ElfReaderImpl<Elf32> *impl32_;
|
||||
ElfReaderImpl<Elf64> *impl64_;
|
||||
ElfReaderImpl<Elf32>* impl32_;
|
||||
ElfReaderImpl<Elf64>* impl64_;
|
||||
};
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
|
|
@ -144,7 +144,7 @@ bool CUFunctionInfoHandler::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
|||
void CUFunctionInfoHandler::ProcessAttributeString(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data) {
|
||||
const string& data) {
|
||||
if (current_function_info_) {
|
||||
if (attr == DW_AT_name)
|
||||
current_function_info_->name = data;
|
||||
|
|
|
@ -143,7 +143,7 @@ vector<string> DwarfCFIToModule::RegisterNames::MIPS() {
|
|||
}
|
||||
|
||||
bool DwarfCFIToModule::Entry(size_t offset, uint64_t address, uint64_t length,
|
||||
uint8_t version, const string &augmentation,
|
||||
uint8_t version, const string& augmentation,
|
||||
unsigned return_address) {
|
||||
assert(!entry_);
|
||||
|
||||
|
@ -190,7 +190,7 @@ string DwarfCFIToModule::RegisterName(int i) {
|
|||
}
|
||||
|
||||
void DwarfCFIToModule::Record(Module::Address address, int reg,
|
||||
const string &rule) {
|
||||
const string& rule) {
|
||||
assert(entry_);
|
||||
|
||||
// Place the name in our global set of strings, and then use the string
|
||||
|
@ -247,14 +247,14 @@ bool DwarfCFIToModule::RegisterRule(uint64_t address, int reg,
|
|||
}
|
||||
|
||||
bool DwarfCFIToModule::ExpressionRule(uint64_t address, int reg,
|
||||
const string &expression) {
|
||||
const string& expression) {
|
||||
reporter_->ExpressionsNotSupported(entry_offset_, RegisterName(reg));
|
||||
// Treat this as a non-fatal error.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DwarfCFIToModule::ValExpressionRule(uint64_t address, int reg,
|
||||
const string &expression) {
|
||||
const string& expression) {
|
||||
reporter_->ExpressionsNotSupported(entry_offset_, RegisterName(reg));
|
||||
// Treat this as a non-fatal error.
|
||||
return true;
|
||||
|
@ -274,7 +274,7 @@ void DwarfCFIToModule::Reporter::UnnamedRegister(size_t offset, int reg) {
|
|||
}
|
||||
|
||||
void DwarfCFIToModule::Reporter::UndefinedNotSupported(size_t offset,
|
||||
const string ®) {
|
||||
const string& reg) {
|
||||
fprintf(stderr, "%s, section '%s': "
|
||||
"the call frame entry at offset 0x%zx sets the rule for "
|
||||
"register '%s' to 'undefined', but the Breakpad symbol file format"
|
||||
|
@ -283,7 +283,7 @@ void DwarfCFIToModule::Reporter::UndefinedNotSupported(size_t offset,
|
|||
}
|
||||
|
||||
void DwarfCFIToModule::Reporter::ExpressionsNotSupported(size_t offset,
|
||||
const string ®) {
|
||||
const string& reg) {
|
||||
fprintf(stderr, "%s, section '%s': "
|
||||
"the call frame entry at offset 0x%zx uses a DWARF expression to"
|
||||
" describe how to recover register '%s', "
|
||||
|
|
|
@ -71,7 +71,7 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
|
|||
// stream. FILE is the name of the file we're processing, and
|
||||
// SECTION is the name of the section within that file that we're
|
||||
// looking at (.debug_frame, .eh_frame, etc.).
|
||||
Reporter(const string &file, const string §ion)
|
||||
Reporter(const string& file, const string& section)
|
||||
: file_(file), section_(section) { }
|
||||
virtual ~Reporter() { }
|
||||
|
||||
|
@ -83,13 +83,13 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
|
|||
|
||||
// The DWARF CFI entry at OFFSET says that REG is undefined, but the
|
||||
// Breakpad symbol file format cannot express this.
|
||||
virtual void UndefinedNotSupported(size_t offset, const string ®);
|
||||
virtual void UndefinedNotSupported(size_t offset, const string& reg);
|
||||
|
||||
// The DWARF CFI entry at OFFSET says that REG uses a DWARF
|
||||
// expression to find its value, but DwarfCFIToModule is not
|
||||
// capable of translating DWARF expressions to Breakpad postfix
|
||||
// expressions.
|
||||
virtual void ExpressionsNotSupported(size_t offset, const string ®);
|
||||
virtual void ExpressionsNotSupported(size_t offset, const string& reg);
|
||||
|
||||
protected:
|
||||
string file_, section_;
|
||||
|
@ -118,7 +118,7 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
|
|||
private:
|
||||
// Given STRINGS, an array of C strings with SIZE elements, return an
|
||||
// equivalent vector<string>.
|
||||
static vector<string> MakeVector(const char * const *strings, size_t size);
|
||||
static vector<string> MakeVector(const char* const* strings, size_t size);
|
||||
};
|
||||
|
||||
// Create a handler for the dwarf2reader::CallFrameInfo parser that
|
||||
|
@ -130,15 +130,15 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
|
|||
//
|
||||
// Use REPORTER for reporting problems encountered in the conversion
|
||||
// process.
|
||||
DwarfCFIToModule(Module *module, const vector<string> ®ister_names,
|
||||
Reporter *reporter)
|
||||
DwarfCFIToModule(Module* module, const vector<string>& register_names,
|
||||
Reporter* reporter)
|
||||
: module_(module), register_names_(register_names), reporter_(reporter),
|
||||
entry_(NULL), return_address_(-1), cfa_name_(".cfa"), ra_name_(".ra") {
|
||||
}
|
||||
virtual ~DwarfCFIToModule() { delete entry_; }
|
||||
|
||||
virtual bool Entry(size_t offset, uint64_t address, uint64_t length,
|
||||
uint8_t version, const string &augmentation,
|
||||
uint8_t version, const string& augmentation,
|
||||
unsigned return_address);
|
||||
virtual bool UndefinedRule(uint64_t address, int reg);
|
||||
virtual bool SameValueRule(uint64_t address, int reg);
|
||||
|
@ -148,9 +148,9 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
|
|||
int base_register, long offset);
|
||||
virtual bool RegisterRule(uint64_t address, int reg, int base_register);
|
||||
virtual bool ExpressionRule(uint64_t address, int reg,
|
||||
const string &expression);
|
||||
const string& expression);
|
||||
virtual bool ValExpressionRule(uint64_t address, int reg,
|
||||
const string &expression);
|
||||
const string& expression);
|
||||
virtual bool End();
|
||||
|
||||
private:
|
||||
|
@ -158,19 +158,19 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
|
|||
string RegisterName(int i);
|
||||
|
||||
// Record RULE for register REG at ADDRESS.
|
||||
void Record(Module::Address address, int reg, const string &rule);
|
||||
void Record(Module::Address address, int reg, const string& rule);
|
||||
|
||||
// The module to which we should add entries.
|
||||
Module *module_;
|
||||
Module* module_;
|
||||
|
||||
// Map from register numbers to register names.
|
||||
const vector<string> ®ister_names_;
|
||||
const vector<string>& register_names_;
|
||||
|
||||
// The reporter to use to report problems.
|
||||
Reporter *reporter_;
|
||||
Reporter* reporter_;
|
||||
|
||||
// The current entry we're constructing.
|
||||
Module::StackFrameEntry *entry_;
|
||||
Module::StackFrameEntry* entry_;
|
||||
|
||||
// The section offset of the current frame description entry, for
|
||||
// use in error messages.
|
||||
|
|
|
@ -47,11 +47,11 @@ using testing::Test;
|
|||
using testing::_;
|
||||
|
||||
struct MockCFIReporter: public DwarfCFIToModule::Reporter {
|
||||
MockCFIReporter(const string &file, const string §ion)
|
||||
MockCFIReporter(const string& file, const string& section)
|
||||
: Reporter(file, section) { }
|
||||
MOCK_METHOD2(UnnamedRegister, void(size_t offset, int reg));
|
||||
MOCK_METHOD2(UndefinedNotSupported, void(size_t offset, const string ®));
|
||||
MOCK_METHOD2(ExpressionsNotSupported, void(size_t offset, const string ®));
|
||||
MOCK_METHOD2(UndefinedNotSupported, void(size_t offset, const string& reg));
|
||||
MOCK_METHOD2(ExpressionsNotSupported, void(size_t offset, const string& reg));
|
||||
};
|
||||
|
||||
struct DwarfCFIToModuleFixture {
|
||||
|
@ -80,7 +80,7 @@ struct DwarfCFIToModuleFixture {
|
|||
vector<string> register_names;
|
||||
MockCFIReporter reporter;
|
||||
DwarfCFIToModule handler;
|
||||
vector<Module::StackFrameEntry *> entries;
|
||||
vector<Module::StackFrameEntry*> entries;
|
||||
};
|
||||
|
||||
class Entry: public DwarfCFIToModuleFixture, public Test { };
|
||||
|
|
|
@ -128,8 +128,8 @@ struct DwarfCUToModule::FilePrivate {
|
|||
AbstractOriginByOffset origins;
|
||||
};
|
||||
|
||||
DwarfCUToModule::FileContext::FileContext(const string &filename,
|
||||
Module *module,
|
||||
DwarfCUToModule::FileContext::FileContext(const string& filename,
|
||||
Module* module,
|
||||
bool handle_inter_cu_refs)
|
||||
: filename_(filename),
|
||||
module_(module),
|
||||
|
@ -141,7 +141,7 @@ DwarfCUToModule::FileContext::~FileContext() {
|
|||
}
|
||||
|
||||
void DwarfCUToModule::FileContext::AddSectionToSectionMap(
|
||||
const string& name, const uint8_t *contents, uint64_t length) {
|
||||
const string& name, const uint8_t* contents, uint64_t length) {
|
||||
section_map_[name] = std::make_pair(contents, length);
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ bool DwarfCUToModule::FileContext::IsUnhandledInterCUReference(
|
|||
// parsing. This is for data shared across the CU's entire DIE tree,
|
||||
// and parameters from the code invoking the CU parser.
|
||||
struct DwarfCUToModule::CUContext {
|
||||
CUContext(FileContext *file_context_arg, WarningReporter *reporter_arg,
|
||||
RangesHandler *ranges_handler_arg)
|
||||
CUContext(FileContext* file_context_arg, WarningReporter* reporter_arg,
|
||||
RangesHandler* ranges_handler_arg)
|
||||
: file_context(file_context_arg),
|
||||
reporter(reporter_arg),
|
||||
ranges_handler(ranges_handler_arg),
|
||||
|
@ -181,23 +181,23 @@ struct DwarfCUToModule::CUContext {
|
|||
ranges(0) {}
|
||||
|
||||
~CUContext() {
|
||||
for (vector<Module::Function *>::iterator it = functions.begin();
|
||||
for (vector<Module::Function*>::iterator it = functions.begin();
|
||||
it != functions.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
};
|
||||
|
||||
// The DWARF-bearing file into which this CU was incorporated.
|
||||
FileContext *file_context;
|
||||
FileContext* file_context;
|
||||
|
||||
// For printing error messages.
|
||||
WarningReporter *reporter;
|
||||
WarningReporter* reporter;
|
||||
|
||||
// For reading ranges from the .debug_ranges section
|
||||
RangesHandler *ranges_handler;
|
||||
RangesHandler* ranges_handler;
|
||||
|
||||
// The source language of this compilation unit.
|
||||
const Language *language;
|
||||
const Language* language;
|
||||
|
||||
// Addresses covered by this CU. If high_pc_ is non-zero then the CU covers
|
||||
// low_pc to high_pc, otherwise ranges is non-zero and low_pc represents
|
||||
|
@ -211,11 +211,11 @@ struct DwarfCUToModule::CUContext {
|
|||
// assign them lines and add them to file_context->module.
|
||||
//
|
||||
// Destroying this destroys all the functions this vector points to.
|
||||
vector<Module::Function *> functions;
|
||||
vector<Module::Function*> functions;
|
||||
|
||||
// Keep a list of forward references from DW_AT_abstract_origin and
|
||||
// DW_AT_specification attributes so names can be fixed up.
|
||||
std::map<uint64_t, Module::Function *> forward_ref_die_to_func;
|
||||
std::map<uint64_t, Module::Function*> forward_ref_die_to_func;
|
||||
};
|
||||
|
||||
// Information about the context of a particular DIE. This is for
|
||||
|
@ -241,7 +241,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler {
|
|||
// Create a handler for the DIE at OFFSET whose compilation unit is
|
||||
// described by CU_CONTEXT, and whose immediate context is described
|
||||
// by PARENT_CONTEXT.
|
||||
GenericDIEHandler(CUContext *cu_context, DIEContext *parent_context,
|
||||
GenericDIEHandler(CUContext* cu_context, DIEContext* parent_context,
|
||||
uint64_t offset)
|
||||
: cu_context_(cu_context),
|
||||
parent_context_(parent_context),
|
||||
|
@ -266,7 +266,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler {
|
|||
// handle DW_AT_specification, or simply not override it.
|
||||
void ProcessAttributeString(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data);
|
||||
const string& data);
|
||||
|
||||
protected:
|
||||
// Compute and return the fully-qualified name of the DIE. If this
|
||||
|
@ -279,8 +279,8 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler {
|
|||
// have been seen.
|
||||
string ComputeQualifiedName();
|
||||
|
||||
CUContext *cu_context_;
|
||||
DIEContext *parent_context_;
|
||||
CUContext* cu_context_;
|
||||
DIEContext* parent_context_;
|
||||
uint64_t offset_;
|
||||
|
||||
// Place the name in the global set of strings. Even though this looks
|
||||
|
@ -289,7 +289,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler {
|
|||
// share copies of strings whenever possible.
|
||||
// FIXME: Should this return something like a string_ref to avoid the
|
||||
// assumption about how strings are implemented?
|
||||
string AddStringToPool(const string &str);
|
||||
string AddStringToPool(const string& str);
|
||||
|
||||
// If this DIE has a DW_AT_declaration attribute, this is its value.
|
||||
// It is false on DIEs with no DW_AT_declaration attribute.
|
||||
|
@ -298,7 +298,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler {
|
|||
// If this DIE has a DW_AT_specification attribute, this is the
|
||||
// Specification structure for the DIE the attribute refers to.
|
||||
// Otherwise, this is NULL.
|
||||
Specification *specification_;
|
||||
Specification* specification_;
|
||||
|
||||
// If this DIE has a DW_AT_specification or DW_AT_abstract_origin and it is a
|
||||
// forward reference, no Specification will be available. Track the reference
|
||||
|
@ -335,7 +335,7 @@ void DwarfCUToModule::GenericDIEHandler::ProcessAttributeReference(
|
|||
uint64_t data) {
|
||||
switch (attr) {
|
||||
case dwarf2reader::DW_AT_specification: {
|
||||
FileContext *file_context = cu_context_->file_context;
|
||||
FileContext* file_context = cu_context_->file_context;
|
||||
if (file_context->IsUnhandledInterCUReference(
|
||||
data, cu_context_->reporter->cu_offset())) {
|
||||
cu_context_->reporter->UnhandledInterCUReference(offset_, data);
|
||||
|
@ -346,7 +346,7 @@ void DwarfCUToModule::GenericDIEHandler::ProcessAttributeReference(
|
|||
// here, but it's better to leave the real work to our
|
||||
// EndAttribute member function, at which point we know we have
|
||||
// seen all the DIE's attributes.
|
||||
SpecificationByOffset *specifications =
|
||||
SpecificationByOffset* specifications =
|
||||
&file_context->file_private_->specifications;
|
||||
SpecificationByOffset::iterator spec = specifications->find(data);
|
||||
if (spec != specifications->end()) {
|
||||
|
@ -362,7 +362,7 @@ void DwarfCUToModule::GenericDIEHandler::ProcessAttributeReference(
|
|||
}
|
||||
}
|
||||
|
||||
string DwarfCUToModule::GenericDIEHandler::AddStringToPool(const string &str) {
|
||||
string DwarfCUToModule::GenericDIEHandler::AddStringToPool(const string& str) {
|
||||
pair<unordered_set<string>::iterator, bool> result =
|
||||
cu_context_->file_context->file_private_->common_strings.insert(str);
|
||||
return *result.first;
|
||||
|
@ -371,7 +371,7 @@ string DwarfCUToModule::GenericDIEHandler::AddStringToPool(const string &str) {
|
|||
void DwarfCUToModule::GenericDIEHandler::ProcessAttributeString(
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data) {
|
||||
const string& data) {
|
||||
switch (attr) {
|
||||
case dwarf2reader::DW_AT_name:
|
||||
name_attribute_ = AddStringToPool(data);
|
||||
|
@ -404,7 +404,7 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() {
|
|||
// Use the demangled name, if one is available. Demangled names are
|
||||
// preferable to those inferred from the DWARF structure because they
|
||||
// include argument types.
|
||||
const string *qualified_name = NULL;
|
||||
const string* qualified_name = NULL;
|
||||
if (!demangled_name_.empty()) {
|
||||
// Found it is this DIE.
|
||||
qualified_name = &demangled_name_;
|
||||
|
@ -413,8 +413,8 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() {
|
|||
qualified_name = &specification_->qualified_name;
|
||||
}
|
||||
|
||||
const string *unqualified_name = NULL;
|
||||
const string *enclosing_name;
|
||||
const string* unqualified_name = NULL;
|
||||
const string* enclosing_name;
|
||||
if (!qualified_name) {
|
||||
// Find the unqualified name. If the DIE has its own DW_AT_name
|
||||
// attribute, then use that; otherwise, check the specification.
|
||||
|
@ -466,7 +466,7 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() {
|
|||
// A handler class for DW_TAG_subprogram DIEs.
|
||||
class DwarfCUToModule::FuncHandler: public GenericDIEHandler {
|
||||
public:
|
||||
FuncHandler(CUContext *cu_context, DIEContext *parent_context,
|
||||
FuncHandler(CUContext* cu_context, DIEContext* parent_context,
|
||||
uint64_t offset)
|
||||
: GenericDIEHandler(cu_context, parent_context, offset),
|
||||
low_pc_(0), high_pc_(0), high_pc_form_(dwarf2reader::DW_FORM_addr),
|
||||
|
@ -605,7 +605,7 @@ void DwarfCUToModule::FuncHandler::Finish() {
|
|||
Module::Range range(low_pc_, high_pc_ - low_pc_);
|
||||
ranges.push_back(range);
|
||||
} else {
|
||||
RangesHandler *ranges_handler = cu_context_->ranges_handler;
|
||||
RangesHandler* ranges_handler = cu_context_->ranges_handler;
|
||||
|
||||
if (ranges_handler) {
|
||||
if (!ranges_handler->ReadRanges(ranges_, cu_context_->low_pc, &ranges)) {
|
||||
|
@ -668,11 +668,11 @@ void DwarfCUToModule::FuncHandler::Finish() {
|
|||
// component to their names: namespaces, classes, etc.
|
||||
class DwarfCUToModule::NamedScopeHandler: public GenericDIEHandler {
|
||||
public:
|
||||
NamedScopeHandler(CUContext *cu_context, DIEContext *parent_context,
|
||||
NamedScopeHandler(CUContext* cu_context, DIEContext* parent_context,
|
||||
uint64_t offset)
|
||||
: GenericDIEHandler(cu_context, parent_context, offset) { }
|
||||
bool EndAttributes();
|
||||
DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag);
|
||||
DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag);
|
||||
|
||||
private:
|
||||
DIEContext child_context_; // A context for our children.
|
||||
|
@ -683,7 +683,7 @@ bool DwarfCUToModule::NamedScopeHandler::EndAttributes() {
|
|||
return true;
|
||||
}
|
||||
|
||||
dwarf2reader::DIEHandler *DwarfCUToModule::NamedScopeHandler::FindChildHandler(
|
||||
dwarf2reader::DIEHandler* DwarfCUToModule::NamedScopeHandler::FindChildHandler(
|
||||
uint64_t offset,
|
||||
enum DwarfTag tag) {
|
||||
switch (tag) {
|
||||
|
@ -725,7 +725,7 @@ void DwarfCUToModule::WarningReporter::UnknownAbstractOrigin(uint64_t offset,
|
|||
filename_.c_str(), offset, target);
|
||||
}
|
||||
|
||||
void DwarfCUToModule::WarningReporter::MissingSection(const string &name) {
|
||||
void DwarfCUToModule::WarningReporter::MissingSection(const string& name) {
|
||||
CUHeading();
|
||||
fprintf(stderr, "%s: warning: couldn't find DWARF '%s' section\n",
|
||||
filename_.c_str(), name.c_str());
|
||||
|
@ -748,7 +748,7 @@ void DwarfCUToModule::WarningReporter::UncoveredHeading() {
|
|||
}
|
||||
|
||||
void DwarfCUToModule::WarningReporter::UncoveredFunction(
|
||||
const Module::Function &function) {
|
||||
const Module::Function& function) {
|
||||
if (!uncovered_warnings_enabled_)
|
||||
return;
|
||||
UncoveredHeading();
|
||||
|
@ -757,7 +757,7 @@ void DwarfCUToModule::WarningReporter::UncoveredFunction(
|
|||
function.name.c_str());
|
||||
}
|
||||
|
||||
void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line &line) {
|
||||
void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line& line) {
|
||||
if (!uncovered_warnings_enabled_)
|
||||
return;
|
||||
UncoveredHeading();
|
||||
|
@ -772,7 +772,7 @@ void DwarfCUToModule::WarningReporter::UnnamedFunction(uint64_t offset) {
|
|||
filename_.c_str(), offset);
|
||||
}
|
||||
|
||||
void DwarfCUToModule::WarningReporter::DemangleError(const string &input) {
|
||||
void DwarfCUToModule::WarningReporter::DemangleError(const string& input) {
|
||||
CUHeading();
|
||||
fprintf(stderr, "%s: warning: failed to demangle %s\n",
|
||||
filename_.c_str(), input.c_str());
|
||||
|
@ -800,10 +800,10 @@ void DwarfCUToModule::WarningReporter::MissingRanges() {
|
|||
"the .debug_ranges section is missing.\n", filename_.c_str());
|
||||
}
|
||||
|
||||
DwarfCUToModule::DwarfCUToModule(FileContext *file_context,
|
||||
LineToModuleHandler *line_reader,
|
||||
RangesHandler *ranges_handler,
|
||||
WarningReporter *reporter)
|
||||
DwarfCUToModule::DwarfCUToModule(FileContext* file_context,
|
||||
LineToModuleHandler* line_reader,
|
||||
RangesHandler* ranges_handler,
|
||||
WarningReporter* reporter)
|
||||
: line_reader_(line_reader),
|
||||
cu_context_(new CUContext(file_context, reporter, ranges_handler)),
|
||||
child_context_(new DIEContext()),
|
||||
|
@ -853,7 +853,7 @@ void DwarfCUToModule::ProcessAttributeUnsigned(enum DwarfAttribute attr,
|
|||
|
||||
void DwarfCUToModule::ProcessAttributeString(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data) {
|
||||
const string& data) {
|
||||
switch (attr) {
|
||||
case dwarf2reader::DW_AT_name:
|
||||
cu_context_->reporter->SetCUName(data);
|
||||
|
@ -870,7 +870,7 @@ bool DwarfCUToModule::EndAttributes() {
|
|||
return true;
|
||||
}
|
||||
|
||||
dwarf2reader::DIEHandler *DwarfCUToModule::FindChildHandler(
|
||||
dwarf2reader::DIEHandler* DwarfCUToModule::FindChildHandler(
|
||||
uint64_t offset,
|
||||
enum DwarfTag tag) {
|
||||
switch (tag) {
|
||||
|
@ -932,7 +932,7 @@ void DwarfCUToModule::SetLanguage(DwarfLanguage language) {
|
|||
}
|
||||
|
||||
void DwarfCUToModule::ReadSourceLines(uint64_t offset) {
|
||||
const dwarf2reader::SectionMap §ion_map
|
||||
const dwarf2reader::SectionMap& section_map
|
||||
= cu_context_->file_context->section_map();
|
||||
dwarf2reader::SectionMap::const_iterator map_entry
|
||||
= dwarf2reader::GetSectionByName(section_map, ".debug_line");
|
||||
|
@ -974,30 +974,30 @@ void DwarfCUToModule::ReadSourceLines(uint64_t offset) {
|
|||
namespace {
|
||||
class FunctionRange {
|
||||
public:
|
||||
FunctionRange(const Module::Range &range, Module::Function *function) :
|
||||
FunctionRange(const Module::Range& range, Module::Function* function) :
|
||||
address(range.address), size(range.size), function(function) { }
|
||||
|
||||
void AddLine(Module::Line &line) {
|
||||
void AddLine(Module::Line& line) {
|
||||
function->lines.push_back(line);
|
||||
}
|
||||
|
||||
Module::Address address;
|
||||
Module::Address size;
|
||||
Module::Function *function;
|
||||
Module::Function* function;
|
||||
};
|
||||
|
||||
// Fills an array of ranges with pointers to the functions which owns
|
||||
// them. The array is sorted in ascending order and the ranges are non
|
||||
// empty and non-overlapping.
|
||||
|
||||
static void FillSortedFunctionRanges(vector<FunctionRange> &dest_ranges,
|
||||
vector<Module::Function *> *functions) {
|
||||
for (vector<Module::Function *>::const_iterator func_it = functions->cbegin();
|
||||
static void FillSortedFunctionRanges(vector<FunctionRange>& dest_ranges,
|
||||
vector<Module::Function*>* functions) {
|
||||
for (vector<Module::Function*>::const_iterator func_it = functions->cbegin();
|
||||
func_it != functions->cend();
|
||||
func_it++)
|
||||
{
|
||||
Module::Function *func = *func_it;
|
||||
vector<Module::Range> &ranges = func->ranges;
|
||||
Module::Function* func = *func_it;
|
||||
vector<Module::Range>& ranges = func->ranges;
|
||||
for (vector<Module::Range>::const_iterator ranges_it = ranges.cbegin();
|
||||
ranges_it != ranges.cend();
|
||||
++ranges_it) {
|
||||
|
@ -1009,7 +1009,7 @@ static void FillSortedFunctionRanges(vector<FunctionRange> &dest_ranges,
|
|||
}
|
||||
|
||||
sort(dest_ranges.begin(), dest_ranges.end(),
|
||||
[](const FunctionRange &fr1, const FunctionRange &fr2) {
|
||||
[](const FunctionRange& fr1, const FunctionRange& fr2) {
|
||||
return fr1.address < fr2.address;
|
||||
}
|
||||
);
|
||||
|
@ -1017,7 +1017,7 @@ static void FillSortedFunctionRanges(vector<FunctionRange> &dest_ranges,
|
|||
|
||||
// Return true if ADDRESS falls within the range of ITEM.
|
||||
template <class T>
|
||||
inline bool within(const T &item, Module::Address address) {
|
||||
inline bool within(const T& item, Module::Address address) {
|
||||
// Because Module::Address is unsigned, and unsigned arithmetic
|
||||
// wraps around, this will be false if ADDRESS falls before the
|
||||
// start of ITEM, or if it falls after ITEM's end.
|
||||
|
@ -1026,8 +1026,8 @@ inline bool within(const T &item, Module::Address address) {
|
|||
}
|
||||
|
||||
void DwarfCUToModule::AssignLinesToFunctions() {
|
||||
vector<Module::Function *> *functions = &cu_context_->functions;
|
||||
WarningReporter *reporter = cu_context_->reporter;
|
||||
vector<Module::Function*>* functions = &cu_context_->functions;
|
||||
WarningReporter* reporter = cu_context_->reporter;
|
||||
|
||||
// This would be simpler if we assumed that source line entries
|
||||
// don't cross function boundaries. However, there's no real reason
|
||||
|
@ -1047,12 +1047,12 @@ void DwarfCUToModule::AssignLinesToFunctions() {
|
|||
|
||||
// The last line that we used any piece of. We use this only for
|
||||
// generating warnings.
|
||||
const Module::Line *last_line_used = NULL;
|
||||
const Module::Line* last_line_used = NULL;
|
||||
|
||||
// The last function and line we warned about --- so we can avoid
|
||||
// doing so more than once.
|
||||
const Module::Function *last_function_cited = NULL;
|
||||
const Module::Line *last_line_cited = NULL;
|
||||
const Module::Function* last_function_cited = NULL;
|
||||
const Module::Line* last_line_cited = NULL;
|
||||
|
||||
// Prepare a sorted list of ranges with range-to-function mapping
|
||||
vector<FunctionRange> sorted_ranges;
|
||||
|
@ -1068,8 +1068,8 @@ void DwarfCUToModule::AssignLinesToFunctions() {
|
|||
|
||||
// Pointers to the referents of func_it and line_it, or NULL if the
|
||||
// iterator is at the end of the sequence.
|
||||
FunctionRange *range;
|
||||
const Module::Line *line;
|
||||
FunctionRange* range;
|
||||
const Module::Line* line;
|
||||
|
||||
// Start current at the beginning of the first line or function,
|
||||
// whichever is earlier.
|
||||
|
@ -1232,7 +1232,7 @@ void DwarfCUToModule::Finish() {
|
|||
if (has_source_line_info_)
|
||||
ReadSourceLines(source_line_offset_);
|
||||
|
||||
vector<Module::Function *> *functions = &cu_context_->functions;
|
||||
vector<Module::Function*>* functions = &cu_context_->functions;
|
||||
|
||||
// Dole out lines to the appropriate functions.
|
||||
AssignLinesToFunctions();
|
||||
|
|
|
@ -79,14 +79,14 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
// to true to handle debugging symbols with DW_FORM_ref_addr entries.
|
||||
class FileContext {
|
||||
public:
|
||||
FileContext(const string &filename,
|
||||
Module *module,
|
||||
FileContext(const string& filename,
|
||||
Module* module,
|
||||
bool handle_inter_cu_refs);
|
||||
~FileContext();
|
||||
|
||||
// Add CONTENTS of size LENGTH to the section map as NAME.
|
||||
void AddSectionToSectionMap(const string& name,
|
||||
const uint8_t *contents,
|
||||
const uint8_t* contents,
|
||||
uint64_t length);
|
||||
|
||||
// Clear the section map for testing.
|
||||
|
@ -114,7 +114,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
dwarf2reader::SectionMap section_map_;
|
||||
|
||||
// The Module to which we're contributing definitions.
|
||||
Module *module_;
|
||||
Module* module_;
|
||||
|
||||
// True if we are handling references between compilation units.
|
||||
const bool handle_inter_cu_refs_;
|
||||
|
@ -163,7 +163,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
uint64_t string_section_length,
|
||||
const uint8_t* line_string_section,
|
||||
uint64_t line_string_length,
|
||||
Module *module, vector<Module::Line> *lines) = 0;
|
||||
Module* module, vector<Module::Line>* lines) = 0;
|
||||
};
|
||||
|
||||
// The interface DwarfCUToModule uses to report warnings. The member
|
||||
|
@ -174,14 +174,14 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
public:
|
||||
// Warn about problems in the DWARF file FILENAME, in the
|
||||
// compilation unit at OFFSET.
|
||||
WarningReporter(const string &filename, uint64_t cu_offset)
|
||||
WarningReporter(const string& filename, uint64_t cu_offset)
|
||||
: filename_(filename), cu_offset_(cu_offset), printed_cu_header_(false),
|
||||
printed_unpaired_header_(false),
|
||||
uncovered_warnings_enabled_(false) { }
|
||||
virtual ~WarningReporter() { }
|
||||
|
||||
// Set the name of the compilation unit we're processing to NAME.
|
||||
virtual void SetCUName(const string &name) { cu_name_ = name; }
|
||||
virtual void SetCUName(const string& name) { cu_name_ = name; }
|
||||
|
||||
// Accessor and setter for uncovered_warnings_enabled_.
|
||||
// UncoveredFunction and UncoveredLine only report a problem if that is
|
||||
|
@ -204,17 +204,17 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
virtual void UnknownAbstractOrigin(uint64_t offset, uint64_t target);
|
||||
|
||||
// We were unable to find the DWARF section named SECTION_NAME.
|
||||
virtual void MissingSection(const string §ion_name);
|
||||
virtual void MissingSection(const string& section_name);
|
||||
|
||||
// The CU's DW_AT_stmt_list offset OFFSET is bogus.
|
||||
virtual void BadLineInfoOffset(uint64_t offset);
|
||||
|
||||
// FUNCTION includes code covered by no line number data.
|
||||
virtual void UncoveredFunction(const Module::Function &function);
|
||||
virtual void UncoveredFunction(const Module::Function& function);
|
||||
|
||||
// Line number NUMBER in LINE_FILE, of length LENGTH, includes code
|
||||
// covered by no function.
|
||||
virtual void UncoveredLine(const Module::Line &line);
|
||||
virtual void UncoveredLine(const Module::Line& line);
|
||||
|
||||
// The DW_TAG_subprogram DIE at OFFSET has no name specified directly
|
||||
// in the DIE, nor via a DW_AT_specification or DW_AT_abstract_origin
|
||||
|
@ -222,7 +222,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
virtual void UnnamedFunction(uint64_t offset);
|
||||
|
||||
// __cxa_demangle() failed to demangle INPUT.
|
||||
virtual void DemangleError(const string &input);
|
||||
virtual void DemangleError(const string& input);
|
||||
|
||||
// The DW_FORM_ref_addr at OFFSET to TARGET was not handled because
|
||||
// FilePrivate did not retain the inter-CU specification data.
|
||||
|
@ -261,10 +261,10 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
// FILE_CONTEXT->module. Use LINE_READER to handle the compilation
|
||||
// unit's line number data. Use REPORTER to report problems with the
|
||||
// data we find.
|
||||
DwarfCUToModule(FileContext *file_context,
|
||||
LineToModuleHandler *line_reader,
|
||||
RangesHandler *ranges_handler,
|
||||
WarningReporter *reporter);
|
||||
DwarfCUToModule(FileContext* file_context,
|
||||
LineToModuleHandler* line_reader,
|
||||
RangesHandler* ranges_handler,
|
||||
WarningReporter* reporter);
|
||||
~DwarfCUToModule();
|
||||
|
||||
void ProcessAttributeSigned(enum DwarfAttribute attr,
|
||||
|
@ -275,9 +275,9 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
uint64_t data);
|
||||
void ProcessAttributeString(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data);
|
||||
const string& data);
|
||||
bool EndAttributes();
|
||||
DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag);
|
||||
DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag);
|
||||
|
||||
// Assign all our source Lines to the Functions that cover their
|
||||
// addresses, and then add them to module_.
|
||||
|
@ -323,7 +323,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
|
|||
// destructor deletes them.
|
||||
|
||||
// The handler to use to handle line number data.
|
||||
LineToModuleHandler *line_reader_;
|
||||
LineToModuleHandler* line_reader_;
|
||||
|
||||
// This compilation unit's context.
|
||||
scoped_ptr<CUContext> cu_context_;
|
||||
|
|
|
@ -77,17 +77,17 @@ class MockLineToModuleHandler: public DwarfCUToModule::LineToModuleHandler {
|
|||
|
||||
class MockWarningReporter: public DwarfCUToModule::WarningReporter {
|
||||
public:
|
||||
MockWarningReporter(const string &filename, uint64_t cu_offset)
|
||||
MockWarningReporter(const string& filename, uint64_t cu_offset)
|
||||
: DwarfCUToModule::WarningReporter(filename, cu_offset) { }
|
||||
MOCK_METHOD1(SetCUName, void(const string &name));
|
||||
MOCK_METHOD1(SetCUName, void(const string& name));
|
||||
MOCK_METHOD2(UnknownSpecification, void(uint64_t offset, uint64_t target));
|
||||
MOCK_METHOD2(UnknownAbstractOrigin, void(uint64_t offset, uint64_t target));
|
||||
MOCK_METHOD1(MissingSection, void(const string §ion_name));
|
||||
MOCK_METHOD1(MissingSection, void(const string& section_name));
|
||||
MOCK_METHOD1(BadLineInfoOffset, void(uint64_t offset));
|
||||
MOCK_METHOD1(UncoveredFunction, void(const Module::Function &function));
|
||||
MOCK_METHOD1(UncoveredLine, void(const Module::Line &line));
|
||||
MOCK_METHOD1(UncoveredFunction, void(const Module::Function& function));
|
||||
MOCK_METHOD1(UncoveredLine, void(const Module::Line& line));
|
||||
MOCK_METHOD1(UnnamedFunction, void(uint64_t offset));
|
||||
MOCK_METHOD1(DemangleError, void(const string &input));
|
||||
MOCK_METHOD1(DemangleError, void(const string& input));
|
||||
MOCK_METHOD2(UnhandledInterCUReference, void(uint64_t offset, uint64_t target));
|
||||
};
|
||||
|
||||
|
@ -116,7 +116,7 @@ class CUFixtureBase {
|
|||
class AppendLinesFunctor {
|
||||
public:
|
||||
explicit AppendLinesFunctor(
|
||||
const vector<Module::Line> *lines) : lines_(lines) { }
|
||||
const vector<Module::Line>* lines) : lines_(lines) { }
|
||||
void operator()(const uint8_t* program, uint64_t length,
|
||||
const uint8_t* string_section,
|
||||
uint64_t string_section_length,
|
||||
|
@ -126,7 +126,7 @@ class CUFixtureBase {
|
|||
lines->insert(lines->end(), lines_->begin(), lines_->end());
|
||||
}
|
||||
private:
|
||||
const vector<Module::Line> *lines_;
|
||||
const vector<Module::Line>* lines_;
|
||||
};
|
||||
|
||||
CUFixtureBase()
|
||||
|
@ -169,7 +169,7 @@ class CUFixtureBase {
|
|||
// when it invokes its LineToModuleHandler. Call this before calling
|
||||
// StartCU.
|
||||
void PushLine(Module::Address address, Module::Address size,
|
||||
const string &filename, int line_number);
|
||||
const string& filename, int line_number);
|
||||
|
||||
// Use LANGUAGE for the compilation unit. More precisely, arrange
|
||||
// for StartCU to pass the compilation unit's root DIE a
|
||||
|
@ -190,28 +190,28 @@ class CUFixtureBase {
|
|||
void StartCU();
|
||||
|
||||
// Have HANDLER process some strange attribute/form/value triples.
|
||||
void ProcessStrangeAttributes(dwarf2reader::DIEHandler *handler);
|
||||
void ProcessStrangeAttributes(dwarf2reader::DIEHandler* handler);
|
||||
|
||||
// Start a child DIE of PARENT with the given tag and name. Leave
|
||||
// the handler ready to hear about children: call EndAttributes, but
|
||||
// not Finish.
|
||||
DIEHandler *StartNamedDIE(DIEHandler *parent, DwarfTag tag,
|
||||
const string &name);
|
||||
DIEHandler* StartNamedDIE(DIEHandler* parent, DwarfTag tag,
|
||||
const string& name);
|
||||
|
||||
// Start a child DIE of PARENT with the given tag and a
|
||||
// DW_AT_specification attribute whose value is SPECIFICATION. Leave
|
||||
// the handler ready to hear about children: call EndAttributes, but
|
||||
// not Finish. If NAME is non-zero, use it as the DW_AT_name
|
||||
// attribute.
|
||||
DIEHandler *StartSpecifiedDIE(DIEHandler *parent, DwarfTag tag,
|
||||
uint64_t specification, const char *name = NULL);
|
||||
DIEHandler* StartSpecifiedDIE(DIEHandler* parent, DwarfTag tag,
|
||||
uint64_t specification, const char* name = NULL);
|
||||
|
||||
// Define a function as a child of PARENT with the given name, address, and
|
||||
// size. If high_pc_form is DW_FORM_addr then the DW_AT_high_pc attribute
|
||||
// will be written as an address; otherwise it will be written as the
|
||||
// function's size. Call EndAttributes and Finish; one cannot define
|
||||
// children of the defined function's DIE.
|
||||
void DefineFunction(DIEHandler *parent, const string &name,
|
||||
void DefineFunction(DIEHandler* parent, const string& name,
|
||||
Module::Address address, Module::Address size,
|
||||
const char* mangled_name,
|
||||
DwarfForm high_pc_form = dwarf2reader::DW_FORM_addr);
|
||||
|
@ -219,32 +219,32 @@ class CUFixtureBase {
|
|||
// Create a declaration DIE as a child of PARENT with the given
|
||||
// offset, tag and name. If NAME is the empty string, don't provide
|
||||
// a DW_AT_name attribute. Call EndAttributes and Finish.
|
||||
void DeclarationDIE(DIEHandler *parent, uint64_t offset,
|
||||
DwarfTag tag, const string &name,
|
||||
const string &mangled_name);
|
||||
void DeclarationDIE(DIEHandler* parent, uint64_t offset,
|
||||
DwarfTag tag, const string& name,
|
||||
const string& mangled_name);
|
||||
|
||||
// Create a definition DIE as a child of PARENT with the given tag
|
||||
// that refers to the declaration DIE at offset SPECIFICATION as its
|
||||
// specification. If NAME is non-empty, pass it as the DW_AT_name
|
||||
// attribute. If SIZE is non-zero, record ADDRESS and SIZE as
|
||||
// low_pc/high_pc attributes.
|
||||
void DefinitionDIE(DIEHandler *parent, DwarfTag tag,
|
||||
uint64_t specification, const string &name,
|
||||
void DefinitionDIE(DIEHandler* parent, DwarfTag tag,
|
||||
uint64_t specification, const string& name,
|
||||
Module::Address address = 0, Module::Address size = 0);
|
||||
|
||||
// Create an inline DW_TAG_subprogram DIE as a child of PARENT. If
|
||||
// SPECIFICATION is non-zero, then the DIE refers to the declaration DIE at
|
||||
// offset SPECIFICATION as its specification. If Name is non-empty, pass it
|
||||
// as the DW_AT_name attribute.
|
||||
void AbstractInstanceDIE(DIEHandler *parent, uint64_t offset,
|
||||
void AbstractInstanceDIE(DIEHandler* parent, uint64_t offset,
|
||||
DwarfInline type, uint64_t specification,
|
||||
const string &name,
|
||||
const string& name,
|
||||
DwarfForm form = dwarf2reader::DW_FORM_data1);
|
||||
|
||||
// Create a DW_TAG_subprogram DIE as a child of PARENT that refers to
|
||||
// ORIGIN in its DW_AT_abstract_origin attribute. If NAME is the empty
|
||||
// string, don't provide a DW_AT_name attribute.
|
||||
void DefineInlineInstanceDIE(DIEHandler *parent, const string &name,
|
||||
void DefineInlineInstanceDIE(DIEHandler* parent, const string& name,
|
||||
uint64_t origin, Module::Address address,
|
||||
Module::Address size);
|
||||
|
||||
|
@ -259,7 +259,7 @@ class CUFixtureBase {
|
|||
// Test that the I'th function (ordered by address) in the module
|
||||
// this.module_ has the given name, address, and size, and that its
|
||||
// parameter size is zero.
|
||||
void TestFunction(int i, const string &name,
|
||||
void TestFunction(int i, const string& name,
|
||||
Module::Address address, Module::Address size);
|
||||
|
||||
// Test that the number of source lines owned by the I'th function
|
||||
|
@ -270,7 +270,7 @@ class CUFixtureBase {
|
|||
// (again, by address) has the given address, size, filename, and
|
||||
// line number.
|
||||
void TestLine(int i, int j, Module::Address address, Module::Address size,
|
||||
const string &filename, int number);
|
||||
const string& filename, int number);
|
||||
|
||||
// Actual objects under test.
|
||||
Module module_;
|
||||
|
@ -308,7 +308,7 @@ class CUFixtureBase {
|
|||
|
||||
// If functions_filled_ is true, this is a table of functions we've
|
||||
// extracted from module_, sorted by address.
|
||||
vector<Module::Function *> functions_;
|
||||
vector<Module::Function*> functions_;
|
||||
// True if we have filled the above vector with this.module_'s function list.
|
||||
bool functions_filled_;
|
||||
};
|
||||
|
@ -318,7 +318,7 @@ const size_t CUFixtureBase::dummy_line_size_ =
|
|||
sizeof(CUFixtureBase::dummy_line_program_);
|
||||
|
||||
void CUFixtureBase::PushLine(Module::Address address, Module::Address size,
|
||||
const string &filename, int line_number) {
|
||||
const string& filename, int line_number) {
|
||||
Module::Line l;
|
||||
l.address = address;
|
||||
l.size = size;
|
||||
|
@ -376,7 +376,7 @@ void CUFixtureBase::StartCU() {
|
|||
}
|
||||
|
||||
void CUFixtureBase::ProcessStrangeAttributes(
|
||||
dwarf2reader::DIEHandler *handler) {
|
||||
dwarf2reader::DIEHandler* handler) {
|
||||
handler->ProcessAttributeUnsigned((DwarfAttribute) 0xf560dead,
|
||||
(DwarfForm) 0x4106e4db,
|
||||
0xa592571997facda1ULL);
|
||||
|
@ -395,10 +395,10 @@ void CUFixtureBase::ProcessStrangeAttributes(
|
|||
"strange string");
|
||||
}
|
||||
|
||||
DIEHandler *CUFixtureBase::StartNamedDIE(DIEHandler *parent,
|
||||
DIEHandler* CUFixtureBase::StartNamedDIE(DIEHandler* parent,
|
||||
DwarfTag tag,
|
||||
const string &name) {
|
||||
dwarf2reader::DIEHandler *handler
|
||||
const string& name) {
|
||||
dwarf2reader::DIEHandler* handler
|
||||
= parent->FindChildHandler(0x8f4c783c0467c989ULL, tag);
|
||||
if (!handler)
|
||||
return NULL;
|
||||
|
@ -415,11 +415,11 @@ DIEHandler *CUFixtureBase::StartNamedDIE(DIEHandler *parent,
|
|||
return handler;
|
||||
}
|
||||
|
||||
DIEHandler *CUFixtureBase::StartSpecifiedDIE(DIEHandler *parent,
|
||||
DIEHandler* CUFixtureBase::StartSpecifiedDIE(DIEHandler* parent,
|
||||
DwarfTag tag,
|
||||
uint64_t specification,
|
||||
const char *name) {
|
||||
dwarf2reader::DIEHandler *handler
|
||||
const char* name) {
|
||||
dwarf2reader::DIEHandler* handler
|
||||
= parent->FindChildHandler(0x8f4c783c0467c989ULL, tag);
|
||||
if (!handler)
|
||||
return NULL;
|
||||
|
@ -439,12 +439,12 @@ DIEHandler *CUFixtureBase::StartSpecifiedDIE(DIEHandler *parent,
|
|||
return handler;
|
||||
}
|
||||
|
||||
void CUFixtureBase::DefineFunction(dwarf2reader::DIEHandler *parent,
|
||||
const string &name, Module::Address address,
|
||||
void CUFixtureBase::DefineFunction(dwarf2reader::DIEHandler* parent,
|
||||
const string& name, Module::Address address,
|
||||
Module::Address size,
|
||||
const char* mangled_name,
|
||||
DwarfForm high_pc_form) {
|
||||
dwarf2reader::DIEHandler *func
|
||||
dwarf2reader::DIEHandler* func
|
||||
= parent->FindChildHandler(0xe34797c7e68590a8LL,
|
||||
dwarf2reader::DW_TAG_subprogram);
|
||||
ASSERT_TRUE(func != NULL);
|
||||
|
@ -474,11 +474,11 @@ void CUFixtureBase::DefineFunction(dwarf2reader::DIEHandler *parent,
|
|||
delete func;
|
||||
}
|
||||
|
||||
void CUFixtureBase::DeclarationDIE(DIEHandler *parent, uint64_t offset,
|
||||
void CUFixtureBase::DeclarationDIE(DIEHandler* parent, uint64_t offset,
|
||||
DwarfTag tag,
|
||||
const string &name,
|
||||
const string &mangled_name) {
|
||||
dwarf2reader::DIEHandler *die = parent->FindChildHandler(offset, tag);
|
||||
const string& name,
|
||||
const string& mangled_name) {
|
||||
dwarf2reader::DIEHandler* die = parent->FindChildHandler(offset, tag);
|
||||
ASSERT_TRUE(die != NULL);
|
||||
if (!name.empty())
|
||||
die->ProcessAttributeString(dwarf2reader::DW_AT_name,
|
||||
|
@ -497,13 +497,13 @@ void CUFixtureBase::DeclarationDIE(DIEHandler *parent, uint64_t offset,
|
|||
delete die;
|
||||
}
|
||||
|
||||
void CUFixtureBase::DefinitionDIE(DIEHandler *parent,
|
||||
void CUFixtureBase::DefinitionDIE(DIEHandler* parent,
|
||||
DwarfTag tag,
|
||||
uint64_t specification,
|
||||
const string &name,
|
||||
const string& name,
|
||||
Module::Address address,
|
||||
Module::Address size) {
|
||||
dwarf2reader::DIEHandler *die
|
||||
dwarf2reader::DIEHandler* die
|
||||
= parent->FindChildHandler(0x6ccfea031a9e6cc9ULL, tag);
|
||||
ASSERT_TRUE(die != NULL);
|
||||
die->ProcessAttributeReference(dwarf2reader::DW_AT_specification,
|
||||
|
@ -526,13 +526,13 @@ void CUFixtureBase::DefinitionDIE(DIEHandler *parent,
|
|||
delete die;
|
||||
}
|
||||
|
||||
void CUFixtureBase::AbstractInstanceDIE(DIEHandler *parent,
|
||||
void CUFixtureBase::AbstractInstanceDIE(DIEHandler* parent,
|
||||
uint64_t offset,
|
||||
DwarfInline type,
|
||||
uint64_t specification,
|
||||
const string &name,
|
||||
const string& name,
|
||||
DwarfForm form) {
|
||||
dwarf2reader::DIEHandler *die
|
||||
dwarf2reader::DIEHandler* die
|
||||
= parent->FindChildHandler(offset, dwarf2reader::DW_TAG_subprogram);
|
||||
ASSERT_TRUE(die != NULL);
|
||||
if (specification != 0ULL)
|
||||
|
@ -554,12 +554,12 @@ void CUFixtureBase::AbstractInstanceDIE(DIEHandler *parent,
|
|||
delete die;
|
||||
}
|
||||
|
||||
void CUFixtureBase::DefineInlineInstanceDIE(DIEHandler *parent,
|
||||
const string &name,
|
||||
void CUFixtureBase::DefineInlineInstanceDIE(DIEHandler* parent,
|
||||
const string& name,
|
||||
uint64_t origin,
|
||||
Module::Address address,
|
||||
Module::Address size) {
|
||||
dwarf2reader::DIEHandler *func
|
||||
dwarf2reader::DIEHandler* func
|
||||
= parent->FindChildHandler(0x11c70f94c6e87ccdLL,
|
||||
dwarf2reader::DW_TAG_subprogram);
|
||||
ASSERT_TRUE(func != NULL);
|
||||
|
@ -597,13 +597,13 @@ void CUFixtureBase::TestFunctionCount(size_t expected) {
|
|||
ASSERT_EQ(expected, functions_.size());
|
||||
}
|
||||
|
||||
void CUFixtureBase::TestFunction(int i, const string &name,
|
||||
void CUFixtureBase::TestFunction(int i, const string& name,
|
||||
Module::Address address,
|
||||
Module::Address size) {
|
||||
FillFunctions();
|
||||
ASSERT_LT((size_t) i, functions_.size());
|
||||
|
||||
Module::Function *function = functions_[i];
|
||||
Module::Function* function = functions_[i];
|
||||
EXPECT_EQ(name, function->name);
|
||||
EXPECT_EQ(address, function->address);
|
||||
EXPECT_EQ(size, function->ranges[0].size);
|
||||
|
@ -619,12 +619,12 @@ void CUFixtureBase::TestLineCount(int i, size_t expected) {
|
|||
|
||||
void CUFixtureBase::TestLine(int i, int j,
|
||||
Module::Address address, Module::Address size,
|
||||
const string &filename, int number) {
|
||||
const string& filename, int number) {
|
||||
FillFunctions();
|
||||
ASSERT_LT((size_t) i, functions_.size());
|
||||
ASSERT_LT((size_t) j, functions_[i]->lines.size());
|
||||
|
||||
Module::Line *line = &functions_[i]->lines[j];
|
||||
Module::Line* line = &functions_[i]->lines[j];
|
||||
EXPECT_EQ(address, line->address);
|
||||
EXPECT_EQ(size, line->size);
|
||||
EXPECT_EQ(filename, line->file->name.c_str());
|
||||
|
@ -711,7 +711,7 @@ TEST_F(SimpleCU, IrrelevantRootChildren) {
|
|||
|
||||
TEST_F(SimpleCU, IrrelevantNamedScopeChildren) {
|
||||
StartCU();
|
||||
DIEHandler *class_A_handler
|
||||
DIEHandler* class_A_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A");
|
||||
EXPECT_TRUE(class_A_handler != NULL);
|
||||
EXPECT_FALSE(class_A_handler
|
||||
|
@ -861,7 +861,7 @@ INSTANTIATE_TEST_CASE_P(AllSituations, FuncLinePairing,
|
|||
ValuesIn(situations));
|
||||
|
||||
TEST_P(FuncLinePairing, Pairing) {
|
||||
const Situation &s = GetParam();
|
||||
const Situation& s = GetParam();
|
||||
PushLine(s.lines[0].start,
|
||||
s.lines[0].end - s.lines[0].start,
|
||||
"line-file", 67636963);
|
||||
|
@ -1057,7 +1057,7 @@ TEST_P(CXXQualifiedNames, TwoFunctions) {
|
|||
PushLine(20, 1, "filename2", 95115701);
|
||||
|
||||
StartCU();
|
||||
DIEHandler *enclosure_handler = StartNamedDIE(&root_handler_, tag,
|
||||
DIEHandler* enclosure_handler = StartNamedDIE(&root_handler_, tag,
|
||||
"Enclosure");
|
||||
EXPECT_TRUE(enclosure_handler != NULL);
|
||||
DefineFunction(enclosure_handler, "func_B", 10, 1, NULL);
|
||||
|
@ -1078,11 +1078,11 @@ TEST_P(CXXQualifiedNames, FuncInEnclosureInNamespace) {
|
|||
PushLine(10, 1, "line-file", 69819327);
|
||||
|
||||
StartCU();
|
||||
DIEHandler *namespace_handler
|
||||
DIEHandler* namespace_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace,
|
||||
"Namespace");
|
||||
EXPECT_TRUE(namespace_handler != NULL);
|
||||
DIEHandler *enclosure_handler = StartNamedDIE(namespace_handler, tag,
|
||||
DIEHandler* enclosure_handler = StartNamedDIE(namespace_handler, tag,
|
||||
"Enclosure");
|
||||
EXPECT_TRUE(enclosure_handler != NULL);
|
||||
DefineFunction(enclosure_handler, "function", 10, 1, NULL);
|
||||
|
@ -1101,15 +1101,15 @@ TEST_F(CXXQualifiedNames, FunctionInClassInStructInNamespace) {
|
|||
PushLine(10, 1, "filename1", 69819327);
|
||||
|
||||
StartCU();
|
||||
DIEHandler *namespace_handler
|
||||
DIEHandler* namespace_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace,
|
||||
"namespace_A");
|
||||
EXPECT_TRUE(namespace_handler != NULL);
|
||||
DIEHandler *struct_handler
|
||||
DIEHandler* struct_handler
|
||||
= StartNamedDIE(namespace_handler, dwarf2reader::DW_TAG_structure_type,
|
||||
"struct_B");
|
||||
EXPECT_TRUE(struct_handler != NULL);
|
||||
DIEHandler *class_handler
|
||||
DIEHandler* class_handler
|
||||
= StartNamedDIE(struct_handler, dwarf2reader::DW_TAG_class_type,
|
||||
"class_C");
|
||||
DefineFunction(class_handler, "function_D", 10, 1, NULL);
|
||||
|
@ -1127,7 +1127,7 @@ TEST_F(CXXQualifiedNames, FunctionInClassInStructInNamespace) {
|
|||
|
||||
struct LanguageAndQualifiedName {
|
||||
dwarf2reader::DwarfLanguage language;
|
||||
const char *name;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
const LanguageAndQualifiedName LanguageAndQualifiedNameCases[] = {
|
||||
|
@ -1149,13 +1149,13 @@ INSTANTIATE_TEST_CASE_P(LanguageAndQualifiedName, QualifiedForLanguage,
|
|||
ValuesIn(LanguageAndQualifiedNameCases));
|
||||
|
||||
TEST_P(QualifiedForLanguage, MemberFunction) {
|
||||
const LanguageAndQualifiedName ¶m = GetParam();
|
||||
const LanguageAndQualifiedName& param = GetParam();
|
||||
|
||||
PushLine(10, 1, "line-file", 212966758);
|
||||
SetLanguage(param.language);
|
||||
|
||||
StartCU();
|
||||
DIEHandler *class_handler
|
||||
DIEHandler* class_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
"class_A");
|
||||
DefineFunction(class_handler, "function_B", 10, 1, NULL);
|
||||
|
@ -1172,14 +1172,14 @@ TEST_P(QualifiedForLanguage, MemberFunction) {
|
|||
}
|
||||
|
||||
TEST_P(QualifiedForLanguage, MemberFunctionSignedLanguage) {
|
||||
const LanguageAndQualifiedName ¶m = GetParam();
|
||||
const LanguageAndQualifiedName& param = GetParam();
|
||||
|
||||
PushLine(10, 1, "line-file", 212966758);
|
||||
SetLanguage(param.language);
|
||||
SetLanguageSigned(true);
|
||||
|
||||
StartCU();
|
||||
DIEHandler *class_handler
|
||||
DIEHandler* class_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
"class_A");
|
||||
DefineFunction(class_handler, "function_B", 10, 1, NULL);
|
||||
|
@ -1282,7 +1282,7 @@ TEST_F(Specifications, MemberFunction) {
|
|||
PushLine(0x3341a248634e7170ULL, 0x5f6938ee5553b953ULL, "line-file", 18116691);
|
||||
|
||||
StartCU();
|
||||
DIEHandler *class_handler
|
||||
DIEHandler* class_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A");
|
||||
DeclarationDIE(class_handler, 0x7d83028c431406e8ULL,
|
||||
dwarf2reader::DW_TAG_subprogram, "declaration-name", "");
|
||||
|
@ -1305,7 +1305,7 @@ TEST_F(Specifications, FunctionDeclarationParent) {
|
|||
|
||||
StartCU();
|
||||
{
|
||||
DIEHandler *class_handler
|
||||
DIEHandler* class_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
"class_A");
|
||||
ASSERT_TRUE(class_handler != NULL);
|
||||
|
@ -1333,7 +1333,7 @@ TEST_F(Specifications, NamedScopeDeclarationParent) {
|
|||
|
||||
StartCU();
|
||||
{
|
||||
DIEHandler *space_handler
|
||||
DIEHandler* space_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace,
|
||||
"space_A");
|
||||
ASSERT_TRUE(space_handler != NULL);
|
||||
|
@ -1345,7 +1345,7 @@ TEST_F(Specifications, NamedScopeDeclarationParent) {
|
|||
}
|
||||
|
||||
{
|
||||
DIEHandler *class_handler
|
||||
DIEHandler* class_handler
|
||||
= StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
0x419bb1d12f9a73a2ULL, "class-definition-name");
|
||||
ASSERT_TRUE(class_handler != NULL);
|
||||
|
@ -1437,7 +1437,7 @@ TEST_F(Specifications, LongChain) {
|
|||
// space_A::space_B::struct_C::struct_D::union_E::union_F::
|
||||
// class_G::class_H::func_I
|
||||
{
|
||||
DIEHandler *space_A_handler
|
||||
DIEHandler* space_A_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace,
|
||||
"space_A");
|
||||
DeclarationDIE(space_A_handler, 0x2e111126496596e2ULL,
|
||||
|
@ -1447,10 +1447,10 @@ TEST_F(Specifications, LongChain) {
|
|||
}
|
||||
|
||||
{
|
||||
DIEHandler *space_B_handler
|
||||
DIEHandler* space_B_handler
|
||||
= StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace,
|
||||
0x2e111126496596e2ULL);
|
||||
DIEHandler *struct_C_handler
|
||||
DIEHandler* struct_C_handler
|
||||
= StartNamedDIE(space_B_handler, dwarf2reader::DW_TAG_structure_type,
|
||||
"struct_C");
|
||||
DeclarationDIE(struct_C_handler, 0x20cd423bf2a25a4cULL,
|
||||
|
@ -1462,10 +1462,10 @@ TEST_F(Specifications, LongChain) {
|
|||
}
|
||||
|
||||
{
|
||||
DIEHandler *struct_D_handler
|
||||
DIEHandler* struct_D_handler
|
||||
= StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_structure_type,
|
||||
0x20cd423bf2a25a4cULL);
|
||||
DIEHandler *union_E_handler
|
||||
DIEHandler* union_E_handler
|
||||
= StartNamedDIE(struct_D_handler, dwarf2reader::DW_TAG_union_type,
|
||||
"union_E");
|
||||
DeclarationDIE(union_E_handler, 0xe25c84805aa58c32ULL,
|
||||
|
@ -1477,10 +1477,10 @@ TEST_F(Specifications, LongChain) {
|
|||
}
|
||||
|
||||
{
|
||||
DIEHandler *union_F_handler
|
||||
DIEHandler* union_F_handler
|
||||
= StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_union_type,
|
||||
0xe25c84805aa58c32ULL);
|
||||
DIEHandler *class_G_handler
|
||||
DIEHandler* class_G_handler
|
||||
= StartNamedDIE(union_F_handler, dwarf2reader::DW_TAG_class_type,
|
||||
"class_G");
|
||||
DeclarationDIE(class_G_handler, 0xb70d960dcc173b6eULL,
|
||||
|
@ -1492,7 +1492,7 @@ TEST_F(Specifications, LongChain) {
|
|||
}
|
||||
|
||||
{
|
||||
DIEHandler *class_H_handler
|
||||
DIEHandler* class_H_handler
|
||||
= StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
0xb70d960dcc173b6eULL);
|
||||
DeclarationDIE(class_H_handler, 0x27ff829e3bf69f37ULL,
|
||||
|
@ -1542,7 +1542,7 @@ TEST_F(Specifications, InterCU) {
|
|||
ASSERT_TRUE(root2_handler.StartRootDIE(1,
|
||||
dwarf2reader::DW_TAG_compile_unit));
|
||||
ASSERT_TRUE(root2_handler.EndAttributes());
|
||||
DIEHandler *class_A_handler
|
||||
DIEHandler* class_A_handler
|
||||
= StartSpecifiedDIE(&root2_handler, dwarf2reader::DW_TAG_class_type,
|
||||
0xb8fbfdd5f0b26fceULL);
|
||||
DeclarationDIE(class_A_handler, 0xb01fef8b380bd1a2ULL,
|
||||
|
@ -1565,7 +1565,7 @@ TEST_F(Specifications, InterCU) {
|
|||
root3_handler.Finish();
|
||||
}
|
||||
|
||||
vector<Module::Function *> functions;
|
||||
vector<Module::Function*> functions;
|
||||
m.GetFunctions(&functions, functions.end());
|
||||
EXPECT_EQ(1U, functions.size());
|
||||
EXPECT_STREQ("class_A::member_func_B", functions[0]->name.c_str());
|
||||
|
@ -1602,7 +1602,7 @@ TEST_F(Specifications, UnhandledInterCU) {
|
|||
dwarf2reader::DW_TAG_compile_unit));
|
||||
ASSERT_TRUE(root2_handler.EndAttributes());
|
||||
EXPECT_CALL(reporter_, UnhandledInterCUReference(_, _)).Times(1);
|
||||
DIEHandler *class_A_handler
|
||||
DIEHandler* class_A_handler
|
||||
= StartSpecifiedDIE(&root2_handler, dwarf2reader::DW_TAG_class_type,
|
||||
0xb8fbfdd5f0b26fceULL);
|
||||
DeclarationDIE(class_A_handler, 0xb01fef8b380bd1a2ULL,
|
||||
|
@ -1665,7 +1665,7 @@ TEST_F(Specifications, ClassDefinitionHasOwnName) {
|
|||
DeclarationDIE(&root_handler_, 0xd0fe467ec2f1a58cULL,
|
||||
dwarf2reader::DW_TAG_class_type, "class-declaration-name", "");
|
||||
|
||||
dwarf2reader::DIEHandler *class_definition
|
||||
dwarf2reader::DIEHandler* class_definition
|
||||
= StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
0xd0fe467ec2f1a58cULL, "class-definition-name");
|
||||
ASSERT_TRUE(class_definition);
|
||||
|
@ -1696,7 +1696,7 @@ TEST_F(Specifications, PreferSpecificationParents) {
|
|||
|
||||
StartCU();
|
||||
{
|
||||
dwarf2reader::DIEHandler *declaration_class_handler =
|
||||
dwarf2reader::DIEHandler* declaration_class_handler =
|
||||
StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
"declaration-class");
|
||||
DeclarationDIE(declaration_class_handler, 0x9ddb35517455ef7aULL,
|
||||
|
@ -1706,7 +1706,7 @@ TEST_F(Specifications, PreferSpecificationParents) {
|
|||
delete declaration_class_handler;
|
||||
}
|
||||
{
|
||||
dwarf2reader::DIEHandler *definition_class_handler
|
||||
dwarf2reader::DIEHandler* definition_class_handler
|
||||
= StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type,
|
||||
"definition-class");
|
||||
DefinitionDIE(definition_class_handler, dwarf2reader::DW_TAG_subprogram,
|
||||
|
|
|
@ -44,18 +44,18 @@
|
|||
// it until we actually have to deal with DWARF on Windows.
|
||||
|
||||
// Return true if PATH is an absolute path, false if it is relative.
|
||||
static bool PathIsAbsolute(const string &path) {
|
||||
static bool PathIsAbsolute(const string& path) {
|
||||
return (path.size() >= 1 && path[0] == '/');
|
||||
}
|
||||
|
||||
static bool HasTrailingSlash(const string &path) {
|
||||
static bool HasTrailingSlash(const string& path) {
|
||||
return (path.size() >= 1 && path[path.size() - 1] == '/');
|
||||
}
|
||||
|
||||
// If PATH is an absolute path, return PATH. If PATH is a relative path,
|
||||
// treat it as relative to BASE and return the combined path.
|
||||
static string ExpandPath(const string &path,
|
||||
const string &base) {
|
||||
static string ExpandPath(const string& path,
|
||||
const string& base) {
|
||||
if (PathIsAbsolute(path) || base.empty())
|
||||
return path;
|
||||
return base + (HasTrailingSlash(base) ? "" : "/") + path;
|
||||
|
@ -63,14 +63,14 @@ static string ExpandPath(const string &path,
|
|||
|
||||
namespace google_breakpad {
|
||||
|
||||
void DwarfLineToModule::DefineDir(const string &name, uint32_t dir_num) {
|
||||
void DwarfLineToModule::DefineDir(const string& name, uint32_t dir_num) {
|
||||
// Directory number zero is reserved to mean the compilation
|
||||
// directory. Silently ignore attempts to redefine it.
|
||||
if (dir_num != 0)
|
||||
directories_[dir_num] = ExpandPath(name, compilation_dir_);
|
||||
}
|
||||
|
||||
void DwarfLineToModule::DefineFile(const string &name, int32_t file_num,
|
||||
void DwarfLineToModule::DefineFile(const string& name, int32_t file_num,
|
||||
uint32_t dir_num, uint64_t mod_time,
|
||||
uint64_t length) {
|
||||
if (file_num == -1)
|
||||
|
|
|
@ -121,7 +121,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler {
|
|||
// sort out which lines belong to which functions; we don't add them
|
||||
// to any particular function in MODULE ourselves.
|
||||
DwarfLineToModule(Module *module, const string& compilation_dir,
|
||||
vector<Module::Line> *lines)
|
||||
vector<Module::Line>* lines)
|
||||
: module_(module),
|
||||
compilation_dir_(compilation_dir),
|
||||
lines_(lines),
|
||||
|
@ -132,8 +132,8 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler {
|
|||
|
||||
~DwarfLineToModule() { }
|
||||
|
||||
void DefineDir(const string &name, uint32_t dir_num);
|
||||
void DefineFile(const string &name, int32_t file_num,
|
||||
void DefineDir(const string& name, uint32_t dir_num);
|
||||
void DefineFile(const string& name, int32_t file_num,
|
||||
uint32_t dir_num, uint64_t mod_time,
|
||||
uint64_t length);
|
||||
void AddLine(uint64_t address, uint64_t length,
|
||||
|
@ -142,7 +142,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler {
|
|||
private:
|
||||
|
||||
typedef std::map<uint32_t, string> DirectoryTable;
|
||||
typedef std::map<uint32_t, Module::File *> FileTable;
|
||||
typedef std::map<uint32_t, Module::File*> FileTable;
|
||||
|
||||
// The module we're contributing debugging info to. Owned by our
|
||||
// client.
|
||||
|
@ -161,7 +161,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler {
|
|||
// to the appropriate function from module_ until we've read the
|
||||
// function info as well. Instead, we accumulate lines here, and let
|
||||
// whoever constructed this sort it all out.
|
||||
vector<Module::Line> *lines_;
|
||||
vector<Module::Line>* lines_;
|
||||
|
||||
// A table mapping directory numbers to paths.
|
||||
DirectoryTable directories_;
|
||||
|
|
|
@ -51,7 +51,7 @@ TEST(SimpleModule, One) {
|
|||
h.AddLine(0x6fd126fbf74f2680LL, 0x63c9a14cf556712bLL, 0x30bf0f27,
|
||||
0x4c090cbf, 0x1cf9fe0d);
|
||||
|
||||
vector<Module::File *> files;
|
||||
vector<Module::File*> files;
|
||||
m.GetFiles(&files);
|
||||
EXPECT_EQ(1U, files.size());
|
||||
EXPECT_STREQ("/file1", files[0]->name.c_str());
|
||||
|
@ -86,7 +86,7 @@ TEST(SimpleModule, Many) {
|
|||
h.AddLine(0xe2d72a37f8d9403aULL, 0x034dfab5b0d4d236ULL, 0x63beb4a5,
|
||||
0x75047044U, 0xb6a0016cU);
|
||||
|
||||
vector<Module::File *> files;
|
||||
vector<Module::File*> files;
|
||||
m.GetFiles(&files);
|
||||
ASSERT_EQ(5U, files.size());
|
||||
EXPECT_STREQ("/directory1/file1", files[0]->name.c_str());
|
||||
|
@ -133,7 +133,7 @@ TEST(Filenames, Absolute) {
|
|||
|
||||
h.AddLine(1, 1, 1, 0, 0);
|
||||
|
||||
vector<Module::File *> files;
|
||||
vector<Module::File*> files;
|
||||
m.GetFiles(&files);
|
||||
ASSERT_EQ(1U, files.size());
|
||||
EXPECT_STREQ("/absolute", files[0]->name.c_str());
|
||||
|
@ -151,7 +151,7 @@ TEST(Filenames, Relative) {
|
|||
|
||||
h.AddLine(1, 1, 1, 0, 0);
|
||||
|
||||
vector<Module::File *> files;
|
||||
vector<Module::File*> files;
|
||||
m.GetFiles(&files);
|
||||
ASSERT_EQ(1U, files.size());
|
||||
EXPECT_STREQ("/directory1/relative", files[0]->name.c_str());
|
||||
|
|
|
@ -51,7 +51,7 @@ void DwarfRangeListHandler::SetBaseAddress(uint64_t base_address) {
|
|||
|
||||
void DwarfRangeListHandler::Finish() {
|
||||
std::sort(ranges_->begin(), ranges_->end(),
|
||||
[](const Module::Range &a, const Module::Range &b) {
|
||||
[](const Module::Range& a, const Module::Range& b) {
|
||||
return a.address < b.address;
|
||||
}
|
||||
);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue