process-cpp
3.0.0
A simple convenience library for handling processes in C++11.
|
Go to the documentation of this file.
29 std::tuple<std::string, bool>
demangle(
const std::string& symbol)
32 auto result = abi::__cxa_demangle(symbol.c_str(),
37 if (!result || status != 0)
39 return std::make_tuple(std::string(),
false);
42 std::string s{result};
45 return std::make_tuple(s,
true);
50 struct Symbol :
public bt::Frame::Symbol
54 auto first =
raw_.find_first_of(
"(");
55 auto last =
raw_.find_last_of(
")");
57 if (first != std::string::npos && last != std::string::npos)
59 auto mangled_symbol =
raw_.substr(first+1,
60 (last-1) - (first+1));
62 auto plus = mangled_symbol.find_first_of(
"+");
63 if (plus != std::string::npos)
64 mangled_symbol.erase(plus);
82 std::string
raw()
const
120 std::shared_ptr<bt::Frame::Symbol> bt::Frame::Symbol::for_testing_from_raw_symbol(
const char* symbol)
127 static const unsigned int max_frames=64;
128 void *frames[max_frames];
130 auto frame_count = ::backtrace(frames, max_frames);
131 auto symbols = ::backtrace_symbols(frames, frame_count);
135 Scope(
char** symbols) : symbols(symbols)
144 char** symbols =
nullptr;
147 for (
int i = 0; i < frame_count; i++)
The Frame class models an individual frame of a backtrace.
std::string demangled() const
const Symbol & symbol() const
symbol returns the symbolic representation of this frame.
usr lib ccache c g O2 fdebug prefix Bsymbolic functions relro rdynamic CMakeFiles cross_process_sync_test dir cross_process_sync_test cpp o o cross_process_sync_test rpath
std::tuple< std::string, bool > demangle(const std::string &symbol)
CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string &fn, const std::vector< std::string > &argv, const std::map< std::string, std::string > &env, const StandardStream &flags)
exec execve's the executable with the provided arguments and environment.
std::size_t depth() const
depth returns the depth of this frame in the overall backtrace.
CORE_POSIX_DLL_PUBLIC ChildProcess fork(const std::function< posix::exit::Status()> &main, const StandardStream &flags)
fork forks a new process and executes the provided main function in the newly forked process.
Symbol(const char *symbol)
usr lib ccache c fPIC g O2 fdebug prefix version build process cpp ubports20 symbols map Bsymbolic functions z
std::function< bool(const Frame &frame)> FrameHandler
FrameHandler is the functor invoked for every frame of a backtrace.
virtual void * frame_pointer() const
frame_pointer returns the the raw frame pointer of this frame.
usr lib ccache c fPIC g O2 fdebug prefix map
Frame(std::size_t depth, void *frame_pointer, const char *symbol)
usr lib ccache c fPIC g O2 fdebug prefix version build process cpp ubports20 symbols map Wl
void visit_with_handler(const FrameHandler &handler)
visit_with_handler iterates the backtrace of the calling program, invoking the handler for every fram...
usr lib ccache c fPIC g O2 fdebug prefix version build process cpp ubports20 symbols map Bsymbolic functions relro no undefined shared soname
usr lib ccache c fPIC g O2 fdebug prefix version script
CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run(const std::function< core::posix::exit::Status()> &service, const std::function< core::posix::exit::Status()> &client)
Forks two processes for both the service and the client.