Restore lost wake_up().

Sun May  8 15:45:08 2005  Søren Sandmann  <sandmann@redhat.com>

	* sysprof-module.c (do_generate): Restore lost wake_up().

	* sfile.c: Comment out use of bz2.

	* Makefile: Add an install target. Add GLADE_DIR and PIXMAP_DIR

	* sysprof.c (build_gui): use GLADE_DIR and PIXMAP_DIR here.

	* TODO: Updates.
This commit is contained in:
Søren Sandmann
2005-05-08 19:49:26 +00:00
committed by Søren Sandmann Pedersen
parent c427b88352
commit aaa38daad8
9 changed files with 102 additions and 33 deletions

View File

@ -1,3 +1,15 @@
Sun May 8 15:45:08 2005 Søren Sandmann <sandmann@redhat.com>
* sysprof-module.c (do_generate): Restore lost wake_up().
* sfile.c: Comment out use of bz2.
* Makefile: Add an install target. Add GLADE_DIR and PIXMAP_DIR
* sysprof.c (build_gui): use GLADE_DIR and PIXMAP_DIR here.
* TODO: Updates.
Sat May 7 13:57:17 2005 Søren Sandmann <sandmann@redhat.com>
* sfile.c (sfile_output_free): Implement this function

View File

@ -5,8 +5,16 @@ CFLAGS += $(MODCFLAGS) -DKERNEL26
else
CFLAGS := $(shell pkg-config --cflags gtk+-2.0 libglade-2.0) -Wall -g
LIBS := $(shell pkg-config --libs gtk+-2.0 libglade-2.0) -lbfd -liberty -lbz2
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
BINDIR := $(PREFIX)/bin
GLADE_DIR := $(PREFIX)/share/sysprof
PIXMAP_DIR := $(PREFIX)/share/pixmaps/sysprof
CFLAGS := $(shell pkg-config --cflags gtk+-2.0 libglade-2.0) -Wall -g -DGLADE_DIR=\"$(GLADE_DIR)\" -DPIXMAP_DIR=\"$(PIXMAP_DIR)\"
LIBS := $(shell pkg-config --libs gtk+-2.0 libglade-2.0) -lbfd -liberty
C_FILES := sysprof.c binfile.c stackstash.c watch.c process.c \
profile.c treeviewutils.c sfile.c
OBJS := $(addsuffix .o, $(basename $(C_FILES)))
@ -17,12 +25,26 @@ INCLUDE := -isystem $(KDIR)/include
MODCFLAGS := -DMODULE -D__KERNEL__ -Wall ${INCLUDE}
MODULE := sysprof-module
all: check $(BINARY) $(MODULE).o
KMAKE := $(MAKE) -C $(KDIR) SUBDIRS=$(PWD)
all: binaries
@echo ==========================================
@echo
@echo To install sysprof type
@echo
@echo \ \ \ make PREFIX=\<prefix\> install
@echo
@echo as root. For example:
@echo
@echo \ \ \ make PREFIX=/usr install
@echo
binaries: check $(BINARY) $(MODULE).o
check:
pkg-config gtk+-2.0 libglade-2.0
@[ -r $(KDIR)/include/linux/kernel.h ] || (echo No kernel headers found; exit 1)
@[ -r /usr/include/bzlib.h ] || (echo bzip2 header file not found; exit 1)
# @[ -r /usr/include/bzlib.h ] || (echo bzip2 header file not found; exit 1)
touch check
$(BINARY): $(OBJS) depend
@ -33,6 +55,41 @@ clean:
depend:
$(CC) -MM $(CFLAGS) $(C_FILES) > depend.mk
install: binaries
@echo
@echo Installing in $(PREFIX)
@echo
# binary
@mkdir -p $(BINDIR)
cp sysprof $(BINDIR)
# glade file
mkdir -p $(GLADE_DIR)
cp sysprof.glade $(GLADE_DIR)
# icon
mkdir -p $(PIXMAP_DIR)
cp sysprof-icon.png $(PIXMAP_DIR)
# kernel module
$(KMAKE) modules_install
depmod
@echo ======================================
@echo
@echo To run sysprof first insert the module by typing
@echo
@echo \ \ \ \ modprobe sysprof-module
@echo
@echo as root. Then run \"$(PREFIX)/bin/sysprof\".
@echo
insert_module: install
modprobe -r sysprof-module
modprobe sysprof-module
depend.mk:
touch depend.mk
$(MAKE) depend
@ -41,20 +98,13 @@ include depend.mk
.PHONY: depend all
ifeq ($(shell (uname -r | grep 2.6) > /dev/null ; echo -n $$?),0)
ifneq ($(shell (uname -r | grep 2.6) > /dev/null ; echo -n $$?),0)
echo A 2.6 kernel is required; exit 1
endif
# if kernel 2.6
$(MODULE).o: $(MODULE).c
# echo modcflags $(MODCFLAGS)
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
else
MODCFLAGS += -DKERNEL24
# build module
$(MODULE).o: $(MODULE).c
$(CC) $(MODCFLAGS) $(MODULE).c -c -o$(MODULE).o
$(KMAKE) modules
endif
endif

4
TODO
View File

@ -1,7 +1,6 @@
Before 1.0:
* Correctness
- grep FIXME
- When the module is unloaded, kill all processes blocking in read
- or block unloading until all processes have exited
@ -30,6 +29,7 @@ Before 1.0:
Before 1.2:
- grep FIXME - not10
- translation should be hooked up
- Fixing the oops in kernels < 2.6.11
@ -252,6 +252,8 @@ Later:
DONE:
- grep FIXME
- give profiles on the command line
- Hopefully the oops at the end of this file is gone now that

2
autogen.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
make

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

View File

@ -23,7 +23,9 @@
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#if 0
#include <bzlib.h>
#endif
#include "sfile.h"
typedef struct State State;
@ -1468,6 +1470,7 @@ file_replace (const gchar *filename,
gssize length,
GError **error);
#if 0
static void
disaster (int status)
{
@ -1530,6 +1533,7 @@ bz2_compress (const guchar *input, int input_length,
if (output_length)
*output_length = compressed_size;
}
#endif
gboolean
sfile_output_save (SFileOutput *sfile,
@ -1593,12 +1597,14 @@ sfile_output_save (SFileOutput *sfile,
}
}
/* FIMXE: bz2 compressing the output is probably
#if 0
/* FIXME - not10: bz2 compressing the output is probably
* interesting at some point. For now just make sure
* it works without actually using it.
*/
bz2_compress (output->str, output->len,
&compressed, &compressed_size);
#endif
g_free (compressed);

View File

@ -331,20 +331,17 @@ do_generate (void *data)
struct task_struct *task = data;
generate_stack_trace(task, head);
wake_up_process (task);
if (head++ == &stack_traces[N_TRACES - 1])
head = &stack_traces[0];
/* This is crack, what we actually want is "put_task_struct()",
* but that macros uses __put_task_struct() which is not exported.
*
* It does look to me like the worst that will happen is a rare
* leak, which is certainly better than an oops.
wake_up (&wait_for_trace);
/* If a task dies between the time we see it in on_timer and
* the time we get here, it will be leaked. If __put_task_struct9)
* was exported, then we could do this properly
*/
if (atomic_dec_and_test(&(task)->usage)) {
free_task (task);
}
atomic_dec (&(task)->usage);
mod_timer(&timer, jiffies + INTERVAL);
}
@ -357,7 +354,7 @@ on_timer(unsigned long dong)
if (current && current->state == TASK_RUNNING && current->pid != 0)
{
get_task_struct (current);
INIT_WORK (&work, do_generate, current);
schedule_work (&work);

View File

@ -105,7 +105,7 @@ show_samples_timeout (gpointer data)
{
Application *app = data;
char *label;
switch (app->state)
{
case INITIAL:
@ -446,9 +446,9 @@ on_start_toggled (GtkWidget *widget, gpointer data)
{
sorry (app->main_window,
"Can't open /proc/sysprof-trace. You need to insert\n"
"the sysprof kernel module. Type \n"
"the sysprof kernel module. Type\n"
"\n"
" insmod sysprof-module.ko\n"
" modprobe sysprof-module\n"
"\n"
"as root.");
@ -1162,11 +1162,11 @@ build_gui (Application *app)
set_shadows (xml);
xml = glade_xml_new ("./sysprof.glade", NULL, NULL);
xml = glade_xml_new (GLADE_DIR "/sysprof.glade", NULL, NULL);
/* Main Window */
app->main_window = glade_xml_get_widget (xml, "main_window");
app->icon = gdk_pixbuf_new_from_file ("sysprof-icon.png", NULL);
app->icon = gdk_pixbuf_new_from_file (PIXMAP_DIR "/sysprof-icon.png", NULL);
gtk_window_set_icon (GTK_WINDOW (app->main_window), app->icon);