[kernel] Add debug names to processes

To make debugging easier, add names to processes. These are arbitrary
and supplied by the caller of process_create. The max is 31 characters
in debug configuration, and 0 in release.
This commit is contained in:
Justin C. Miller
2024-08-12 19:40:20 -07:00
parent ee24ec8d5c
commit d3c1d6cc34
8 changed files with 104 additions and 26 deletions

View File

@@ -13,6 +13,14 @@
namespace obj {
static constexpr bool __use_process_names =
#ifdef __jsix_config_debug
true;
#else
false;
#endif
class process :
public kobject
{
@@ -32,7 +40,7 @@ public:
static constexpr kobject::type type = kobject::type::process;
/// Constructor.
process();
process(const char *name);
/// Destructor.
virtual ~process();
@@ -47,6 +55,9 @@ public:
/// Get the process' virtual memory space
vm_space & space() { return m_space; }
/// Get the debugging name of the process
const char *name() { if constexpr(__use_process_names) return m_name; else return nullptr; }
/// Create a new thread in this process
/// \args rsp3 If non-zero, sets the ring3 stack pointer to this value
/// \args priority The new thread's scheduling priority
@@ -107,6 +118,15 @@ private:
enum class state : uint8_t { running, exited };
state m_state;
static constexpr size_t max_name_len =
#ifdef __jsix_config_debug
32;
#else
0;
#endif
char m_name[max_name_len];
};
} // namespace obj