INTERFACE:
-#include "initcalls.h"
#include "l4_error.h"
-enum {
+enum Tbuf_entry_fixed
+{
Tbuf_unused = 0,
Tbuf_pf,
Tbuf_ipc,
Tbuf_ipc_trace,
Tbuf_ke,
Tbuf_ke_reg,
- Tbuf_exregs,
Tbuf_breakpoint,
- Tbuf_pf_res,
- Tbuf_preemption,
Tbuf_ke_bin,
Tbuf_dynentries,
class Syscall_frame;
class Trap_state;
class Tb_entry_formatter;
+class String_buffer;
struct Tb_log_table_entry
{
protected:
Mword _number; ///< event number
Address _ip; ///< instruction pointer
- Context const *_ctx; ///< Context
Unsigned64 _tsc; ///< time stamp counter
+ Context const *_ctx; ///< Context
Unsigned32 _pmc1; ///< performance counter value 1
Unsigned32 _pmc2; ///< performance counter value 2
Unsigned32 _kclock; ///< lower 32 bits of kernel clock
struct Tb_entry_empty : public Tb_entry
{
- unsigned print(int, char *) const { return 0; }
+ void print(String_buffer *) const {}
};
class Tb_entry_formatter
public:
typedef Tb_entry::Group_order Group_order;
- virtual unsigned print(Tb_entry const *e, int max, char *buf) const = 0;
+ virtual void print(String_buffer *, Tb_entry const *e) const = 0;
virtual Group_order has_partner(Tb_entry const *e) const = 0;
virtual Group_order is_pair(Tb_entry const *e, Tb_entry const *n) const = 0;
virtual Mword partner(Tb_entry const *e) const = 0;
class Tb_entry_formatter_t : public Tb_entry_formatter
{
public:
+ Tb_entry_formatter_t() {}
+
typedef T const *Const_ptr;
typedef T *Ptr;
- unsigned print(Tb_entry const *e, int max, char *buf) const
- { return static_cast<Const_ptr>(e)->print(max, buf); }
+ void print(String_buffer *buf, Tb_entry const *e) const
+ { static_cast<Const_ptr>(e)->print(buf); }
Group_order has_partner(Tb_entry const *e) const
{ return static_cast<Const_ptr>(e)->has_partner(); }
L4_timeout_pair _timeout; ///< timeout
public:
Tb_entry_ipc() : _timeout(0) {}
- unsigned print(int max, char *buf) const;
+ void print(String_buffer *buf) const;
};
/** logged ipc result. */
Unsigned8 _have_snd; ///< ipc had send part
Unsigned8 _is_np; ///< next period bit set
public:
- unsigned print(int max, char *buf) const;
+ void print(String_buffer *buf) const;
};
/** logged ipc for user level tracing with Vampir. */
Unsigned8 _snd_desc;
Unsigned8 _rcv_desc;
public:
- unsigned print(int max, char *buf) const;
+ void print(String_buffer *buf) const;
};
-#if 0
-/** logged short-cut ipc failed. */
-class Tb_entry_ipc_sfl : public Tb_entry_base
-{
-private:
- Global_id _from; ///< short ipc rcv descriptor
- L4_timeout_pair _timeout; ///< ipc timeout
- Global_id _dst; ///< partner
- Unsigned8 _is_irq, _snd_lst, _dst_ok, _dst_lck, _preempt;
-};
-#endif
/** logged pagefault. */
class Tb_entry_pf : public Tb_entry
Mword _error; ///< pagefault error code
Space *_space;
public:
- unsigned print(int max, char *buf) const;
+ void print(String_buffer *buf) const;
};
-/** pagefault result. */
-class Tb_entry_pf_res : public Tb_entry
+/** logged kernel event. */
+template<unsigned BASE_SIZE>
+union Tb_entry_msg
{
-private:
- Address _pfa;
- L4_error _err;
- L4_error _ret;
-public:
- unsigned print(int max, char *buf) const;
-};
+ char msg[Tb_entry::Tb_entry_size - BASE_SIZE];
+ struct Ptr
+ {
+ char tag[2];
+ char const *ptr;
+ } mptr;
+ void set_const(char const *msg)
+ {
+ mptr.tag[0] = 0;
+ mptr.tag[1] = 1;
+ mptr.ptr = msg;
+ }
-/** logged kernel event. */
-template<typename BASE, unsigned TAG>
-class Tb_entry_ke_t : public BASE
-{
-protected:
- union Msg
+ void set_buf(unsigned i, char c)
{
- char msg[BASE::Tb_entry_size - sizeof(BASE)];
- struct Ptr
- {
- char tag[2];
- char const *ptr;
- } mptr;
- } _msg;
-} __attribute__((__packed__));
+ if (i < sizeof(msg) - 1)
+ msg[i] = c >= ' ' ? c : '.';
+ }
+
+ void term_buf(unsigned i)
+ {
+ msg[i < sizeof(msg) - 1 ? i : sizeof(msg) - 1] = '\0';
+ }
-typedef Tb_entry_ke_t<Tb_entry, Tbuf_ke> Tb_entry_ke;
+ char const *str() const
+ {
+ return mptr.tag[0] == 0 && mptr.tag[1] == 1 ? mptr.ptr : msg;
+ }
+};
-class Tb_entry_ke_reg_b : public Tb_entry
+class Tb_entry_ke : public Tb_entry
{
public:
- Mword v[3];
-} __attribute__((__packed__));
+ Tb_entry_msg<sizeof(Tb_entry)> msg;
+ void set(Context const *ctx, Address ip)
+ { set_global(Tbuf_ke, ctx, ip); }
+};
-class Tb_entry_ke_reg : public Tb_entry_ke_t<Tb_entry_ke_reg_b, Tbuf_ke_reg>
+class Tb_entry_ke_reg : public Tb_entry
{
+public:
+ Mword v[3];
+ Tb_entry_msg<sizeof(Tb_entry) + sizeof(v)> msg;
+ void set(Context const *ctx, Address ip)
+ { set_global(Tbuf_ke_reg, ctx, ip); }
};
/** logged breakpoint. */
Mword _value; ///< value at address
int _mode; ///< breakpoint mode
public:
- unsigned print(int max, char *buf) const;
+ void print(String_buffer *buf) const;
};
-/** logged context switch. */
-class Tb_entry_ctx_sw : public Tb_entry
-{
-public:
- using Tb_entry::_ip;
-
- Context const *dst; ///< switcher target
- Context const *dst_orig;
- Address kernel_ip;
- Mword lock_cnt;
- Space const *from_space;
- Sched_context const *from_sched;
- Mword from_prio;
- unsigned print(int max, char *buf) const;
-} __attribute__((packed));
-
-/** logged scheduling event. */
-class Tb_entry_sched : public Tb_entry
-{
-public:
- unsigned short mode;
- Context const *owner;
- unsigned short id;
- unsigned short prio;
- signed long left;
- unsigned long quantum;
-
- unsigned print(int max, char *buf) const;
-} __attribute__((packed));
-
/** logged binary kernel event. */
class Tb_entry_ke_bin : public Tb_entry
{
#include "entry_frame.h"
#include "globals.h"
#include "kip.h"
-#include "static_init.h"
#include "trap_state.h"
_ctx = ctx;
_ip = ip;
_kclock = (Unsigned32)Kip::k()->clock;
- _cpu = current_cpu();
+ _cpu = cxx::int_value<Cpu_number>(current_cpu());
}
PUBLIC inline
Tb_entry_ipc::set(Context const *ctx, Mword ip, Syscall_frame *ipc_regs, Utcb *utcb,
Mword dbg_id, Unsigned64 left)
{
+ (void)left;
set_global(Tbuf_ipc, ctx, ip);
_dst = ipc_regs->ref();
_label = ipc_regs->from_spec();
_timeout = ipc_regs->timeout();
_tag = ipc_regs->tag();
- if (ipc_regs->next_period())
- {
- _dword[0] = (Unsigned32)(left & 0xffffffff);
- _dword[1] = (Unsigned32)(left >> 32);
- }
- else
- {
- // hint for gcc
- register Mword tmp0 = utcb->values[0];
- register Mword tmp1 = utcb->values[1];
- _dword[0] = tmp0;
- _dword[1] = tmp1;
- }
+ // hint for gcc
+ Mword tmp0 = utcb->values[0];
+ Mword tmp1 = utcb->values[1];
+ _dword[0] = tmp0;
+ _dword[1] = tmp1;
}
PUBLIC inline
{
set_global(Tbuf_ipc_res, ctx, ip);
// hint for gcc
- register Mword tmp0 = utcb->values[0];
- register Mword tmp1 = utcb->values[1];
+ Mword tmp0 = utcb->values[0];
+ Mword tmp1 = utcb->values[1];
_dword[0] = tmp0;
_dword[1] = tmp1;
_tag = ipc_regs->tag();
{ return _space; }
-PUBLIC inline
-void
-Tb_entry_pf_res::set(Context const *ctx, Address ip, Address pfa,
- L4_error err, L4_error ret)
-{
- set_global(Tbuf_pf_res, ctx, ip);
- _pfa = pfa;
- _err = err;
- _ret = ret;
-}
-
-PUBLIC inline
-Address
-Tb_entry_pf_res::pfa() const
-{ return _pfa; }
-
-PUBLIC inline
-L4_error
-Tb_entry_pf_res::err() const
-{ return _err; }
-
-PUBLIC inline
-L4_error
-Tb_entry_pf_res::ret() const
-{ return _ret; }
-
-
PUBLIC inline
void
Tb_entry_bp::set(Context const *ctx, Address ip,
{ return _address; }
-
-PUBLIC template<typename BASE, unsigned TAG> inline
-void
-Tb_entry_ke_t<BASE, TAG>::set(Context const *ctx, Address ip)
-{ this->set_global(TAG, ctx, ip); }
-
-PUBLIC template<typename BASE, unsigned TAG> inline
-void
-Tb_entry_ke_t<BASE, TAG>::set_const(Context const *ctx, Address ip, char const *msg)
-{
- this->set_global(TAG, ctx, ip);
- _msg.mptr.tag[0] = 0;
- _msg.mptr.tag[1] = 1;
- _msg.mptr.ptr = msg;
-}
-
-PUBLIC template<typename BASE, unsigned TAG> inline
-void
-Tb_entry_ke_t<BASE, TAG>::set_buf(unsigned i, char c)
-{
- if (i < sizeof(_msg.msg)-1)
- _msg.msg[i] = c >= ' ' ? c : '.';
-}
-
-PUBLIC template<typename BASE, unsigned TAG> inline
-void
-Tb_entry_ke_t<BASE, TAG>::term_buf(unsigned i)
-{
- _msg.msg[i < sizeof(_msg.msg)-1 ? i : sizeof(_msg.msg)-1] = '\0';
-}
-
-PUBLIC template<typename BASE, unsigned TAG> inline
-char const *
-Tb_entry_ke_t<BASE, TAG>::msg() const
-{
- return _msg.mptr.tag[0] == 0 && _msg.mptr.tag[1] == 1 ? _msg.mptr.ptr : _msg.msg;
-}
-
PUBLIC inline
void
Tb_entry_ke_bin::set(Context const *ctx, Address ip)
_msg[i] = c;
}
-PUBLIC inline
-void
-Tb_entry_ke_reg::set_const(Context const *ctx, Mword eip,
- const char *msg,
- Mword v1, Mword v2, Mword v3)
-{
- Tb_entry_ke_t<Tb_entry_ke_reg_b, Tbuf_ke_reg>::set_const(ctx, eip, msg);
- v[0] = v1;
- v[1] = v2;
- v[2] = v3;
-}
-