mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-30 04:18:45 +00:00
Remove some old dead code from ftrace
This commit is contained in:
parent
b4ae385a6a
commit
4245da19e2
2 changed files with 14 additions and 21 deletions
|
@ -16,28 +16,14 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/cmpxchg.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/lockcmpxchgp.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nexgen32e/rdtscp.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/time/clockstonanos.internal.h"
|
||||
|
||||
#define MAX_NESTING 512
|
||||
|
||||
|
@ -57,7 +43,6 @@ static struct Ftrace {
|
|||
int skew;
|
||||
int stackdigs;
|
||||
int64_t lastaddr;
|
||||
uint64_t laststamp;
|
||||
} g_ftrace;
|
||||
|
||||
static privileged int GetNestingLevelImpl(struct StackFrame *frame) {
|
||||
|
@ -112,17 +97,14 @@ static privileged inline bool AcquireFtraceLock(void) {
|
|||
*/
|
||||
privileged void ftracer(void) {
|
||||
long stackuse;
|
||||
uint64_t stamp;
|
||||
struct StackFrame *frame;
|
||||
if (AcquireFtraceLock()) {
|
||||
stamp = rdtsc();
|
||||
frame = __builtin_frame_address(0);
|
||||
frame = frame->next;
|
||||
if (frame->addr != g_ftrace.lastaddr) {
|
||||
stackuse = (intptr_t)GetStackAddr(0) + GetStackSize() - (intptr_t)frame;
|
||||
kprintf("%rFUN %5P %'13T %'*ld %*s%t\n", g_ftrace.stackdigs, stackuse,
|
||||
GetNestingLevel(frame) * 2, "", frame->addr);
|
||||
g_ftrace.laststamp = X86_HAVE(RDTSCP) ? rdtscp(0) : rdtsc();
|
||||
g_ftrace.lastaddr = frame->addr;
|
||||
}
|
||||
ReleaseFtraceLock();
|
||||
|
@ -132,7 +114,6 @@ privileged void ftracer(void) {
|
|||
textstartup int ftrace_install(void) {
|
||||
if (GetSymbolTable()) {
|
||||
g_ftrace.lastaddr = -1;
|
||||
g_ftrace.laststamp = kStartTsc;
|
||||
g_ftrace.stackdigs = LengthInt64Thousands(GetStackSize());
|
||||
g_ftrace.skew = GetNestingLevelImpl(__builtin_frame_address(0));
|
||||
return __hook(ftrace_hook, GetSymbolTable());
|
||||
|
|
|
@ -6552,10 +6552,13 @@ static int MemoryMonitor(void *arg) {
|
|||
mi = mi2;
|
||||
mi[0].x = (intptr_t)_base >> 16;
|
||||
mi[0].size = _etext - _base;
|
||||
mi[0].flags = 0;
|
||||
mi[1].x = (intptr_t)_etext >> 16;
|
||||
mi[1].size = _edata - _etext;
|
||||
mi[1].flags = 0;
|
||||
mi[2].x = (intptr_t)_edata >> 16;
|
||||
mi[2].size = _end - _edata;
|
||||
mi[2].flags = 0;
|
||||
_spinlock(&_mmi.lock);
|
||||
if (_mmi.i == intervals - 3) {
|
||||
memcpy(mi + 3, _mmi.p, _mmi.i * sizeof(*mi));
|
||||
|
@ -6585,7 +6588,11 @@ static int MemoryMonitor(void *arg) {
|
|||
rc = mincore(addr + j * PAGESIZE, PAGESIZE, &rez);
|
||||
if (!rc) {
|
||||
if (rez & 1) {
|
||||
color2 = 42;
|
||||
if (mi[i].flags & MAP_SHARED) {
|
||||
color2 = 105;
|
||||
} else {
|
||||
color2 = 42;
|
||||
}
|
||||
} else {
|
||||
color2 = 41;
|
||||
}
|
||||
|
@ -6597,7 +6604,11 @@ static int MemoryMonitor(void *arg) {
|
|||
color = color2;
|
||||
appendf(&b, "\e[%dm", color);
|
||||
}
|
||||
appendw(&b, ' ');
|
||||
if (mi[i].flags & MAP_ANONYMOUS) {
|
||||
appendw(&b, ' ');
|
||||
} else {
|
||||
appendw(&b, '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7294,6 +7305,7 @@ void RedBean(int argc, char *argv[]) {
|
|||
#else
|
||||
GetHostsTxt(); // for effect
|
||||
GetResolvConf(); // for effect
|
||||
__print_maps();
|
||||
if (daemonize || uniprocess || !linenoiseIsTerminal()) {
|
||||
EventLoop(HEARTBEAT);
|
||||
} else if (IsWindows()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue