Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d6d932a authored by Christopher Ferris's avatar Christopher Ferris Committed by Gerrit Code Review
Browse files

Merge "Remove assert, use CHECK instead."

parents e29a6cda 9416703f
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
@@ -76,17 +76,6 @@ cc_library {
    defaults: ["libunwindstack_common"],
}

cc_library {
    name: "libunwindstack_debug",
    defaults: ["libunwindstack_common"],

    cflags: [
        "-UNDEBUG",
        "-O0",
        "-g",
    ],
}

//-------------------------------------------------------------------------
// Unit Tests
//-------------------------------------------------------------------------
@@ -160,21 +149,6 @@ cc_test {
    ],
}

// These unit tests run against the static debug library.
cc_test {
    name: "libunwindstack_test_debug",
    defaults: ["libunwindstack_test_common"],

    static_libs: [
        "libunwindstack_debug",
    ],

    data: [
        "tests/elf32.xz",
        "tests/elf64.xz",
    ],
}

//-------------------------------------------------------------------------
// Utility Executables
//-------------------------------------------------------------------------
+10 −10
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 * limitations under the License.
 */

#include <assert.h>
#include <stdint.h>

#include <deque>
@@ -23,6 +22,7 @@
#include <android-base/stringprintf.h>

#include "ArmExidx.h"
#include "Check.h"
#include "Log.h"
#include "Machine.h"
#include "Memory.h"
@@ -173,7 +173,7 @@ inline bool ArmExidx::GetByte(uint8_t* byte) {
}

inline bool ArmExidx::DecodePrefix_10_00(uint8_t byte) {
  assert((byte >> 4) == 0x8);
  CHECK((byte >> 4) == 0x8);

  uint16_t registers = (byte & 0xf) << 8;
  if (!GetByte(&byte)) {
@@ -232,7 +232,7 @@ inline bool ArmExidx::DecodePrefix_10_00(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_10_01(uint8_t byte) {
  assert((byte >> 4) == 0x9);
  CHECK((byte >> 4) == 0x9);

  uint8_t bits = byte & 0xf;
  if (bits == 13 || bits == 15) {
@@ -258,7 +258,7 @@ inline bool ArmExidx::DecodePrefix_10_01(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_10_10(uint8_t byte) {
  assert((byte >> 4) == 0xa);
  CHECK((byte >> 4) == 0xa);

  // 10100nnn: Pop r4-r[4+nnn]
  // 10101nnn: Pop r4-r[4+nnn], r14
@@ -419,7 +419,7 @@ inline bool ArmExidx::DecodePrefix_10_11_01nn() {
}

inline bool ArmExidx::DecodePrefix_10_11_1nnn(uint8_t byte) {
  assert((byte & ~0x07) == 0xb8);
  CHECK((byte & ~0x07) == 0xb8);

  // 10111nnn: Pop VFP double-precision registers D[8]-D[8+nnn] by FSTMFDX
  if (log_) {
@@ -439,7 +439,7 @@ inline bool ArmExidx::DecodePrefix_10_11_1nnn(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_10(uint8_t byte) {
  assert((byte >> 6) == 0x2);
  CHECK((byte >> 6) == 0x2);

  switch ((byte >> 4) & 0x3) {
  case 0:
@@ -469,7 +469,7 @@ inline bool ArmExidx::DecodePrefix_10(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_11_000(uint8_t byte) {
  assert((byte & ~0x07) == 0xc0);
  CHECK((byte & ~0x07) == 0xc0);

  uint8_t bits = byte & 0x7;
  if (bits == 6) {
@@ -550,7 +550,7 @@ inline bool ArmExidx::DecodePrefix_11_000(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_11_001(uint8_t byte) {
  assert((byte & ~0x07) == 0xc8);
  CHECK((byte & ~0x07) == 0xc8);

  uint8_t bits = byte & 0x7;
  if (bits == 0) {
@@ -605,7 +605,7 @@ inline bool ArmExidx::DecodePrefix_11_001(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_11_010(uint8_t byte) {
  assert((byte & ~0x07) == 0xd0);
  CHECK((byte & ~0x07) == 0xd0);

  // 11010nnn: Pop VFP double precision registers D[8]-D[8+nnn] by VPUSH
  if (log_) {
@@ -624,7 +624,7 @@ inline bool ArmExidx::DecodePrefix_11_010(uint8_t byte) {
}

inline bool ArmExidx::DecodePrefix_11(uint8_t byte) {
  assert((byte >> 6) == 0x3);
  CHECK((byte >> 6) == 0x3);

  switch ((byte >> 3) & 0x7) {
  case 0:

libunwindstack/Check.h

0 → 100644
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _LIBUNWINDSTACK_ERROR_H
#define _LIBUNWINDSTACK_ERROR_H

#include <stdlib.h>

#include "Log.h"

#define CHECK(assertion)                                   \
  if (__builtin_expect(!(assertion), false)) {             \
    log(0, "%s:%d: %s\n", __FILE__, __LINE__, #assertion); \
    abort();                                               \
  }

#endif  // _LIBUNWINDSTACK_ERROR_H
+4 −4
Original line number Diff line number Diff line
@@ -14,9 +14,9 @@
 * limitations under the License.
 */

#include <assert.h>
#include <stdint.h>

#include "Check.h"
#include "DwarfEhFrame.h"
#include "DwarfMemory.h"
#include "DwarfSection.h"
@@ -105,8 +105,8 @@ const typename DwarfEhFrame<AddressType>::FdeInfo* DwarfEhFrame<AddressType>::Ge
template <typename AddressType>
bool DwarfEhFrame<AddressType>::GetFdeOffsetBinary(uint64_t pc, uint64_t* fde_offset,
                                                   uint64_t total_entries) {
  assert(fde_count_ > 0);
  assert(total_entries <= fde_count_);
  CHECK(fde_count_ > 0);
  CHECK(total_entries <= fde_count_);

  size_t first = 0;
  size_t last = total_entries;
@@ -133,7 +133,7 @@ bool DwarfEhFrame<AddressType>::GetFdeOffsetBinary(uint64_t pc, uint64_t* fde_of

template <typename AddressType>
bool DwarfEhFrame<AddressType>::GetFdeOffsetSequential(uint64_t pc, uint64_t* fde_offset) {
  assert(fde_count_ != 0);
  CHECK(fde_count_ != 0);
  last_error_ = DWARF_ERROR_NONE;
  // We can do a binary search if the pc is in the range of the elements
  // that have already been cached.
+3 −3
Original line number Diff line number Diff line
@@ -14,11 +14,11 @@
 * limitations under the License.
 */

#include <assert.h>
#include <stdint.h>

#include <string>

#include "Check.h"
#include "DwarfEncoding.h"
#include "DwarfMemory.h"
#include "Memory.h"
@@ -100,8 +100,8 @@ size_t DwarfMemory::GetEncodedSize(uint8_t encoding) {
}

bool DwarfMemory::AdjustEncodedValue(uint8_t encoding, uint64_t* value) {
  assert((encoding & 0x0f) == 0);
  assert(encoding != DW_EH_PE_aligned);
  CHECK((encoding & 0x0f) == 0);
  CHECK(encoding != DW_EH_PE_aligned);

  // Handle the encoding.
  switch (encoding) {
Loading