Skip to content

Commit

Permalink
Merge pull request #96 from cblichmann:v12-absl-log
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 478980451
Change-Id: Ib1ef896924b7f6f44389e99bb0df39c81fc251c7
  • Loading branch information
Copybara-Service committed Oct 5, 2022
2 parents 522e529 + 7d54b3b commit 74a9b8c
Show file tree
Hide file tree
Showing 39 changed files with 100 additions and 247 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Expand Up @@ -122,8 +122,11 @@ add_library(binexport_shared STATIC
)
target_link_libraries(binexport_shared PUBLIC
absl::bad_optional_access
absl::check
absl::flat_hash_map
absl::flat_hash_set
absl::log
absl::log_initialize
absl::optional
absl::status
absl::statusor
Expand Down Expand Up @@ -238,11 +241,13 @@ add_library(binexport_core
target_link_libraries(binexport_core PUBLIC
absl::bad_optional_access
absl::btree
absl::check
absl::flat_hash_map
absl::flat_hash_set
absl::hash
absl::node_hash_map
absl::node_hash_set
absl::log
absl::optional
absl::strings
absl::time
Expand Down Expand Up @@ -270,7 +275,9 @@ add_library(binexport_reader STATIC
reader/instruction.h
)
target_link_libraries(binexport_reader PUBLIC
absl::check
absl::inlined_vector
absl::log
absl::strings
binexport_shared
)
Expand Down
2 changes: 2 additions & 0 deletions binaryninja/CMakeLists.txt
Expand Up @@ -19,6 +19,8 @@ add_library(${binexport_bn_plugin_name} SHARED
log_sink.h
)
target_link_libraries(${binexport_bn_plugin_name} PRIVATE
absl::log
absl::log_initialize
absl::status
absl::statusor
absl::strings
Expand Down
3 changes: 1 addition & 2 deletions binaryninja/log_sink.cc
Expand Up @@ -18,14 +18,13 @@
#include "binaryninjaapi.h" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/base/log_severity.h"
#include "third_party/absl/strings/string_view.h"
#include "third_party/zynamics/binexport/util/logging.h"

namespace security::binexport {

void BinaryNinjaLogSink::Send(const not_absl::LogEntry& entry) {
void BinaryNinjaLogSink::Send(const absl::LogEntry& entry) {
BNLogLevel level;
switch (entry.log_severity()) {
case absl::LogSeverity::kInfo:
Expand Down
8 changes: 4 additions & 4 deletions binaryninja/log_sink.h
Expand Up @@ -15,14 +15,14 @@
#ifndef BINARYNINJA_LOG_SINK_H_
#define BINARYNINJA_LOG_SINK_H_

#include "base/logging.h"
#include "third_party/absl/log/log_sink.h"
#include "third_party/zynamics/binexport/util/logging.h"

namespace security::binexport {

class BinaryNinjaLogSink : public not_absl::LogSink {
public:
void Send(const not_absl::LogEntry& entry) override;
class BinaryNinjaLogSink : public absl::LogSink {
private:
void Send(const absl::LogEntry& entry) override;
};

} // namespace security::binexport
Expand Down
2 changes: 1 addition & 1 deletion binaryninja/main_plugin.cc
Expand Up @@ -17,7 +17,7 @@
#include <cstdint>
#include <string>

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/status/status.h"
#include "third_party/absl/status/statusor.h"
#include "third_party/absl/strings/escaping.h"
Expand Down
4 changes: 3 additions & 1 deletion binexport.cc
Expand Up @@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "base/logging.h"
#include "third_party/zynamics/binexport/binexport.h"

#include "third_party/absl/log/check.h"
#include "third_party/absl/log/log.h"

namespace security::binexport {

Address GetInstructionAddress(const BinExport2& proto, int index) {
Expand Down
3 changes: 2 additions & 1 deletion binexport2_writer.cc
Expand Up @@ -36,8 +36,9 @@
#include <locale>
#include <string>

#include "base/logging.h"
#include "third_party/absl/container/flat_hash_map.h"
#include "third_party/absl/log/check.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/absl/strings/string_view.h"
#include "third_party/absl/time/clock.h"
Expand Down
2 changes: 1 addition & 1 deletion comment.cc
Expand Up @@ -14,7 +14,7 @@

#include "third_party/zynamics/binexport/comment.h"

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/util/format.h"

Expand Down
2 changes: 1 addition & 1 deletion edge.cc
Expand Up @@ -16,7 +16,7 @@

#include <functional>

#include "base/logging.h"
#include "third_party/absl/log/log.h"

bool operator<(const FlowGraphEdge& one, const FlowGraphEdge& two) {
if (one.source == two.source) {
Expand Down
5 changes: 3 additions & 2 deletions entry_point.cc
Expand Up @@ -14,7 +14,7 @@

#include "third_party/zynamics/binexport/entry_point.h"

#include "base/logging.h"
#include "third_party/absl/log/log.h"

EntryPoint::EntryPoint(Address address, EntryPoint::Source source,
const int flags)
Expand Down Expand Up @@ -67,7 +67,8 @@ std::string EntryPoint::SourceToString() const {
case Source::GOLANG_TYPE_INFO:
return "GOLANG_TYPE_INFO";
default:
CHECK(false);
LOG(QFATAL) << "Invalid entry point source: "
<< static_cast<int>(source_);
return ""; // Not reached
}
}
Expand Down
2 changes: 1 addition & 1 deletion expression.cc
Expand Up @@ -16,7 +16,7 @@

#include <sstream>

#include "base/logging.h"
#include "third_party/absl/log/check.h"
#include "third_party/zynamics/binexport/instruction.h"
#include "third_party/zynamics/binexport/util/hash.h"

Expand Down
1 change: 0 additions & 1 deletion flow_analysis.cc
Expand Up @@ -19,7 +19,6 @@
#include <map>
#include <set>

#include "base/logging.h"
#include "third_party/zynamics/binexport/call_graph.h"
#include "third_party/zynamics/binexport/flow_graph.h"
#include "third_party/zynamics/binexport/virtual_memory.h"
Expand Down
3 changes: 2 additions & 1 deletion flow_graph.cc
Expand Up @@ -21,8 +21,9 @@
#include <stack>
#include <unordered_map>

#include "base/logging.h"
#include "third_party/absl/container/flat_hash_set.h"
#include "third_party/absl/log/check.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/call_graph.h"
#include "third_party/zynamics/binexport/comment.h"
Expand Down
10 changes: 5 additions & 5 deletions function.cc
Expand Up @@ -14,16 +14,16 @@

#include "third_party/zynamics/binexport/function.h"

#include <cinttypes>
#include <iomanip>
#include <iostream>

#include <boost/graph/compressed_sparse_row_graph.hpp> // NOLINT
#include <boost/graph/dominator_tree.hpp> // NOLINT
#include <boost/graph/filtered_graph.hpp> // NOLINT
#include <boost/graph/iteration_macros.hpp> // NOLINT
#include <cinttypes>
#include <iomanip>
#include <iostream>

#include "base/logging.h"
#include "third_party/absl/log/check.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/ascii.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/call_graph.h"
Expand Down
2 changes: 2 additions & 0 deletions ida/CMakeLists.txt
Expand Up @@ -55,6 +55,8 @@ ida_target_link_libraries(${binexport_ida_plugin_name}
absl::flat_hash_map
absl::flat_hash_set
absl::hash
absl::log
absl::log_initialize
absl::node_hash_map
absl::node_hash_set
absl::optional
Expand Down
2 changes: 1 addition & 1 deletion ida/arm.cc
Expand Up @@ -26,7 +26,7 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/ida/names.h"
#include "third_party/zynamics/binexport/util/format.h"
Expand Down
4 changes: 2 additions & 2 deletions ida/begin_idasdk.inc
Expand Up @@ -45,9 +45,9 @@
#pragma clang diagnostic ignored "-Wvarargs"
#elif __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op-parentheses"
#pragma GCC diagnostic ignored "-Wlogical-not-parentheses"
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#pragma GCC diagnostic ignored "-Wnullability-completeness"
#pragma GCC diagnostic ignored "-Wnonnull"
#pragma GCC diagnostic ignored "-Wvarargs"
#elif _MSC_VER
#pragma warning(push)
Expand Down
2 changes: 1 addition & 1 deletion ida/dalvik.cc
Expand Up @@ -30,7 +30,7 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/ida/names.h"
#include "third_party/zynamics/binexport/util/format.h"
Expand Down
2 changes: 1 addition & 1 deletion ida/flow_analysis.cc
Expand Up @@ -30,7 +30,7 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/flow_analysis.h"
#include "third_party/zynamics/binexport/ida/arm.h"
Expand Down
9 changes: 4 additions & 5 deletions ida/log_sink.cc
Expand Up @@ -22,18 +22,17 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/strings/string_view.h"
#include "third_party/zynamics/binexport/util/logging.h"

namespace security::binexport {

void IdaLogSink::Send(const not_absl::LogEntry& entry) {
auto message = entry.text_message();
void IdaLogSink::Send(const absl::LogEntry& entry) {
auto message = entry.text_message_with_newline();
// Output up to 8K of log data (including the new line).
// Note: msg() and vmsg() are thread-safe.
msg("%.*s\n",
static_cast<int>(std::clamp(message.size(), size_t(0), size_t(8191))),
msg("%.*s",
static_cast<int>(std::clamp(message.size(), size_t(0), size_t(8192))),
message.data());
}

Expand Down
8 changes: 4 additions & 4 deletions ida/log_sink.h
Expand Up @@ -15,14 +15,14 @@
#ifndef IDA_LOG_SINK_H_
#define IDA_LOG_SINK_H_

#include "base/logging.h"
#include "third_party/absl/log/log_sink.h"
#include "third_party/zynamics/binexport/util/logging.h"

namespace security::binexport {

class IdaLogSink : public not_absl::LogSink {
public:
void Send(const not_absl::LogEntry& entry) override;
class IdaLogSink : public absl::LogSink {
private:
void Send(const absl::LogEntry& entry) override;
};

} // namespace security::binexport
Expand Down
2 changes: 1 addition & 1 deletion ida/main_plugin.cc
Expand Up @@ -25,8 +25,8 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/base/attributes.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/memory/memory.h"
#include "third_party/absl/strings/ascii.h"
#include "third_party/absl/strings/escaping.h"
Expand Down
2 changes: 1 addition & 1 deletion ida/metapc.cc
Expand Up @@ -27,7 +27,7 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/base_types.h"
#include "third_party/zynamics/binexport/call_graph.h"
Expand Down
2 changes: 1 addition & 1 deletion ida/mips.cc
Expand Up @@ -27,7 +27,7 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/call_graph.h"
#include "third_party/zynamics/binexport/ida/names.h"
Expand Down
2 changes: 1 addition & 1 deletion ida/names.cc
Expand Up @@ -38,8 +38,8 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/container/btree_map.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/ascii.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/absl/time/time.h"
Expand Down
2 changes: 1 addition & 1 deletion ida/ppc.cc
Expand Up @@ -26,7 +26,7 @@
#include "third_party/zynamics/binexport/ida/end_idasdk.inc" // NOLINT
// clang-format on

#include "base/logging.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/call_graph.h"
#include "third_party/zynamics/binexport/ida/names.h"
Expand Down
3 changes: 2 additions & 1 deletion instruction.cc
Expand Up @@ -22,7 +22,8 @@
#include <sstream>
#include <tuple>

#include "base/logging.h"
#include "third_party/absl/log/check.h"
#include "third_party/absl/log/log.h"
#include "third_party/zynamics/binexport/flow_graph.h"
#include "third_party/zynamics/binexport/virtual_memory.h"

Expand Down
2 changes: 1 addition & 1 deletion library_manager.cc
Expand Up @@ -14,7 +14,7 @@

#include "third_party/zynamics/binexport/library_manager.h"

#include "base/logging.h"
#include "third_party/absl/log/check.h"

int LibraryManager::AddKnownLibrary(const std::string& library_name,
Linkage linkage) {
Expand Down
3 changes: 1 addition & 2 deletions operand.cc
Expand Up @@ -15,9 +15,8 @@
#include "third_party/zynamics/binexport/operand.h"

#include <iterator>
#include <sstream>

#include "base/logging.h"
#include "third_party/absl/log/check.h"

Expressions Operand::expressions_;
Operand::OperandCache Operand::operand_cache_;
Expand Down
2 changes: 1 addition & 1 deletion reader/call_graph.cc
Expand Up @@ -18,7 +18,7 @@
#include <utility>
#include <vector>

#include "base/logging.h"
#include "third_party/absl/log/check.h"
#include "third_party/absl/memory/memory.h"
#include "third_party/absl/strings/str_cat.h"
#include "third_party/zynamics/binexport/reader/graph_utility.h"
Expand Down
1 change: 0 additions & 1 deletion reader/call_graph_test.cc
Expand Up @@ -16,7 +16,6 @@

#include "third_party/zynamics/binexport/reader/call_graph.h"

#include "base/logging.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "third_party/absl/strings/str_cat.h"
Expand Down
3 changes: 2 additions & 1 deletion reader/flow_graph.cc
Expand Up @@ -20,7 +20,8 @@
#include <string>
#include <vector>

#include "base/logging.h"
#include "third_party/absl/log/check.h"
#include "third_party/absl/log/log.h"
#include "third_party/absl/memory/memory.h"
#include "third_party/zynamics/binexport/reader/graph_utility.h"
#include "third_party/zynamics/binexport/util/types.h"
Expand Down

0 comments on commit 74a9b8c

Please sign in to comment.