/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// DWARF record parser
-#ifndef FOLLY_EXPERIMENTAL_SYMBOLIZER_DWARF_H_
-#define FOLLY_EXPERIMENTAL_SYMBOLIZER_DWARF_H_
+#pragma once
#include <boost/variant.hpp>
-#include "folly/experimental/symbolizer/Elf.h"
-#include "folly/Range.h"
+#include <folly/experimental/symbolizer/Elf.h>
+#include <folly/Range.h>
namespace folly {
namespace symbolizer {
* actually support many of the version 4 features (such as VLIW, multiple
* operations per instruction)
*
- * Note that the DWARF record parser does not allocate heap memory at all
- * during normal operation (it might in the error case, as throwing exceptions
- * uses the heap). This is on purpose: you can use the parser from
+ * Note that the DWARF record parser does not allocate heap memory at all.
+ * This is on purpose: you can use the parser from
* memory-constrained situations (such as an exception handler for
* std::out_of_memory) If it weren't for this requirement, some things would
* be much simpler: the Path class would be unnecessary and would be replaced
folly::StringPiece file_;
};
- struct LocationInfo {
- LocationInfo() : hasMainFile(false), hasFileAndLine(false), line(0) { }
+ enum class LocationInfoMode {
+ // Don't resolve location info.
+ DISABLED,
+ // Perform CU lookup using .debug_aranges (might be incomplete).
+ FAST,
+ // Scan all CU in .debug_info (slow!) on .debug_aranges lookup failure.
+ FULL,
+ };
- bool hasMainFile;
+ struct LocationInfo {
+ bool hasMainFile = false;
Path mainFile;
- bool hasFileAndLine;
+ bool hasFileAndLine = false;
Path file;
- uint64_t line;
+ uint64_t line = 0;
};
- /** Find the file and line number information corresponding to address */
- bool findAddress(uintptr_t address, LocationInfo& info) const;
+ /**
+ * Find the file and line number information corresponding to address.
+ */
+ bool findAddress(uintptr_t address,
+ LocationInfo& info,
+ LocationInfoMode mode) const;
private:
+ static bool findDebugInfoOffset(uintptr_t address,
+ StringPiece aranges,
+ uint64_t& offset);
+
void init();
+ bool findLocation(uintptr_t address,
+ StringPiece& infoEntry,
+ LocationInfo& info) const;
const ElfFile* elf_;
} // namespace symbolizer
} // namespace folly
-
-#endif /* FOLLY_EXPERIMENTAL_SYMBOLIZER_DWARF_H_ */
-