Add a function to dump the actor call backtrace to stdout

This commit is contained in:
Xiaoge Su
2023-09-26 18:03:05 -07:00
parent b5e40c5598
commit ba264a26cc
3 changed files with 41 additions and 2 deletions

View File

@@ -81,6 +81,38 @@ enum class ActorContextDumpType : uint8_t {
`FULL_CONTEXT` will dump *all* running actors, while `CURRENT_CALL_BACKTRACE` will dump the call backtrace of the current running actor. `CURRENT_STACK` is not as helpful since it will dump the current call stack and is for debugging purposes only. The result will be encoded in `base64` format and returned as a `std::string` object. The object can be consumed by `bin/acac`.
### Dump the actor call backtrace in debugger
It is possible to dump the encoded actor call backtrace within `gdb` or `lldb` via `dumpActorCallBacktrace()`, e.g.,
```
(lldb) p dumpActorCallBacktrace()
AsfmEwAAAAAACQAAAMfmEwAAAAAAAM2oiSx71iIAGrSuCzh6ICZdEwAAAAAAJl0TAAAAAAAA
xtSlzYb4jwDwjH12k/QMyyITAAAAAADLIhMAAAAAAAB494CVpeUhADemI+QonWM4IgAAAAAA
ADgiAAAAAAAAABGOhIZwfcMAYcMZsUHF4yoiAAAAAAAAKiIAAAAAAAAAZ0OdsC0dMwBDhOSw
qDHU7CAAAAAAAADsIAAAAAAAAAD/+N1Ch/X3AEwORpyq68Y8AAAAAAAAADwAAAAAAAAAAEqD
W3c/M9kAHCBUzBTlojsAAAAAAAAAOwAAAAAAAAAA+uRVDFla0gA5DXKp8yQbCgAAAAAAAAAK
AAAAAAAAAADwo2kloY1WAKDXp1f+BrgAAAAAAAAAAA==
```
```bash
# echo "AsfmEwAAAAAACQAAAMfmEwAAAAAAAM2oiSx71iIAGrSuCzh6ICZdEwAAAAAAJl0TAAAAAAAA
\ xtSlzYb4jwDwjH12k/QMyyITAAAAAADLIhMAAAAAAAB494CVpeUhADemI+QonWM4IgAAAAAA
\ ADgiAAAAAAAAABGOhIZwfcMAYcMZsUHF4yoiAAAAAAAAKiIAAAAAAAAAZ0OdsC0dMwBDhOSw
\ qDHU7CAAAAAAAADsIAAAAAAAAAD/+N1Ch/X3AEwORpyq68Y8AAAAAAAAADwAAAAAAAAAAEqD
\ W3c/M9kAHCBUzBTlojsAAAAAAAAAOwAAAAAAAAAA+uRVDFla0gA5DXKp8yQbCgAAAAAAAAAK
\ AAAAAAAAAADwo2kloY1WAKDXp1f+BrgAAAAAAAAAAA=="|bin/acac
1304263 /root/src/fdbserver/workloads/FuzzApiCorrectness.actor.cpp:loadAndRun <ACTIVE>
1269030 /root/src/fdbserver/tester.actor.cpp:runWorkloadAsync
1254091 /root/src/fdbserver/tester.actor.cpp:testerServerWorkload
8760 /root/src/fdbserver/tester.actor.cpp:testerServerCore
8746 /root/src/fdbserver/worker.actor.cpp:workerServer
8428 /root/src/fdbserver/worker.actor.cpp:fdbd
60 /root/src/fdbserver/SimulatedCluster.actor.cpp:simulatedFDBDRebooter
59 /root/src/fdbserver/SimulatedCluster.actor.cpp:simulatedMachine
10 /root/src/fdbserver/SimulatedCluster.actor.cpp:simulationSetupAndRun
```
## Implementation Details
<TODO>

View File

@@ -3,6 +3,7 @@
#ifdef WITH_ACAC
#include <iomanip>
#include <iostream>
#include <mutex>
#include "flow/flow.h"
@@ -121,6 +122,11 @@ std::vector<ActiveActor> getCallBacktraceOfActor(const ActorID& actorID) {
} // anonymous namespace
void dumpActorCallBacktrace() {
std::string backtrace = encodeActorContext(ActorContextDumpType::CURRENT_CALL_BACKTRACE);
std::cout << backtrace << std::endl;
}
std::string encodeActorContext(const ActorContextDumpType dumpType) {
BinaryWriter writer(Unversioned());
auto writeActorInfo = [&writer](const ActiveActor& actor) {

View File

@@ -26,8 +26,6 @@
#include <cstdint>
#include <memory>
#include <mutex>
#include <thread>
#include <unordered_map>
#include <vector>
#include "flow/FastAlloc.h"
@@ -96,6 +94,9 @@ enum class ActorContextDumpType : uint8_t {
// Encode the current actor context into a string
extern std::string encodeActorContext(const ActorContextDumpType dumpType = ActorContextDumpType::FULL_CONTEXT);
// Encode the current actor call backtrace
extern void dumpActorCallBacktrace();
struct DecodedActorContext {
struct ActorInfo {
ActorID id;