mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
Formatting
This commit is contained in:
parent
32152bf5cf
commit
3b752fde13
@ -206,7 +206,8 @@ void printFuncArg(const std::shared_ptr<FuncDesc::TargetObject>& funcObj) {
|
||||
printf(",");
|
||||
}
|
||||
const auto& location = funcArg->locator.locations[i];
|
||||
printf("{\"start\":\"0x%zx\",\"end\":\"0x%zx\",\"expr_size\":%zu,\"expr\":[",
|
||||
printf(
|
||||
"{\"start\":\"0x%zx\",\"end\":\"0x%zx\",\"expr_size\":%zu,\"expr\":[",
|
||||
location.start, location.end, location.expr_size);
|
||||
for (size_t j = 0; j < location.expr_size; j++) {
|
||||
if (j > 0) {
|
||||
|
@ -2,13 +2,12 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <span>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include <memory>
|
||||
#include <msgpack.hpp>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/options.h"
|
||||
@ -146,8 +145,8 @@ std::ostream &operator<<(std::ostream &os, const Node &node) {
|
||||
os << " Is typedef node: " << node.isTypedef << "\n";
|
||||
os << " Static size: " << node.staticSize << "\n";
|
||||
os << " Dynamic size: " << node.dynamicSize << "\n";
|
||||
os << " Padding savings: " <<
|
||||
(node.paddingSavingsSize ? *node.paddingSavingsSize : -1) << "\n";
|
||||
os << " Padding savings: "
|
||||
<< (node.paddingSavingsSize ? *node.paddingSavingsSize : -1) << "\n";
|
||||
if (node.containerStats) {
|
||||
const auto& stats = *node.containerStats;
|
||||
os << " Container stats:\n";
|
||||
@ -202,13 +201,19 @@ int main(int argc, const char **argv) {
|
||||
options.statistics = rocksdb::CreateDBStatistics();
|
||||
options.OptimizeForSmallDb();
|
||||
|
||||
auto close_db = [](rocksdb::DB *db) { if (db) db->Close(); };
|
||||
auto close_db = [](rocksdb::DB* db) {
|
||||
if (db)
|
||||
db->Close();
|
||||
};
|
||||
auto db = std::unique_ptr<rocksdb::DB, decltype(close_db)>{nullptr};
|
||||
|
||||
{ // Open the database, then safely store its pointer in a unique_ptr for lifetime management.
|
||||
{ // Open the database, then safely store its pointer in a unique_ptr for
|
||||
// lifetime management.
|
||||
rocksdb::DB* _db = nullptr;
|
||||
if (auto status = rocksdb::DB::Open(options, dbpath.string(), &_db); !status.ok()) {
|
||||
fprintf(stderr, "Failed to open DB '%s' with error %s\n", dbpath.string().c_str(), status.ToString().c_str());
|
||||
if (auto status = rocksdb::DB::Open(options, dbpath.string(), &_db);
|
||||
!status.ok()) {
|
||||
fprintf(stderr, "Failed to open DB '%s' with error %s\n",
|
||||
dbpath.string().c_str(), status.ToString().c_str());
|
||||
return 1;
|
||||
}
|
||||
db.reset(_db);
|
||||
@ -219,7 +224,8 @@ int main(int argc, const char **argv) {
|
||||
NodeID start = 0, end = 0;
|
||||
|
||||
// Parse the range into two integers; start and end.
|
||||
// If the range contains a single integer, that integer becomes the whole range.
|
||||
// If the range contains a single integer, that integer becomes the whole
|
||||
// range.
|
||||
if (const char* dash = std::strchr(range, '-')) {
|
||||
start = std::strtoul(range, nullptr, 10);
|
||||
end = std::strtoul(dash + 1, nullptr, 10);
|
||||
@ -231,22 +237,27 @@ int main(int argc, const char **argv) {
|
||||
// Print the contents of the nodes...
|
||||
for (NodeID id = start; id <= end; id++) {
|
||||
std::string data;
|
||||
if (auto status = db->Get(rocksdb::ReadOptions(), std::to_string(id), &data); !status.ok()) {
|
||||
if (auto status =
|
||||
db->Get(rocksdb::ReadOptions(), std::to_string(id), &data);
|
||||
!status.ok()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Nodes with ID < FIRST_NODE_ID are reserved for internal use.
|
||||
// We must display their corresponding type.
|
||||
// They have their own type, so we need to unpack and print them
|
||||
// appropriately.
|
||||
if (id == ROOT_NODE_ID) {
|
||||
DBHeader header;
|
||||
msgpack::unpack(data.data(), data.size()).get().convert(header);
|
||||
std::cout << header << "\n";
|
||||
} else if (id == ERROR_NODE_ID) {
|
||||
continue;
|
||||
} else {
|
||||
} else if (id >= FIRST_NODE_ID) {
|
||||
Node node;
|
||||
msgpack::unpack(data.data(), data.size()).get().convert(node);
|
||||
std::cout << node << "\n";
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user