From 5eba3ad6104a45c4bc6e1b3b2283f0fb05fbef87 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 4 Apr 2008 15:16:39 -0400 Subject: 2008-04-04 Masami Hiramatsu PR 5528 * systemtap.stress/conversions.exp: Update a script to catch up recently changes of conversions.stp. --- testsuite/ChangeLog | 6 ++++++ testsuite/systemtap.stress/conversions.exp | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index da789127..95c1f117 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-04-04 Masami Hiramatsu + + PR 5528 + * systemtap.stress/conversions.exp: Update a script to catch up + recently changes of conversions.stp. + 2008-03-31 Frank Ch. Eigler * configure.ac: Bump version to 0.7. diff --git a/testsuite/systemtap.stress/conversions.exp b/testsuite/systemtap.stress/conversions.exp index 34cd3889..9c2c2fa9 100644 --- a/testsuite/systemtap.stress/conversions.exp +++ b/testsuite/systemtap.stress/conversions.exp @@ -12,13 +12,12 @@ foreach value {0 0xffffffff 0xffffffffffffffff} { verbose -log "exp $test $errs" expect { -timeout 180 - -re {ERROR[^\r\n]*\r\n} { incr errs; exp_continue } - -re {WARNING[^\r\n]*\r\n} { incr errs; exp_continue } + -re {(ERROR|WARNING)[^\r\n]*\r\n} { incr errs; exp_continue } eof { } timeout { fail "$test (timeout)" } } verbose -log "done exp $test $errs" wait - if {$errs == 9} { pass $test } else { fail "$test ($errs)" } + if {$errs == 14} { pass $test } else { fail "$test ($errs)" } verbose -log "done $test $errs" } -- cgit From f76710250cf57a06162abb476b13077edd766abe Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 4 Apr 2008 15:06:33 -0500 Subject: 2008-04-04 David Smith PR 5961 (partial) * task_finder.c: New file. --- runtime/ChangeLog | 5 + runtime/task_finder.c | 410 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 415 insertions(+) create mode 100644 runtime/task_finder.c diff --git a/runtime/ChangeLog b/runtime/ChangeLog index e66a048e..bcac9e80 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2008-04-04 David Smith + + PR 5961 (partial) + * task_finder.c: New file. + 2008-04-01 Frank Ch. Eigler * lket/*: Belatedly remove retired LKET code. diff --git a/runtime/task_finder.c b/runtime/task_finder.c new file mode 100644 index 00000000..d2e57a6b --- /dev/null +++ b/runtime/task_finder.c @@ -0,0 +1,410 @@ +#include + +static LIST_HEAD(__stp_task_finder_list); + +struct stap_task_finder_target; + +typedef int (*stap_task_finder_callback)(struct task_struct *tsk, + int register_p, + struct stap_task_finder_target *tgt); + +struct stap_task_finder_target { +/* private: */ + struct list_head list; /* __stp_task_finder_list linkage */ + struct list_head callback_list_head; + struct list_head callback_list; + struct utrace_engine_ops ops; + int engine_attached; + size_t pathlen; + +/* public: */ + const char *pathname; + pid_t pid; + stap_task_finder_callback callback; +}; + +static int +stap_register_task_finder_target(struct stap_task_finder_target *new_tgt) +{ + // Since this __stp_task_finder_list is (currently) only + // written to in one big setup operation before the task + // finder process is started, we don't need to lock it. + struct list_head *node; + struct stap_task_finder_target *tgt = NULL; + int found_node = 0; + + if (new_tgt->pathname != NULL) + new_tgt->pathlen = strlen(new_tgt->pathname); + else + new_tgt->pathlen = 0; + + // Search the list for an existing entry for pathname/pid. + list_for_each(node, &__stp_task_finder_list) { + tgt = list_entry(node, struct stap_task_finder_target, list); + if (tgt != NULL + /* pathname-based target */ + && ((new_tgt->pathlen > 0 + && tgt->pathlen == new_tgt->pathlen + && strcmp(tgt->pathname, new_tgt->pathname) == 0) + /* pid-based target */ + || (new_tgt->pid != 0 && tgt->pid == new_tgt->pid))) { + found_node = 1; + break; + } + } + + // If we didn't find a matching existing entry, add the new + // target to the task list. + if (! found_node) { + INIT_LIST_HEAD(&new_tgt->callback_list_head); + list_add(&new_tgt->list, &__stp_task_finder_list); + tgt = new_tgt; + } + + // Add this target to the callback list for this task. + new_tgt->engine_attached = 0; + list_add_tail(&new_tgt->callback_list, &tgt->callback_list_head); + return 0; +} + +static void +stap_utrace_detach_ops(struct utrace_engine_ops *ops) +{ + struct task_struct *tsk; + struct utrace_attached_engine *engine; + long error = 0; + pid_t pid = 0; + + rcu_read_lock(); + for_each_process(tsk) { + struct mm_struct *mm; + mm = get_task_mm(tsk); + if (mm) { + mmput(mm); + engine = utrace_attach(tsk, UTRACE_ATTACH_MATCH_OPS, + ops, 0); + if (IS_ERR(engine)) { + error = -PTR_ERR(engine); + if (error != ENOENT) { + pid = tsk->pid; + break; + } + error = 0; + } + else if (engine != NULL) { + utrace_detach(tsk, engine); + } + } + } + rcu_read_unlock(); + + if (error != 0) { + _stp_error("utrace_attach returned error %d on pid %d", + error, pid); + } +} + +static void +__stp_task_finder_cleanup(void) +{ + struct list_head *tgt_node, *tgt_next; + struct list_head *cb_node, *cb_next; + struct stap_task_finder_target *tgt; + + // Walk the main list, cleaning up as we go. + list_for_each_safe(tgt_node, tgt_next, &__stp_task_finder_list) { + tgt = list_entry(tgt_node, struct stap_task_finder_target, + list); + if (tgt == NULL) + continue; + + list_for_each_safe(cb_node, cb_next, + &tgt->callback_list_head) { + struct stap_task_finder_target *cb_tgt; + cb_tgt = list_entry(cb_node, + struct stap_task_finder_target, + callback_list); + if (cb_tgt == NULL) + continue; + + if (cb_tgt->engine_attached) { + stap_utrace_detach_ops(&cb_tgt->ops); + cb_tgt->engine_attached = 0; + } + + list_del(&cb_tgt->callback_list); + } + list_del(&tgt->list); + } +} + +static char * +__stp_get_mm_path(struct mm_struct *mm, char *buf, int buflen) +{ + struct vm_area_struct *vma; + char *rc = NULL; + + down_read(&mm->mmap_sem); + vma = mm->mmap; + while (vma) { + if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) + break; + vma = vma->vm_next; + } + if (vma) { + struct vfsmount *mnt = mntget(vma->vm_file->f_path.mnt); + struct dentry *dentry = dget(vma->vm_file->f_path.dentry); + rc = d_path(dentry, mnt, buf, buflen); + dput(dentry); + mntput(mnt); + } + else { + *buf = '\0'; + rc = ERR_PTR(ENOENT); + } + up_read(&mm->mmap_sem); + return rc; +} + +#define __STP_UTRACE_TASK_FINDER_EVENTS (UTRACE_EVENT(CLONE) \ + | UTRACE_EVENT(EXEC)) + +#define __STP_UTRACE_ATTACHED_TASK_EVENTS (UTRACE_EVENT(DEATH)) + +static u32 +__stp_utrace_task_finder_clone(struct utrace_attached_engine *engine, + struct task_struct *parent, + unsigned long clone_flags, + struct task_struct *child) +{ + struct utrace_attached_engine *child_engine; + struct mm_struct *mm; + + // On clone, attach to the child. Ignore threads with no mm + // (which are kernel threads). + mm = get_task_mm(child); + if (mm) { + mmput(mm); + child_engine = utrace_attach(child, UTRACE_ATTACH_CREATE, + engine->ops, 0); + if (IS_ERR(child_engine)) + _stp_error("attach to clone child %d failed: %ld", + (int)child->pid, PTR_ERR(child_engine)); + else { + utrace_set_flags(child, child_engine, + __STP_UTRACE_TASK_FINDER_EVENTS); + } + } + return UTRACE_ACTION_RESUME; +} + +static u32 +__stp_utrace_task_finder_death(struct utrace_attached_engine *engine, + struct task_struct *tsk) +{ + struct stap_task_finder_target *tgt = engine->data; + + // The first implementation of this added a + // UTRACE_EVENT(DEATH) handler to + // __stp_utrace_task_finder_ops. However, dead threads don't + // have a mm_struct, so we can't find the exe's path. So, we + // don't know which callback(s) to call. + // + // So, now when an "interesting" thread is found, we add a + // separate UTRACE_EVENT(DEATH) handler for every probe. + + if (tgt != NULL && tgt->callback != NULL) { + int rc; + + // Call the callback + rc = tgt->callback(tsk, 0, tgt); + if (rc != 0) { + _stp_error("death callback for %d failed: %d", + (int)tsk->pid, rc); + } + } + return UTRACE_ACTION_RESUME; +} + +static u32 +__stp_utrace_task_finder_exec(struct utrace_attached_engine *engine, + struct task_struct *tsk, + const struct linux_binprm *bprm, + struct pt_regs *regs) +{ + size_t filelen; + struct list_head *tgt_node; + struct stap_task_finder_target *tgt; + int found_node = 0; + + // On exec, check bprm + if (bprm->filename == NULL) + return UTRACE_ACTION_RESUME; + + filelen = strlen(bprm->filename); + list_for_each(tgt_node, &__stp_task_finder_list) { + tgt = list_entry(tgt_node, struct stap_task_finder_target, + list); + // Note that we don't bother with looking for pids + // here, since they are handled at startup. + if (tgt != NULL && tgt->pathlen > 0 + && tgt->pathlen == filelen + && strcmp(tgt->pathname, bprm->filename) == 0) { + found_node = 1; + break; + } + } + if (found_node) { + struct list_head *cb_node; + list_for_each(cb_node, &tgt->callback_list_head) { + struct stap_task_finder_target *cb_tgt; + cb_tgt = list_entry(cb_node, + struct stap_task_finder_target, + callback_list); + if (cb_tgt == NULL) + continue; + + if (cb_tgt->callback != NULL) { + int rc = cb_tgt->callback(tsk, 1, cb_tgt); + if (rc != 0) { + _stp_error("exec callback for %d failed: %d", + (int)tsk->pid, rc); + break; + } + } + + // Set up thread death notification. + memset(&cb_tgt->ops, 0, sizeof(cb_tgt->ops)); + cb_tgt->ops.report_death + = &__stp_utrace_task_finder_death; + + engine = utrace_attach(tsk, + UTRACE_ATTACH_CREATE, + &cb_tgt->ops, cb_tgt); + if (IS_ERR(engine)) { + _stp_error("attach to exec'ed %d failed: %ld", + (int)tsk->pid, + PTR_ERR(engine)); + } + else { + utrace_set_flags(tsk, engine, + __STP_UTRACE_ATTACHED_TASK_EVENTS); + cb_tgt->engine_attached = 1; + } + } + } + return UTRACE_ACTION_RESUME; +} + +struct utrace_engine_ops __stp_utrace_task_finder_ops = { + .report_clone = __stp_utrace_task_finder_clone, + .report_exec = __stp_utrace_task_finder_exec, +}; + +int +stap_start_task_finder(void) +{ + int rc = 0; + struct task_struct *tsk; + char *mmpath_buf; + + mmpath_buf = _stp_kmalloc(PATH_MAX); + if (mmpath_buf == NULL) { + _stp_error("Unable to allocate space for path"); + return ENOMEM; + } + + rcu_read_lock(); + for_each_process(tsk) { + struct utrace_attached_engine *engine; + struct mm_struct *mm; + char *mmpath; + size_t mmpathlen; + struct list_head *tgt_node; + + mm = get_task_mm(tsk); + if (! mm) { + /* If the thread doesn't have a mm_struct, it is + * a kernel thread which we need to skip. */ + continue; + } + + /* Attach to the thread */ + engine = utrace_attach(tsk, UTRACE_ATTACH_CREATE, + &__stp_utrace_task_finder_ops, 0); + if (IS_ERR(engine)) { + int error = -PTR_ERR(engine); + if (error != ENOENT) { + mmput(mm); + _stp_error("utrace_attach returned error %d on pid %d", + error, (int)tsk->pid); + rc = error; + break; + } + } + else if (unlikely(engine == NULL)) { + mmput(mm); + _stp_error("utrace_attach returned NULL on pid %d", + (int)tsk->pid); + rc = EFAULT; + break; + } + utrace_set_flags(tsk, engine, __STP_UTRACE_TASK_FINDER_EVENTS); + + /* Check the thread's exe's path/pid against our list. */ + mmpath = __stp_get_mm_path(mm, mmpath_buf, PATH_MAX); + mmput(mm); /* We're done with mm */ + if (IS_ERR(mmpath)) { + rc = -PTR_ERR(mmpath); + _stp_error("Unable to get path (error %d) for pid %d", + rc, (int)tsk->pid); + break; + } + + mmpathlen = strlen(mmpath); + list_for_each(tgt_node, &__stp_task_finder_list) { + struct stap_task_finder_target *tgt; + struct list_head *cb_node; + + tgt = list_entry(tgt_node, + struct stap_task_finder_target, list); + if (tgt == NULL) + continue; + /* pathname-based target */ + else if (tgt->pathlen > 0 + && (tgt->pathlen != mmpathlen + || strcmp(tgt->pathname, mmpath) != 0)) + continue; + /* pid-based target */ + else if (tgt->pid != 0 && tgt->pid != tsk->pid) + continue; + + list_for_each(cb_node, &tgt->callback_list_head) { + struct stap_task_finder_target *cb_tgt; + cb_tgt = list_entry(cb_node, + struct stap_task_finder_target, + callback_list); + if (cb_tgt == NULL || cb_tgt->callback == NULL) + continue; + + // Call the callback. + rc = cb_tgt->callback(tsk, 1, cb_tgt); + if (rc != 0) { + _stp_error("attach callback for %d failed: %d", + (int)tsk->pid, rc); + break; + } + } + } + } + rcu_read_unlock(); + _stp_kfree(mmpath_buf); + return rc; +} + +static void +stap_stop_task_finder(void) +{ + stap_utrace_detach_ops(&__stp_utrace_task_finder_ops); + __stp_task_finder_cleanup(); +} -- cgit From b916df9c10dddd0ae49a9029c8758759a319fb71 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 4 Apr 2008 16:52:30 -0400 Subject: 2008-04-04 Masami Hiramatsu PR 6028 * translate.cxx (c_unparser::emit_common_header): Add unwaddr for caching unwound address. * tapsets.cxx (common_probe_entryfn_prologue): Clear unwaddr. * loc2c-runtime.h (fetch_register): Call ia64_fetch_register with the address of c->unwaddr. * regs-ia64.c (ia64_fetch_register): Don't unwind stack if it has already unwound stack in same probe. --- ChangeLog | 7 +++++++ runtime/ChangeLog | 8 ++++++++ runtime/loc2c-runtime.h | 2 +- runtime/regs-ia64.c | 15 +++++++++------ tapsets.cxx | 2 ++ translate.cxx | 2 ++ 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad961375..e35d90b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-04-04 Masami Hiramatsu + + PR 6028 + * translate.cxx (c_unparser::emit_common_header): Add unwaddr for + caching unwound address. + * tapsets.cxx (common_probe_entryfn_prologue): Clear unwaddr. + 2008-04-01 Frank Ch. Eigler * safety/*: Removed subdirectory containing abandoned experiment. diff --git a/runtime/ChangeLog b/runtime/ChangeLog index e66a048e..7e1b0748 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,11 @@ +2008-04-04 Masami Hiramatsu + + PR 6028 + * loc2c-runtime.h (fetch_register): Call ia64_fetch_register with + the address of c->unwaddr. + * regs-ia64.c (ia64_fetch_register): Don't unwind stack if it has + already unwound stack in same probe. + 2008-04-01 Frank Ch. Eigler * lket/*: Belatedly remove retired LKET code. diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index 7ea1b1e4..66fd1e43 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -129,7 +129,7 @@ #undef fetch_register #undef store_register -#define fetch_register(regno) ia64_fetch_register(regno, c->regs) +#define fetch_register(regno) ia64_fetch_register(regno, c->regs, &c->unwaddr) #define store_register(regno,value) ia64_store_register(regno, c->regs, value) #elif defined __x86_64__ diff --git a/runtime/regs-ia64.c b/runtime/regs-ia64.c index 2a5a1d17..66dc60f3 100644 --- a/runtime/regs-ia64.c +++ b/runtime/regs-ia64.c @@ -35,7 +35,7 @@ static void ia64_stap_get_arbsp(struct unw_frame_info *info, void *arg) lp->address = 0; } -static long ia64_fetch_register(int regno, struct pt_regs *pt_regs) +static long ia64_fetch_register(int regno, struct pt_regs *pt_regs, unsigned long **cache) { struct ia64_stap_get_arbsp_param pa; @@ -47,12 +47,15 @@ static long ia64_fetch_register(int regno, struct pt_regs *pt_regs) else if (regno < 32 || regno > 127) return 0; - pa.ip = pt_regs->cr_iip; - unw_init_running(ia64_stap_get_arbsp, &pa); - if (pa.address == 0) - return 0; + if (!*cache) { + pa.ip = pt_regs->cr_iip; + unw_init_running(ia64_stap_get_arbsp, &pa); + if (pa.address == 0) + return 0; + *cache = pa.address; + } - return *ia64_rse_skip_regs(pa.address, regno-32); + return *ia64_rse_skip_regs(*cache, regno-32); } static void ia64_store_register(int regno, diff --git a/tapsets.cxx b/tapsets.cxx index 079d87e8..ceda9015 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -205,6 +205,8 @@ common_probe_entryfn_prologue (translator_output* o, string statestr, o->newline() << "c->last_error = 0;"; o->newline() << "c->nesting = 0;"; o->newline() << "c->regs = 0;"; + o->newline() << "c->unwaddr = 0;"; + // reset unwound address cache o->newline() << "c->pi = 0;"; o->newline() << "c->probe_point = 0;"; if (! interruptible) diff --git a/translate.cxx b/translate.cxx index f30fca7b..c9ec094a 100644 --- a/translate.cxx +++ b/translate.cxx @@ -874,6 +874,8 @@ c_unparser::emit_common_header () // See c_unparser::visit_statement() o->newline() << "const char *last_stmt;"; o->newline() << "struct pt_regs *regs;"; + o->newline() << "unsigned long *unwaddr;"; + // unwaddr is caching unwound address in each probe handler on ia64. o->newline() << "struct kretprobe_instance *pi;"; o->newline() << "va_list *mark_va_list;"; o->newline() << "void *data;"; -- cgit From a291e87b97bd7eefcd63cc63f37c14ccdae1a268 Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 9 Apr 2008 13:00:36 -0500 Subject: 2008-04-09 David Smith * .gitignore: Added more files to ignore. * doc/.gitignore: New file. --- .gitignore | 2 ++ ChangeLog | 4 ++++ doc/.gitignore | 8 ++++++++ doc/ChangeLog | 4 ++++ 4 files changed, 18 insertions(+) create mode 100644 doc/.gitignore diff --git a/.gitignore b/.gitignore index 69bd5e97..4984fad5 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ systemtap.spec testresults stapio stap_merge +SNAPSHOT +*.o diff --git a/ChangeLog b/ChangeLog index e35d90b6..7d2853d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-04-09 David Smith + + * .gitignore: Added more files to ignore. + 2008-04-04 Masami Hiramatsu PR 6028 diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..d8a93302 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,8 @@ +*.aux +*.glo +*.idx +*.log +*.lot +*.out +*.pdf +*.toc diff --git a/doc/ChangeLog b/doc/ChangeLog index e652078d..21b3cbf7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2008-04-09 David Smith + + * .gitignore: New file. + 2008-03-25 Frank Ch. Eigler * langref.tex: Clarify utility of epilogue-type probe aliases. -- cgit From c0f9d4b0f1e4d1d49d238e4b2546de46f51166eb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 10 Apr 2008 13:09:19 -0400 Subject: PR6393: git version tagging at build time 2008-04-10 Frank Ch. Eigler PR 6393. * git_version.sh: New file, copied from radeonhd. * configure.ac: No longer generate $builddir/SNAPSHOT. * Makefile.am: Generate $builddir/git_version.h. (EXTRA_DIST): Add git_version.h and git_version.sh. * main.cxx (version): Print generated GIT_MESSAGE therefrom. * Makefile.in, configure: Regenerated. --- ChangeLog | 10 ++ Makefile.am | 7 +- Makefile.in | 7 +- configure | 7 -- configure.ac | 7 -- git_version.sh | 348 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.cxx | 2 + 7 files changed, 372 insertions(+), 16 deletions(-) create mode 100755 git_version.sh diff --git a/ChangeLog b/ChangeLog index 7d2853d2..fc720484 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-04-10 Frank Ch. Eigler + + PR 6393. + * git_version.sh: New file, copied from radeonhd. + * configure.ac: No longer generate $builddir/SNAPSHOT. + * Makefile.am: Generate $builddir/git_version.h. + (EXTRA_DIST): Add git_version.h and git_version.sh. + * main.cxx (version): Print generated GIT_MESSAGE therefrom. + * Makefile.in, configure: Regenerated. + 2008-04-09 David Smith * .gitignore: Added more files to ignore. diff --git a/Makefile.am b/Makefile.am index 1fc4dbec..b09bbc05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,6 +17,9 @@ stap_SOURCES = main.cxx \ tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \ cache.cxx util.cxx coveragedb.cxx stap_LDADD = @stap_LIBS@ @sqlite3_LIBS@ +main.o: git_version.h +git_version.h: + $(srcdir)/git_version.sh -k --srcdir $(srcdir) -o git_version.h stap_CXXFLAGS = $(AM_CXXFLAGS) stap_CPPFLAGS = $(AM_CPPFLAGS) @@ -102,7 +105,8 @@ LDADD = EXTRA_DIST = buildrun.h elaborate.h loc2c.h session.h \ parse.h staptree.h tapsets.h translate.h \ cache.h hash.h mdfour.h util.h staplog.c coveragedb.h \ - examples testsuite systemtap.spec runtime tapset + examples testsuite systemtap.spec runtime tapset \ + git_version.h git_version.sh SAMPLE_DEST_DIR = $(distdir)/examples/samples @@ -156,6 +160,7 @@ clean-local: rm -rf $(TEST_COV_DIR) rm -rf stap.info rm -rf staplog.so + rm -f git_version.h uninstall-local: rm -rf $(DESTDIR)$(pkgdatadir) diff --git a/Makefile.in b/Makefile.in index e82d66a3..e1259bde 100644 --- a/Makefile.in +++ b/Makefile.in @@ -311,7 +311,8 @@ LDADD = EXTRA_DIST = buildrun.h elaborate.h loc2c.h session.h \ parse.h staptree.h tapsets.h translate.h \ cache.h hash.h mdfour.h util.h staplog.c coveragedb.h \ - examples testsuite systemtap.spec runtime tapset + examples testsuite systemtap.spec runtime tapset \ + git_version.h git_version.sh SAMPLE_DEST_DIR = $(distdir)/examples/samples SAMPLE_SRC = $(srcdir)/testsuite/systemtap.samples/iotask.stp \ @@ -1458,6 +1459,9 @@ uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8 uninstall-man uninstall-man1 uninstall-man5 uninstall-man8 \ uninstall-pkglibexecPROGRAMS +main.o: git_version.h +git_version.h: + $(srcdir)/git_version.sh -k --srcdir $(srcdir) -o git_version.h @BUILD_ELFUTILS_TRUE@stamp-elfutils: config.status @BUILD_ELFUTILS_TRUE@ $(MAKE) $(AM_MAKEFLAGS) -C build-elfutils all @BUILD_ELFUTILS_TRUE@ for dir in libelf libebl libdw libdwfl backends; do \ @@ -1525,6 +1529,7 @@ clean-local: rm -rf $(TEST_COV_DIR) rm -rf stap.info rm -rf staplog.so + rm -f git_version.h uninstall-local: rm -rf $(DESTDIR)$(pkgdatadir) diff --git a/configure b/configure index c8be8582..819c6f06 100755 --- a/configure +++ b/configure @@ -6812,13 +6812,6 @@ cap_LIBS="$LIBS" LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" -if test -d $srcdir/.git -a ! -f $srcdir/SNAPSHOT; then - snapshot=`cd $srcdir; git-rev-list --abbrev-commit --max-count=1 HEAD` - echo $snapshot > SNAPSHOT - { echo "$as_me:$LINENO: Created git SNAPSHOT $snapshot" >&5 -echo "$as_me: Created git SNAPSHOT $snapshot" >&6;} -fi - ac_config_headers="$ac_config_headers config.h:config.in" ac_config_files="$ac_config_files Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" diff --git a/configure.ac b/configure.ac index fa14516c..51ed83a7 100644 --- a/configure.ac +++ b/configure.ac @@ -204,13 +204,6 @@ AC_SUBST(cap_LIBS) LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" -dnl Create SNAPSHOT file from git commit id if possible -if test -d $srcdir/.git -a ! -f $srcdir/SNAPSHOT; then - snapshot=`cd $srcdir; git-rev-list --abbrev-commit --max-count=1 HEAD` - echo $snapshot > SNAPSHOT - AC_MSG_NOTICE([Created git SNAPSHOT $snapshot]) -fi - AC_CONFIG_HEADERS([config.h:config.in]) AC_CONFIG_FILES(Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) AC_CONFIG_SUBDIRS(testsuite) diff --git a/git_version.sh b/git_version.sh new file mode 100755 index 00000000..69eb0f24 --- /dev/null +++ b/git_version.sh @@ -0,0 +1,348 @@ +#!/bin/sh +# +# Generate some basic versioning information which can be piped to a header. +# +# Copyright (c) 2006-2007 Luc Verhaegen +# Copyright (C) 2007 Hans Ulrich Niedermann +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# This script is based on the one written for xf86-video-unichrome by +# Luc Verhaegen, but was rewritten almost completely by Hans Ulrich +# Niedermann. The script contains a few bug fixes from Egbert Eich, +# Matthias Hopf, Joerg Sonnenberger, and possibly others. +# +# The author thanks the nice people on #git for the assistance. +# +# Simple testing of this script: +# /sbin/busybox sh git_version.sh --example > moo.c \ +# && gcc -Wall -Wextra -Wno-unused -o moo moo.c \ +# && ./moo +# (bash should also do) +# +# For how to hook this up to your automake- and/or imake-based build +# system, best take a look at how the RadeonHD.am and/or RadeonHD.tmpl +# work in the xf86-video-radeonhd build system. For non-recursive make, +# you can probably make things a little bit simpler. +# +# KNOWN BUGS: +# * Uses hyphenated ("git-foo-bar") program names, which git upstream +# have declared deprecated. +# + +# Help messages +USAGE="[