projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adds writer test case for RCU
[folly.git]
/
folly
/
experimental
/
symbolizer
/
ElfCache.h
diff --git
a/folly/experimental/symbolizer/ElfCache.h
b/folly/experimental/symbolizer/ElfCache.h
index 709babe93aaa0753edb76ddbe7555508081bdc88..572d7358c276fded398cd528eded46cd9765a82d 100644
(file)
--- a/
folly/experimental/symbolizer/ElfCache.h
+++ b/
folly/experimental/symbolizer/ElfCache.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
7
Facebook, Inc.
+ * Copyright 201
4-present
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-16,24
+16,25
@@
#pragma once
#pragma once
+#include <climits> // for PATH_MAX
#include <cstring>
#include <cstring>
-#include <limits.h> // for PATH_MAX
#include <memory>
#include <mutex>
#include <string>
#include <memory>
#include <mutex>
#include <string>
-#include <vector>
#include <unordered_map>
#include <unordered_map>
+#include <vector>
-#include <boost/operators.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/intrusive/list.hpp>
+#include <boost/operators.hpp>
#include <glog/logging.h>
#include <glog/logging.h>
-#include <folly/Hash.h>
#include <folly/Range.h>
#include <folly/experimental/symbolizer/Elf.h>
#include <folly/Range.h>
#include <folly/experimental/symbolizer/Elf.h>
+#include <folly/hash/Hash.h>
-namespace folly { namespace symbolizer {
+namespace folly {
+namespace symbolizer {
/**
* Number of ELF files loaded by the dynamic loader.
/**
* Number of ELF files loaded by the dynamic loader.
@@
-43,7
+44,7
@@
size_t countLoadedElfFiles();
class ElfCacheBase {
public:
virtual std::shared_ptr<ElfFile> getFile(StringPiece path) = 0;
class ElfCacheBase {
public:
virtual std::shared_ptr<ElfFile> getFile(StringPiece path) = 0;
- virtual ~ElfCacheBase() {
}
+ virtual ~ElfCacheBase() {}
};
/**
};
/**
@@
-70,9
+71,19
@@
class SignalSafeElfCache : public ElfCacheBase {
// own wrapper around a fixed-size, null-terminated string.
class Path : private boost::totally_ordered<Path> {
public:
// own wrapper around a fixed-size, null-terminated string.
class Path : private boost::totally_ordered<Path> {
public:
+ Path() {
+ assign(folly::StringPiece());
+ }
+
explicit Path(StringPiece s) {
explicit Path(StringPiece s) {
+ assign(s);
+ }
+
+ void assign(StringPiece s) {
DCHECK_LE(s.size(), kMaxSize);
DCHECK_LE(s.size(), kMaxSize);
- memcpy(data_, s.data(), s.size());
+ if (!s.empty()) {
+ memcpy(data_, s.data(), s.size());
+ }
data_[s.size()] = '\0';
}
data_[s.size()] = '\0';
}
@@
-94,6
+105,7
@@
class SignalSafeElfCache : public ElfCacheBase {
char data_[kMaxSize + 1];
};
char data_[kMaxSize + 1];
};
+ Path scratchpad_; // Preallocated key for map_ lookups.
boost::container::flat_map<Path, int> map_;
std::vector<std::shared_ptr<ElfFile>> slots_;
};
boost::container::flat_map<Path, int> map_;
std::vector<std::shared_ptr<ElfFile>> slots_;
};
@@
-128,8
+140,9
@@
class ElfCache : public ElfCacheBase {
typedef boost::intrusive::list<
Entry,
boost::intrusive::member_hook<Entry, LruLink, &Entry::lruLink>,
typedef boost::intrusive::list<
Entry,
boost::intrusive::member_hook<Entry, LruLink, &Entry::lruLink>,
- boost::intrusive::constant_time_size<false>> LruList;
+ boost::intrusive::constant_time_size<false>>
+ LruList;
LruList lruList_;
};
LruList lruList_;
};
-
-}
} // namespaces
+} // namespace symbolizer
+}
// namespace folly