[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- StackID.cpp -------------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
#include "lldb/Target/StackID.h"
|
2010-08-31 02:11:35 +08:00
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
#include "lldb/Symbol/Symbol.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2010-08-31 02:11:35 +08:00
|
|
|
void StackID::Dump(Stream *s) {
|
2014-04-04 12:06:10 +08:00
|
|
|
s->Printf("StackID (pc = 0x%16.16" PRIx64 ", cfa = 0x%16.16" PRIx64
|
|
|
|
", symbol_scope = %p",
|
|
|
|
m_pc, m_cfa, static_cast<void *>(m_symbol_scope));
|
2010-08-31 02:11:35 +08:00
|
|
|
if (m_symbol_scope) {
|
|
|
|
SymbolContext sc;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-08-31 02:11:35 +08:00
|
|
|
m_symbol_scope->CalculateSymbolContext(&sc);
|
|
|
|
if (sc.block)
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf(" (Block {0x%8.8" PRIx64 "})", sc.block->GetID());
|
2010-08-31 02:11:35 +08:00
|
|
|
else if (sc.symbol)
|
|
|
|
s->Printf(" (Symbol{0x%8.8x})", sc.symbol->GetID());
|
|
|
|
}
|
|
|
|
s->PutCString(") ");
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool lldb_private::operator==(const StackID &lhs, const StackID &rhs) {
|
2010-09-03 05:44:10 +08:00
|
|
|
if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-03 05:44:10 +08:00
|
|
|
SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
|
|
|
|
SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
|
|
|
|
|
|
|
|
// Only compare the PC values if both symbol context scopes are nullptr
|
|
|
|
if (lhs_scope == nullptr && rhs_scope == nullptr)
|
|
|
|
return lhs.GetPC() == rhs.GetPC();
|
|
|
|
|
|
|
|
return lhs_scope == rhs_scope;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
|
2010-09-03 05:44:10 +08:00
|
|
|
if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
|
|
|
|
SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
|
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
if (lhs_scope == nullptr && rhs_scope == nullptr)
|
2010-09-03 05:44:10 +08:00
|
|
|
return lhs.GetPC() != rhs.GetPC();
|
|
|
|
|
|
|
|
return lhs_scope != rhs_scope;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool lldb_private::operator<(const StackID &lhs, const StackID &rhs) {
|
2010-09-03 05:44:10 +08:00
|
|
|
const lldb::addr_t lhs_cfa = lhs.GetCallFrameAddress();
|
|
|
|
const lldb::addr_t rhs_cfa = rhs.GetCallFrameAddress();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-01 08:50:50 +08:00
|
|
|
// FIXME: We are assuming that the stacks grow downward in memory. That's not
|
|
|
|
// necessary, but true on
|
|
|
|
// all the machines we care about at present. If this changes, we'll have to
|
2018-05-01 00:49:04 +08:00
|
|
|
// deal with that. The ABI is the agent who knows this ordering, but the
|
|
|
|
// StackID has no access to the ABI. The most straightforward way to handle
|
|
|
|
// this is to add a "m_grows_downward" bool to the StackID, and set it in the
|
|
|
|
// constructor. But I'm not going to waste a bool per StackID on this till we
|
|
|
|
// need it.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-03 05:44:10 +08:00
|
|
|
if (lhs_cfa != rhs_cfa)
|
|
|
|
return lhs_cfa < rhs_cfa;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-03 05:44:10 +08:00
|
|
|
SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
|
|
|
|
SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-19 02:52:47 +08:00
|
|
|
if (lhs_scope != nullptr && rhs_scope != nullptr) {
|
2010-09-03 05:44:10 +08:00
|
|
|
// Same exact scope, lhs is not less than (younger than rhs)
|
|
|
|
if (lhs_scope == rhs_scope)
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-03 05:44:10 +08:00
|
|
|
SymbolContext lhs_sc;
|
|
|
|
SymbolContext rhs_sc;
|
|
|
|
lhs_scope->CalculateSymbolContext(&lhs_sc);
|
|
|
|
rhs_scope->CalculateSymbolContext(&rhs_sc);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-03 05:44:10 +08:00
|
|
|
// Items with the same function can only be compared
|
|
|
|
if (lhs_sc.function == rhs_sc.function && lhs_sc.function != nullptr &&
|
2016-02-19 02:52:47 +08:00
|
|
|
lhs_sc.block != nullptr && rhs_sc.function != nullptr &&
|
|
|
|
rhs_sc.block != nullptr) {
|
2010-09-03 05:44:10 +08:00
|
|
|
return rhs_sc.block->Contains(lhs_sc.block);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-09-03 05:44:10 +08:00
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|