Skip to content

Commit

Permalink
Switch to standard integer types in base/trace_event/.
Browse files Browse the repository at this point in the history
BUG=138542
TBR=dsinclair@chromium.org

Review URL: https://codereview.chromium.org/1546033002

Cr-Commit-Position: refs/heads/master@{#366798}
  • Loading branch information
avi authored and Commit bot committed Dec 24, 2015
1 parent df8474b commit bd1ed05
Show file tree
Hide file tree
Showing 58 changed files with 224 additions and 102 deletions.
1 change: 1 addition & 0 deletions base/trace_event/heap_profiler_allocation_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_
#define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_

#include <stddef.h>
#include <stdint.h>

#include "base/base_export.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <iterator>

#include "base/memory/ref_counted.h"
Expand Down
1 change: 1 addition & 0 deletions base/trace_event/heap_profiler_allocation_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_REGISTER_H_
#define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_REGISTER_H_

#include <stddef.h>
#include <stdint.h>

#include "base/logging.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "base/trace_event/heap_profiler_allocation_register.h"

#include <stddef.h>
#include <sys/mman.h>
#include <unistd.h>

#include "base/basictypes.h"
#include "base/bits.h"
#include "base/logging.h"
#include "base/process/process_metrics.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "base/trace_event/heap_profiler_allocation_register.h"

#include <stddef.h>
#include <stdint.h>

#include "base/process/process_metrics.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down
1 change: 1 addition & 0 deletions base/trace_event/heap_profiler_allocation_register_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "base/trace_event/heap_profiler_allocation_register.h"

#include <windows.h>
#include <stddef.h>

#include "base/bits.h"
#include "base/logging.h"
Expand Down
3 changes: 3 additions & 0 deletions base/trace_event/heap_profiler_heap_dump_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/trace_event/heap_profiler_heap_dump_writer.h"

#include <stdint.h>

#include <algorithm>
#include <iterator>
#include <tuple>
Expand All @@ -12,6 +14,7 @@

#include "base/format_macros.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
#include "base/trace_event/heap_profiler_type_name_deduplicator.h"
Expand Down
2 changes: 2 additions & 0 deletions base/trace_event/heap_profiler_heap_dump_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef BASE_TRACE_EVENT_HEAP_PROFILER_HEAP_DUMP_WRITER_H_
#define BASE_TRACE_EVENT_HEAP_PROFILER_HEAP_DUMP_WRITER_H_

#include <stddef.h>

#include <set>

#include "base/base_export.h"
Expand Down
2 changes: 2 additions & 0 deletions base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <set>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions base/trace_event/heap_profiler_stack_frame_deduplicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"

#include <stddef.h>

#include <string>
#include <utility>

Expand Down
1 change: 1 addition & 0 deletions base/trace_event/heap_profiler_type_name_deduplicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "base/trace_event/heap_profiler_type_name_deduplicator.h"

#include <stddef.h>
#include <stdlib.h>
#include <string>
#include <utility>
Expand Down
1 change: 1 addition & 0 deletions base/trace_event/java_heap_dump_provider_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BASE_TRACE_EVENT_JAVA_HEAP_DUMP_PROVIDER_ANDROID_H_
#define BASE_TRACE_EVENT_JAVA_HEAP_DUMP_PROVIDER_ANDROID_H_

#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/trace_event/memory_dump_provider.h"

Expand Down
9 changes: 6 additions & 3 deletions base/trace_event/malloc_dump_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

#include "base/trace_event/malloc_dump_provider.h"

#include <stddef.h>

#include "base/allocator/allocator_extension.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"

#if defined(OS_MACOSX)
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif

#include "base/allocator/allocator_extension.h"
#include "base/trace_event/process_memory_dump.h"

namespace base {
namespace trace_event {

Expand Down
2 changes: 1 addition & 1 deletion base/trace_event/memory_allocator_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ MemoryAllocatorDump::~MemoryAllocatorDump() {

void MemoryAllocatorDump::AddScalar(const char* name,
const char* units,
uint64 value) {
uint64_t value) {
SStringPrintf(&string_conversion_buffer_, "%" PRIx64, value);
attributes_->BeginDictionary(name);
attributes_->SetString("type", kTypeScalar);
Expand Down
6 changes: 4 additions & 2 deletions base/trace_event/memory_allocator_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#ifndef BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_
#define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_H_

#include <stdint.h>

#include <string>

#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
#include "base/values.h"
Expand Down Expand Up @@ -51,7 +53,7 @@ class BASE_EXPORT MemoryAllocatorDump {
// AddScalar("number_of_freelist_entires", kUnitsObjects, 42)
// - Other informational column (will not be auto-added in the UI)
// AddScalarF("kittens_ratio", "ratio", 42.0f)
void AddScalar(const char* name, const char* units, uint64 value);
void AddScalar(const char* name, const char* units, uint64_t value);
void AddScalarF(const char* name, const char* units, double value);
void AddString(const char* name, const char* units, const std::string& value);

Expand Down
7 changes: 3 additions & 4 deletions base/trace_event/memory_allocator_dump_guid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ namespace base {
namespace trace_event {

namespace {
uint64 HashString(const std::string& str) {
uint64 hash[(kSHA1Length + sizeof(uint64) - 1) / sizeof(uint64)] = { 0 };
uint64_t HashString(const std::string& str) {
uint64_t hash[(kSHA1Length + sizeof(uint64_t) - 1) / sizeof(uint64_t)] = {0};
SHA1HashBytes(reinterpret_cast<const unsigned char*>(str.data()), str.size(),
reinterpret_cast<unsigned char*>(hash));
return hash[0];
}
} // namespace

MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64 guid) : guid_(guid) {
}
MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64_t guid) : guid_(guid) {}

MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid()
: MemoryAllocatorDumpGuid(0u) {
Expand Down
9 changes: 5 additions & 4 deletions base/trace_event/memory_allocator_dump_guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
#ifndef BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_
#define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_

#include <stdint.h>

#include <string>

#include "base/base_export.h"
#include "base/basictypes.h"

namespace base {
namespace trace_event {

class BASE_EXPORT MemoryAllocatorDumpGuid {
public:
MemoryAllocatorDumpGuid();
explicit MemoryAllocatorDumpGuid(uint64 guid);
explicit MemoryAllocatorDumpGuid(uint64_t guid);

// Utility ctor to hash a GUID if the caller prefers a string. The caller
// still has to ensure that |guid_str| is unique, per snapshot, within the
// global scope of all the traced processes.
explicit MemoryAllocatorDumpGuid(const std::string& guid_str);

uint64 ToUint64() const { return guid_; }
uint64_t ToUint64() const { return guid_; }

// Returns a (hex-encoded) string representation of the guid.
std::string ToString() const;
Expand All @@ -39,7 +40,7 @@ class BASE_EXPORT MemoryAllocatorDumpGuid {
}

private:
uint64 guid_;
uint64_t guid_;

// Deliberately copy-able.
};
Expand Down
5 changes: 4 additions & 1 deletion base/trace_event/memory_allocator_dump_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/trace_event/memory_allocator_dump.h"

#include <stdint.h>

#include "base/format_macros.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
Expand All @@ -12,6 +14,7 @@
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event_argument.h"
#include "base/values.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
Expand Down Expand Up @@ -82,7 +85,7 @@ void CheckString(const MemoryAllocatorDump* dump,
void CheckScalar(const MemoryAllocatorDump* dump,
const std::string& name,
const char* expected_units,
uint64 expected_value) {
uint64_t expected_value) {
CheckString(dump, name, MemoryAllocatorDump::kTypeScalar, expected_units,
StringPrintf("%" PRIx64, expected_value));
}
Expand Down
3 changes: 3 additions & 0 deletions base/trace_event/memory_dump_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
#ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
#define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_

#include <stdint.h>

#include <map>
#include <memory>
#include <set>
#include <vector>

#include "base/atomicops.h"
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
Expand Down
10 changes: 6 additions & 4 deletions base/trace_event/memory_dump_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/trace_event/memory_dump_manager.h"

#include <stdint.h>

#include <vector>

#include "base/bind_helpers.h"
Expand Down Expand Up @@ -83,7 +85,7 @@ class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate {
void(const MemoryDumpRequestArgs& args,
const MemoryDumpCallback& callback));

uint64 GetTracingProcessId() const override {
uint64_t GetTracingProcessId() const override {
NOTREACHED();
return MemoryDumpManager::kInvalidTracingProcessId;
}
Expand Down Expand Up @@ -120,7 +122,7 @@ class MemoryDumpManagerTest : public testing::Test {
// result and taking care of posting the closure on the correct task runner.
void DumpCallbackAdapter(scoped_refptr<SingleThreadTaskRunner> task_runner,
Closure closure,
uint64 dump_guid,
uint64_t dump_guid,
bool success) {
last_callback_success_ = success;
task_runner->PostTask(FROM_HERE, closure);
Expand Down Expand Up @@ -373,15 +375,15 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
// iteration, one thread is removed, to check the live unregistration logic.
TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) {
InitializeMemoryDumpManager(false /* is_coordinator */);
const uint32 kNumInitialThreads = 8;
const uint32_t kNumInitialThreads = 8;

std::vector<scoped_ptr<Thread>> threads;
std::vector<scoped_ptr<MockMemoryDumpProvider>> mdps;

// Create the threads and setup the expectations. Given that at each iteration
// we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be
// invoked a number of times equal to its index.
for (uint32 i = kNumInitialThreads; i > 0; --i) {
for (uint32_t i = kNumInitialThreads; i > 0; --i) {
threads.push_back(make_scoped_ptr(new Thread("test thread")));
auto thread = threads.back().get();
thread->Start();
Expand Down
1 change: 1 addition & 0 deletions base/trace_event/process_memory_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/process/process_metrics.h"
#include "base/trace_event/process_memory_totals.h"
#include "base/trace_event/trace_event_argument.h"
#include "build/build_config.h"

#if defined(OS_POSIX)
#include <sys/mman.h>
Expand Down
4 changes: 4 additions & 0 deletions base/trace_event/process_memory_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
#ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
#define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_

#include <stddef.h>

#include <vector>

#include "base/base_export.h"
#include "base/containers/hash_tables.h"
#include "base/containers/small_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
#include "base/trace_event/memory_dump_session_state.h"
#include "base/trace_event/process_memory_maps.h"
#include "base/trace_event/process_memory_totals.h"
#include "build/build_config.h"

// Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the
// resident memory.
Expand Down
2 changes: 2 additions & 0 deletions base/trace_event/process_memory_dump_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/trace_event/process_memory_dump.h"

#include <stddef.h>

#include "base/memory/aligned_memory.h"
#include "base/process/process_metrics.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
Expand Down
6 changes: 3 additions & 3 deletions base/trace_event/process_memory_maps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace base {
namespace trace_event {

// static
const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsRead = 4;
const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite = 2;
const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsExec = 1;
const uint32_t ProcessMemoryMaps::VMRegion::kProtectionFlagsRead = 4;
const uint32_t ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite = 2;
const uint32_t ProcessMemoryMaps::VMRegion::kProtectionFlagsExec = 1;

ProcessMemoryMaps::VMRegion::VMRegion()
: start_address(0),
Expand Down
Loading

0 comments on commit bd1ed05

Please sign in to comment.