diff options
Diffstat (limited to 'debian/patches')
-rw-r--r-- | debian/patches/100-fix-cgroups-crash.patch | 18 | ||||
-rw-r--r-- | debian/patches/600-openvz-veid-on-kernels-gt-2.6.18.patch | 42 | ||||
-rw-r--r-- | debian/patches/700-ltrace-support.patch | 195 | ||||
-rw-r--r-- | debian/patches/series | 3 |
4 files changed, 258 insertions, 0 deletions
diff --git a/debian/patches/100-fix-cgroups-crash.patch b/debian/patches/100-fix-cgroups-crash.patch new file mode 100644 index 0000000..4ba95cb --- /dev/null +++ b/debian/patches/100-fix-cgroups-crash.patch @@ -0,0 +1,18 @@ +diff --git a/ProcessList.c b/ProcessList.c +index c234357..3bb1b81 100644 +--- a/ProcessList.c ++++ b/ProcessList.c +@@ -473,7 +473,12 @@ static void ProcessList_readCGroupFile(Process* process, const char* dirname, co + char** fields = String_split(trimmed, ':'); + free(trimmed); + +- process->cgroup = strndup(fields[2] + 1, 10); ++ if (!fields[1] || !fields[2]) { ++ process->cgroup = strdup(""); // cgroups do not work ++ } ++ else { ++ process->cgroup = strndup(fields[2] + 1, 10); ++ } + String_freeArray(fields); + } + fclose(file); diff --git a/debian/patches/600-openvz-veid-on-kernels-gt-2.6.18.patch b/debian/patches/600-openvz-veid-on-kernels-gt-2.6.18.patch new file mode 100644 index 0000000..57e687e --- /dev/null +++ b/debian/patches/600-openvz-veid-on-kernels-gt-2.6.18.patch @@ -0,0 +1,42 @@ +Fix determining OpenVZ VEID on Linux kernels >= 2.6.18. +Index: htop/ProcessList.c +=================================================================== +--- htop.orig/ProcessList.c 2011-01-16 17:02:59.000000000 +0200 ++++ htop/ProcessList.c 2011-01-16 18:05:01.000000000 +0200 +@@ -438,19 +438,26 @@ + return; + } + char filename[MAX_NAME+1]; +- snprintf(filename, MAX_NAME, "%s/%s/stat", dirname, name); ++ snprintf(filename, MAX_NAME, "%s/%s/status", dirname, name); + FILE* file = fopen(filename, "r"); + if (!file) + return; +- fscanf(file, +- "%*u %*s %*c %*u %*u %*u %*u %*u %*u %*u " +- "%*u %*u %*u %*u %*u %*u %*u %*u " +- "%*u %*u %*u %*u %*u %*u %*u %*u " +- "%*u %*u %*u %*u %*u %*u %*u %*u " +- "%*u %*u %*u %*u %*u %*u %*u %*u " +- "%*u %*u %*u %*u %*u %*u %*u " +- "%*u %*u %u %u", +- &process->vpid, &process->ctid); ++ ++ char buffer[256]; ++ process->ctid = 0; ++ while (!feof(file)) { ++ char* ok = fgets(buffer, 255, file); ++ if (!ok) ++ break; ++ ++ if (String_startsWith(buffer, "envID:")) { ++ int ctid; ++ int ok = sscanf(buffer, "envID:\t%d", &ctid); ++ if (ok >= 1) { ++ process->ctid = ctid; ++ } ++ } ++ } + fclose(file); + } + diff --git a/debian/patches/700-ltrace-support.patch b/debian/patches/700-ltrace-support.patch new file mode 100644 index 0000000..b44b025 --- /dev/null +++ b/debian/patches/700-ltrace-support.patch @@ -0,0 +1,195 @@ +Add support for 'ltrace' in addition to 'strace' support. +Index: htop/TraceScreen.c +=================================================================== +--- htop.orig/TraceScreen.c 2011-01-16 17:02:59.000000000 +0200 ++++ htop/TraceScreen.c 2011-01-16 18:15:07.000000000 +0200 +@@ -23,11 +23,17 @@ + + /*{ + ++typedef enum TraceType_ { ++ STRACE, ++ LTRACE ++} TraceType; ++ + typedef struct TraceScreen_ { + Process* process; + Panel* display; + FunctionBar* bar; + bool tracing; ++ TraceType type; + } TraceScreen; + + }*/ +@@ -38,9 +44,10 @@ + + static int tsEvents[] = {KEY_F(4), KEY_F(5), 27}; + +-TraceScreen* TraceScreen_new(Process* process) { ++TraceScreen* TraceScreen_new(Process* process, TraceType type) { + TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen)); + this->process = process; ++ this->type = type; + this->display = Panel_new(0, 1, COLS, LINES-2, LISTITEM_CLASS, true, ListItem_compare); + this->bar = FunctionBar_new(tsFunctions, tsKeys, tsEvents); + this->tracing = true; +@@ -56,7 +63,14 @@ + static void TraceScreen_draw(TraceScreen* this) { + attrset(CRT_colors[PANEL_HEADER_FOCUS]); + mvhline(0, 0, ' ', COLS); +- mvprintw(0, 0, "Trace of process %d - %s", this->process->pid, this->process->comm); ++ switch(this->type) { ++ case STRACE: ++ mvprintw(0, 0, "Trace of process %d - %s (STRACE)", this->process->pid, this->process->comm); ++ break; ++ case LTRACE: ++ mvprintw(0, 0, "Trace of process %d - %s (LTRACE)", this->process->pid, this->process->comm); ++ break; ++ } + attrset(CRT_colors[DEFAULT_COLOR]); + FunctionBar_draw(this->bar, NULL); + } +@@ -73,15 +87,24 @@ + dup2(fdpair[1], STDERR_FILENO); + fcntl(fdpair[1], F_SETFL, O_NONBLOCK); + sprintf(buffer, "%d", this->process->pid); +- execlp("strace", "strace", "-p", buffer, NULL); +- const char* message = "Could not execute 'strace'. Please make sure it is available in your $PATH."; ++ const char* message; ++ switch(this->type) { ++ case STRACE: ++ execlp("strace", "strace", "-p", buffer, NULL); ++ message = "Could not execute 'strace'. Please make sure it is available in your $PATH."; ++ break; ++ case LTRACE: ++ execlp("ltrace", "ltrace", "-p", buffer, NULL); ++ message = "Could not execute 'ltrace'. Please make sure it is available in your $PATH."; ++ break; ++ } + write(fdpair[1], message, strlen(message)); + exit(1); + } + fcntl(fdpair[0], F_SETFL, O_NONBLOCK); +- FILE* strace = fdopen(fdpair[0], "r"); ++ FILE* trace = fdopen(fdpair[0], "r"); + Panel* panel = this->display; +- int fd_strace = fileno(strace); ++ int fd_trace = fileno(trace); + TraceScreen_draw(this); + CRT_disableDelay(); + bool contLine = false; +@@ -90,13 +113,13 @@ + while (looping) { + fd_set fds; + FD_ZERO(&fds); +- FD_SET(fd_strace, &fds); ++ FD_SET(fd_trace, &fds); + struct timeval tv; + tv.tv_sec = 0; tv.tv_usec = 500; +- int ready = select(fd_strace+1, &fds, NULL, NULL, &tv); ++ int ready = select(fd_trace+1, &fds, NULL, NULL, &tv); + int nread = 0; + if (ready > 0) +- nread = fread(buffer, 1, 1000, strace); ++ nread = fread(buffer, 1, 1000, trace); + if (nread && this->tracing) { + char* line = buffer; + buffer[nread] = '\0'; +@@ -171,6 +194,6 @@ + } + kill(child, SIGTERM); + waitpid(child, NULL, 0); +- fclose(strace); ++ fclose(trace); + CRT_enableDelay(); + } +Index: htop/TraceScreen.h +=================================================================== +--- htop.orig/TraceScreen.h 2009-06-29 13:18:40.000000000 +0300 ++++ htop/TraceScreen.h 2011-01-16 18:15:07.000000000 +0200 +@@ -25,15 +25,21 @@ + #include "FunctionBar.h" + + ++typedef enum TraceType_ { ++ STRACE, ++ LTRACE ++} TraceType; ++ + typedef struct TraceScreen_ { + Process* process; + Panel* display; + FunctionBar* bar; + bool tracing; ++ TraceType type; + } TraceScreen; + + +-TraceScreen* TraceScreen_new(Process* process); ++TraceScreen* TraceScreen_new(Process* process, TraceType type); + + void TraceScreen_delete(TraceScreen* this); + +Index: htop/htop.1 +=================================================================== +--- htop.orig/htop.1 2011-01-16 17:02:59.000000000 +0200 ++++ htop/htop.1 2011-01-16 18:15:07.000000000 +0200 +@@ -54,6 +54,11 @@ + Display open files for a process: if lsof(1) is installed, pressing this key + will display the list of file descriptors opened by the process. + .TP ++.B l ++Trace process library calls: if ltrace(1) is installed, pressing this key ++will attach it to the currently selected process, presenting a live ++update of library calls issued by the process. ++.TP + .B F1, h + Help screen + .TP +Index: htop/htop.c +=================================================================== +--- htop.orig/htop.c 2011-01-16 17:02:59.000000000 +0200 ++++ htop/htop.c 2011-01-16 18:15:07.000000000 +0200 +@@ -133,6 +133,7 @@ + mvaddstr(19, 0, " F2 S: setup F6 >: select sort column"); + mvaddstr(20, 0, " F1 h: show this help screen l: list open files with lsof"); + mvaddstr(21, 0, " F10 q: quit s: trace syscalls with strace"); ++ mvaddstr(22, 0, " L: trace library calls with ltrace"); + + attrset(CRT_colors[HELP_BOLD]); + mvaddstr( 9, 0, " Arrows"); mvaddstr( 9,40, " F5 t"); +@@ -152,10 +153,11 @@ + mvaddstr(19, 0, " F2 S"); mvaddstr(19,40, " F6 >"); + mvaddstr(20, 0, " ? F1 h"); mvaddstr(20,40, " l"); + mvaddstr(21, 0, " F10 q"); mvaddstr(21,40, " s"); ++ mvaddstr(22,40, " L"); + attrset(CRT_colors[DEFAULT_COLOR]); + + attrset(CRT_colors[HELP_BOLD]); +- mvaddstr(23,0, "Press any key to return."); ++ mvaddstr(24,0, "Press any key to return."); + attrset(CRT_colors[DEFAULT_COLOR]); + refresh(); + CRT_readKey(); +@@ -580,9 +582,20 @@ + Panel_onKey(panel, KEY_DOWN); + break; + } ++ case 'L': ++ { ++ TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(panel), LTRACE); ++ TraceScreen_run(ts); ++ TraceScreen_delete(ts); ++ clear(); ++ FunctionBar_draw(defaultBar, NULL); ++ refreshTimeout = 0; ++ CRT_enableDelay(); ++ break; ++ } + case 's': + { +- TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(panel)); ++ TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(panel), STRACE); + TraceScreen_run(ts); + TraceScreen_delete(ts); + clear(); diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..7204157 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,3 @@ +100-fix-cgroups-crash.patch +600-openvz-veid-on-kernels-gt-2.6.18.patch +700-ltrace-support.patch |