Support external (i.e. user-defined) trace annotations (#195)

* Support external (i.e. user-defined) trace annotations

- tweaked the python examples to be more balanced
- updated the user-api example to conform to user API changes
- moved the get/set for State and ThreadState to state.{hpp,cpp}
- introduced user-provided trace annotations
- added perfetto python category
- moved coverage impl files around
- created enumerations for mapping category enums to category types
- created enumerations for mapping annotation type enums to annotation values
- moved tracing::add_perfetto_annotations to tracing/annotation.hpp
- utility make_index_sequence_range
- libomnitrace-dl: omnitrace_push_category_region
- libomnitrace-dl: omnitrace_pop_category_region
- libomnitrace-user: omnitrace_user_push_annotated_region
- libomnitrace-user: omnitrace_user_pop_annotated_region
- libpyomnitrace: support extra annotations via annotate_trace config value
  - filename
  - line
  - last attempted instr in bytecode (lasti)
  - argcount
  - num local variables
  - stacksize
- omnitrace-python: -a / --annotate-traces option

* tweak ubuntu-focal workflow

* Fix installation of omnitrace-user headers

* ubuntu-focal-codecov workflow update

- Install texinfo

* Update timemory submodule
This commit is contained in:
Jonathan R. Madsen
2022-11-11 07:31:14 -06:00
committad av GitHub
förälder 1b8f09aa2d
incheckning 642b6b95ca
40 ändrade filer med 1280 tillägg och 430 borttagningar
+87
Visa fil
@@ -21,9 +21,96 @@
// SOFTWARE.
#include "library/state.hpp"
#include "library/config.hpp"
#include "library/debug.hpp"
#include "library/utility.hpp"
#include <string>
namespace omnitrace
{
namespace
{
auto&
get_state_value()
{
static State _v{ State::PreInit };
return _v;
}
ThreadState&
get_thread_state_value()
{
static thread_local ThreadState _v{ ThreadState::Enabled };
return _v;
}
auto&
get_thread_state_history(int64_t _idx = utility::get_thread_index())
{
static auto _v = utility::get_filled_array<OMNITRACE_MAX_THREADS>(
[]() { return utility::get_reserved_vector<ThreadState>(32); });
return _v.at(_idx);
}
} // namespace
State
get_state()
{
return get_state_value();
}
ThreadState
get_thread_state()
{
return get_thread_state_value();
}
State
set_state(State _n)
{
OMNITRACE_CONDITIONAL_PRINT_F(get_debug_init(), "Setting state :: %s -> %s\n",
std::to_string(get_state()).c_str(),
std::to_string(_n).c_str());
// state should always be increased, not decreased
OMNITRACE_CI_BASIC_THROW(
_n < get_state(), "State is being assigned to a lesser value :: %s -> %s",
std::to_string(get_state()).c_str(), std::to_string(_n).c_str());
std::swap(get_state_value(), _n);
return _n;
}
ThreadState
set_thread_state(ThreadState _n)
{
std::swap(get_thread_state_value(), _n);
return _n;
}
ThreadState
push_thread_state(ThreadState _v)
{
if(get_thread_state() >= ThreadState::Completed) return get_thread_state();
return get_thread_state_history().emplace_back(set_thread_state(_v));
}
ThreadState
pop_thread_state()
{
if(get_thread_state() >= ThreadState::Completed) return get_thread_state();
auto& _hist = get_thread_state_history();
if(!_hist.empty())
{
set_thread_state(_hist.back());
_hist.pop_back();
}
return get_thread_state();
}
} // namespace omnitrace
namespace std
{
std::string