[Ltrace-devel] r32 - in ltrace/branches/ltrace-powerpc-secure-plt: . sysdeps/linux-gnu sysdeps/linux-gnu/alpha sysdeps/linux-gnu/arm sysdeps/linux-gnu/i386 sysdeps/linux-gnu/ia64 sysdeps/linux-gnu/m68k sysdeps/linux-gnu/ppc sysdeps/linux-gnu/s390 sysdeps/linux-gnu/sparc sysdeps/linux-gnu/x86_64 testsuite testsuite/config testsuite/lib testsuite/ltrace.main testsuite/ltrace.minor testsuite/ltrace.torture

Paul Gilliam pgilliam-guest at costa.debian.org
Fri Mar 10 23:13:21 UTC 2006


Author: pgilliam-guest
Date: 2006-03-10 23:13:20 +0000 (Fri, 10 Mar 2006)
New Revision: 32

Added:
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/Makefile.in
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/README
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/config/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/config/unix.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.cc
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/ltrace.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/Makefile.in
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal-1.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-lib.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/Makefile.in
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle-lib.cpp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.cpp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.h
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-T.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-tt.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-ttt.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/Makefile.in
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.c
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.exp
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/run-my-tests.sh
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/so_test1/
   ltrace/branches/ltrace-powerpc-secure-plt/testsuite/so_test2/
Modified:
   ltrace/branches/ltrace-powerpc-secure-plt/Makefile.in
   ltrace/branches/ltrace-powerpc-secure-plt/breakpoints.c
   ltrace/branches/ltrace-powerpc-secure-plt/configure.ac
   ltrace/branches/ltrace-powerpc-secure-plt/elf.c
   ltrace/branches/ltrace-powerpc-secure-plt/elf.h
   ltrace/branches/ltrace-powerpc-secure-plt/ltrace.h
   ltrace/branches/ltrace-powerpc-secure-plt/options.c
   ltrace/branches/ltrace-powerpc-secure-plt/options.h
   ltrace/branches/ltrace-powerpc-secure-plt/output.c
   ltrace/branches/ltrace-powerpc-secure-plt/process_event.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/alpha/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/arm/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/breakpoint.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/i386/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ia64/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/m68k/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/arch.h
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/s390/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/sparc/plt.c
   ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/x86_64/plt.c
Log:
This revision teaches ltrace about the new secure PLT entries for 32-bit
PowerPC targets.  Although these changes are for the ppc architecture only,
all architectures where effected, mostly due to a name change (see below).

Modifications:

 1) The name of the plt2addr routine was changed to sym2addr and it's second
    argument was changed from the address of the plt to a pointer to
    corresponding library_symbol structure.  This was a minor change for most
    architectures because the routine was formally called like this:
        addr = plt2addr(lte, sym->enter_addr);
    and the implementation was simply:
        return (void )plt;
    after the change, this became:
        addr = sym2addr(lte, sym);
    and:
        return sym->enter_addr;
    This change was required because the ppc version of the routine needed
    access to 'plt_type', a new field in the library_symbol structure (see
    below).

2)  The new ppc 'sym2addr' routine needs to differentiate between secure and
    non-secure 32-bit PLT entries, based on ELF flags.  So this information
    had to be passed to the 'sym2addr' routine via the ltelf structure and the
    library_symbol structure, both of which had to be modified to carry this
    new information.

3)  The new ppc 'sym2addr' routine was modified to treat the PLT entry as a
    pointer (secure) or as a executable instruction (non-secure) based on
    information from the ELF header, other than the word size, 32 vs. 64 bits.
    If the PLT entry was a pointer, it would need to be adjusted, depending
    on 'ltrace's word size and the target's word size.

4)  The need for a separate static_plt2addr field in the library_symbol
    structure was eliminated.

5)  The routine 'elf_plt2addr' was renamed to the more representational name
    'opd2addr'.

6)  'process_breakpoint()' had do be modified to cope with a quirk caused by
    the lazy resolution done by the dynamic linker.  For 32-bit ppc, the
    initial value of the PLT entries pointed into executable code in the
    .glink section of the target.  That code would then jump to the PLTresolve
    routine, part of the dynamic linker.  Sometimes, however, the code would
    not be a branch instruction, but rather a NOP, and execution would 'fall
    into' PLTresolve.  During execution, ltrace would have replaced these
    NOP instruction with TRAP instructions.  During processing of a resultant
    breakpoint, the TRAP would be replaced by the original NOP which would then
    be single-stepped.  Here is where the quirk comes in: the instruction after
    that single-stepped NOP would be a TRAP instruction for the 'next' library
    function!  This caused ltrace to give an incorrect trace.  The fix for this
    takes far less than this explanation and can be found near at the beginning
    of 'process_breakpoint()'.  The code is '#ifdef'ed for PowerPC, but it
    doesn't really need to be, except for the fact that for some architectures,
    the size of NOP and TRAP instructions may differ.

7)  The -x option processing was improved.

8)  A number of confusing constructs were improved.  For example, in sysdeps/
    linux-gnu/breakpoint.c, [+j] is used as a subscript, even though 'j' could
    never be negative.

9)  (This is a big one!) A dejagnu testsuite was added.  As well as new files
    being added, this also entailed changing some inputs to the configuration
    process to deal with the new requirements (see below).



The following files were modified to support secure PLT entries for 32-bit
PowerPC targets:

ltrace-powerpc-secure-plt/output.c
ltrace-powerpc-secure-plt/options.h
ltrace-powerpc-secure-plt/elf.c
ltrace-powerpc-secure-plt/elf.h
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/arm/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/breakpoint.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/arch.h
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/m68k/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/alpha/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/i386/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/x86_64/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/s390/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ia64/plt.c
ltrace-powerpc-secure-plt/sysdeps/linux-gnu/sparc/plt.c
ltrace-powerpc-secure-plt/process_event.c
ltrace-powerpc-secure-plt/ltrace.h
ltrace-powerpc-secure-plt/breakpoints.c
ltrace-powerpc-secure-plt/options.c



The following files where modified to support the testsuite:

ltrace-powerpc-secure-plt/Makefile.in
ltrace-powerpc-secure-plt/configure.ac


The following files where added and constitute the testsuite:

ltrace-powerpc-secure-plt/testsuite
ltrace-powerpc-secure-plt/testsuite/run-my-tests.sh
ltrace-powerpc-secure-plt/testsuite/so_test1
ltrace-powerpc-secure-plt/testsuite/Makefile.in
ltrace-powerpc-secure-plt/testsuite/so_test2
ltrace-powerpc-secure-plt/testsuite/config
ltrace-powerpc-secure-plt/testsuite/config/unix.exp
ltrace-powerpc-secure-plt/testsuite/lib
ltrace-powerpc-secure-plt/testsuite/lib/ltrace.exp
ltrace-powerpc-secure-plt/testsuite/lib/compiler.c
ltrace-powerpc-secure-plt/testsuite/lib/compiler.cc
ltrace-powerpc-secure-plt/testsuite/README
ltrace-powerpc-secure-plt/testsuite/ltrace.torture
ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.c
ltrace-powerpc-secure-plt/testsuite/ltrace.torture/Makefile.in
ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/Makefile.in
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.c
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-tt.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record.c
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.cpp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle-lib.cpp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.c
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.h
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-T.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.c
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.c
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-ttt.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.c
ltrace-powerpc-secure-plt/testsuite/ltrace.main
ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.c
ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.c
ltrace-powerpc-secure-plt/testsuite/ltrace.main/Makefile.in
ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.c
ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.c
ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-lib.c
ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.exp
ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal-1.c


Modified: ltrace/branches/ltrace-powerpc-secure-plt/Makefile.in
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/Makefile.in	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/Makefile.in	2006-03-10 23:13:20 UTC (rev 32)
@@ -40,7 +40,12 @@
 sysdeps/sysdep.o: dummy
 		$(MAKE) -C sysdeps/$(OS)
 
-clean:
+clean-deja:
+		$(RM) testrun.log testrun.sum
+		cd testsuite; make clean
+
+
+clean: clean-deja
 		$(MAKE) -C sysdeps/$(OS) clean
 		$(RM) ltrace $(OBJ)
 		$(RM) *~ *.bak a.out core KK
@@ -48,6 +53,7 @@
 distclean:	clean
 		$(RM) config.cache config.status config.log config.h Makefile configure.scan
 		$(RM) -r autom4te.cache
+		ce testsuite; make distclean
 
 realclean:	distclean
 		$(RM) configure config.h.in
@@ -74,6 +80,9 @@
 		$(INSTALL_FILE) COPYING README TODO BUGS ChangeLog $(DESTDIR)$(docdir)
 		$(INSTALL_FILE) ltrace.1 $(DESTDIR)$(mandir)/man1
 
+check:		ltrace
+		( cd testsuite; $(MAKE) check )
+
 dummy:
 
 .PHONY:		all clean distclean dist install dummy

Modified: ltrace/branches/ltrace-powerpc-secure-plt/breakpoints.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/breakpoints.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/breakpoints.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -92,8 +92,7 @@
 		 */
 		if (opt_L) {
 			a = ptrace(PTRACE_PEEKTEXT, proc->pid,
-				   plt2addr(proc,
-					    proc->list_of_symbols->enter_addr),
+				   sym2addr(proc, proc->list_of_symbols),
 				   0);
 			if (a == 0x0)
 				return;
@@ -169,11 +168,7 @@
 	sym = proc->list_of_symbols;
 	while (sym) {
 		/* proc->pid==0 delays enabling. */
-		if (sym->static_plt2addr) {
-			insert_breakpoint(proc, sym->enter_addr, sym);
-		} else {
-			insert_breakpoint(proc, plt2addr(proc, sym->enter_addr), sym);	/* proc->pid==0 delays enabling. */
-		}
+		insert_breakpoint(proc, sym2addr(proc, sym), sym);
 		sym = sym->next;
 	}
 	proc->callstack_depth = 0;
@@ -186,7 +181,7 @@
 
 	while (sym) {
 		if (sym->needs_init) {
-			insert_breakpoint(proc, plt2addr(proc, sym->enter_addr),
+			insert_breakpoint(proc, sym2addr(proc, sym),
 					  sym);
 			if (sym->needs_init && !sym->is_weak) {
 				fprintf(stderr,

Modified: ltrace/branches/ltrace-powerpc-secure-plt/configure.ac
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/configure.ac	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/configure.ac	2006-03-10 23:13:20 UTC (rev 32)
@@ -84,4 +84,6 @@
 dnl of libelf and ltrace matches.
 AC_SYS_LARGEFILE
 fi
-AC_OUTPUT(Makefile)
+AC_OUTPUT(Makefile testsuite/Makefile \
+        testsuite/ltrace.main/Makefile testsuite/ltrace.minor/Makefile \
+        testsuite/ltrace.torture/Makefile )

Modified: ltrace/branches/ltrace-powerpc-secure-plt/elf.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/elf.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/elf.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -21,9 +21,9 @@
 static void do_close_elf(struct ltelf *lte);
 static void add_library_symbol(GElf_Addr addr, const char *name,
 			       struct library_symbol **library_symbolspp,
-			       int use_elf_plt2addr, int is_weak);
+			       enum toplt type_of_plt, int is_weak);
 static int in_load_libraries(const char *name, struct ltelf *lte);
-static GElf_Addr elf_plt2addr(struct ltelf *ltc, void *addr);
+static GElf_Addr opd2addr(struct ltelf *ltc, void *addr);
 
 extern char *PLTs_initialized_by_here;
 
@@ -192,7 +192,7 @@
 					error(EXIT_FAILURE, 0,
 					      "Couldn't convert .hash section from \"%s\"",
 					      filename);
-				lte->hash_malloced = 1;
+				lte->lte_flags |= LTE_HASH_MALLOCED;
 				dst = lte->hash;
 				src = (Elf32_Word *) data->d_buf;
 				if ((data->d_type == ELF_T_WORD
@@ -212,6 +212,9 @@
 			if (strcmp(name, ".plt") == 0) {
 				lte->plt_addr = shdr.sh_addr;
 				lte->plt_size = shdr.sh_size;
+				if (shdr.sh_flags & SHF_EXECINSTR) {
+					lte->lte_flags |= LTE_PLT_EXECUTABLE;
+				}
 			} else if (strcmp(name, ".opd") == 0) {
 				lte->opd_addr = (GElf_Addr *) shdr.sh_addr;
 				lte->opd_size = shdr.sh_size;
@@ -263,7 +266,7 @@
 
 static void do_close_elf(struct ltelf *lte)
 {
-	if (lte->hash_malloced)
+	if (lte->lte_flags & LTE_HASH_MALLOCED)
 		free((char *)lte->hash);
 	elf_end(lte->elf);
 	close(lte->fd);
@@ -272,7 +275,7 @@
 static void
 add_library_symbol(GElf_Addr addr, const char *name,
 		   struct library_symbol **library_symbolspp,
-		   int use_elf_plt2addr, int is_weak)
+		   enum toplt type_of_plt, int is_weak)
 {
 	struct library_symbol *s;
 	s = malloc(sizeof(struct library_symbol) + strlen(name) + 1);
@@ -281,7 +284,7 @@
 
 	s->needs_init = 1;
 	s->is_weak = is_weak;
-	s->static_plt2addr = use_elf_plt2addr;
+	s->plt_type = type_of_plt;
 	s->next = *library_symbolspp;
 	s->enter_addr = (void *)(uintptr_t) addr;
 	s->brkpnt = NULL;
@@ -328,7 +331,7 @@
 	return 0;
 }
 
-static GElf_Addr elf_plt2addr(struct ltelf *lte, void *addr)
+static GElf_Addr opd2addr(struct ltelf *lte, void *addr)
 {
 	long base;
 	long offset;
@@ -351,9 +354,10 @@
 	struct library_symbol *library_symbols = NULL;
 	struct ltelf lte[MAX_LIBRARY + 1];
 	size_t i;
-	struct opt_e_t *xptr;
+	struct opt_x_t *xptr;
 	struct library_symbol **lib_tail = NULL;
-	struct opt_e_t *main_cheat;
+	struct opt_x_t *main_cheat;
+	int exit_out = 0;
 
 	elf_version(EV_CURRENT);
 
@@ -392,7 +396,9 @@
 		name = lte->dynstr + sym.st_name;
 		if (in_load_libraries(name, lte)) {
 			addr = arch_plt_sym_val(lte, i, &rela);
-			add_library_symbol(addr, name, &library_symbols, 0,
+			add_library_symbol(addr, name, &library_symbols,
+					   (PLTS_ARE_EXECUTABLE(lte)
+					   ?  LS_TOPLT_EXEC : LS_TOPLT_POINT),
 					   ELF64_ST_BIND(sym.st_info) != 0);
 			if (!lib_tail)
 				lib_tail = &(library_symbols->next);
@@ -401,7 +407,7 @@
 
 	if (proc->need_to_reinitialize_breakpoints) {
 		/* Add "PLTs_initialized_by_here" to opt_x list, if not already there. */
-		main_cheat = (struct opt_e_t *)malloc(sizeof(struct opt_e_t));
+		main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t));
 		if (main_cheat == NULL)
 			error(EXIT_FAILURE, 0, "Couldn allocate memory");
 		main_cheat->next = opt_x;
@@ -435,28 +441,30 @@
 
 		for (xptr = opt_x; xptr; xptr = xptr->next)
 			if (xptr->name && strcmp(xptr->name, name) == 0) {
-				/* FIXME: Should be able to use &library_symbols as above.  But
-				   when you do, none of the real library symbols cause breaks. */
-				add_library_symbol(elf_plt2addr
-						   (lte, (void *)addr), name,
-						   lib_tail, 1, 0);
+				/* FIXME: Should be able to use &library_symbols
+				   as above.  But when you do, none of the real
+				   library symbols cause breaks. */
+				add_library_symbol(opd2addr(lte, (void *)addr),
+						    name, lib_tail,
+						    LS_TOPLT_NONE, 0);
+				xptr->found = 1;
 				break;
 			}
 	}
 	for (xptr = opt_x; xptr; xptr = xptr->next)
-		if (xptr->name) {
-			if (strcmp(xptr->name, E_ENTRY_NAME) == 0)
-				add_library_symbol(elf_plt2addr
-						   (lte,
-						    (void *)lte->ehdr.e_entry),
-						   "_start", lib_tail, 1, 0);
-			else
-				fprintf(stderr,
-					"Warning: Couldn't get symbol \"%s\" "
-					"from \"%s\" or it's a duplicate",
-					xptr->name, proc->filename);
-		}
-
+		if ( ! xptr->found) {
+			char *badthing = "WARNING";
+			if (E_ENTRY_NAME && strcmp(xptr->name, E_ENTRY_NAME)) {
+				badthing = "ERROR";
+				exit_out = 1;
+			}
+		fprintf (stderr,
+			 "%s: Couldn't find symbol \"%s\" in file \"%s\"\n",
+			 badthing, xptr->name, proc->filename);
+	}
+	if (exit_out) {
+		exit (1);
+	}
 	for (i = 0; i < library_num + 1; ++i)
 		do_close_elf(&lte[i]);
 

Modified: ltrace/branches/ltrace-powerpc-secure-plt/elf.h
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/elf.h	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/elf.h	2006-03-10 23:13:20 UTC (rev 32)
@@ -24,9 +24,14 @@
 	GElf_Addr *opd_addr;
 	size_t opd_size;
 	Elf32_Word *hash;
-	int hash_malloced;
+	int lte_flags;
 };
 
+#define LTE_HASH_MALLOCED 1
+#define LTE_PLT_EXECUTABLE 2
+
+#define PLTS_ARE_EXECUTABLE(lte) ((lte->lte_flags & LTE_PLT_EXECUTABLE) != 0)
+
 extern int library_num;
 extern char *library[MAX_LIBRARY];
 

Modified: ltrace/branches/ltrace-powerpc-secure-plt/ltrace.h
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/ltrace.h	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/ltrace.h	2006-03-10 23:13:20 UTC (rev 32)
@@ -66,6 +66,13 @@
 	struct function *next;
 };
 
+enum toplt {
+	LS_TOPLT_NONE = 0,	/* PLT not used for this symbol. */
+	LS_TOPLT_EXEC,		/* PLT for this symbol is executable. */
+	LS_TOPLT_POINT		/* PLT for this symbol is a non-executable. */
+};
+
+
 extern struct function *list_of_functions;
 extern char *PLTs_initialized_by_here;
 
@@ -74,9 +81,8 @@
 	void *enter_addr;
 	struct breakpoint *brkpnt;
 	char needs_init;
-	char static_plt2addr;
+	enum toplt plt_type;
 	char is_weak;
-
 	struct library_symbol *next;
 };
 
@@ -193,7 +199,7 @@
 extern void save_register_args(enum tof type, struct process *proc);
 extern int umovestr(struct process *proc, void *addr, int len, void *laddr);
 extern int ffcheck(void *maddr);
-extern void *plt2addr(struct process *, void **);
+extern void *sym2addr(struct process *, struct library_symbol *);
 
 #if 0				/* not yet */
 extern int umoven(struct process *proc, void *addr, int len, void *laddr);

Modified: ltrace/branches/ltrace-powerpc-secure-plt/options.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/options.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/options.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -51,7 +51,7 @@
 int opt_e_enable = 1;
 
 /* List of global function names given to -x: */
-struct opt_e_t *opt_x = NULL;
+struct opt_x_t *opt_x = NULL;
 
 /* Set a break on the routine named here in order to re-initialize breakpoints
    after all the PLTs have been initialzed */
@@ -323,7 +323,7 @@
 
 		case 'x':
 			{
-				struct opt_e_t *p = opt_x;
+				struct opt_x_t *p = opt_x;
 
 				/* First, check for duplicate. */
 				while (p && strcmp(p->name, optarg)) {
@@ -334,7 +334,7 @@
 				}
 
 				/* If not duplicate, add to list. */
-				p = malloc(sizeof(struct opt_e_t));
+				p = malloc(sizeof(struct opt_x_t));
 				if (!p) {
 					perror("ltrace: malloc");
 					exit(1);

Modified: ltrace/branches/ltrace-powerpc-secure-plt/options.h
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/options.h	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/options.h	2006-03-10 23:13:20 UTC (rev 32)
@@ -31,11 +31,17 @@
 	struct opt_e_t *next;
 };
 
+struct opt_x_t {
+	char *name;
+	int found;
+	struct opt_x_t *next;
+};
+
 extern struct opt_p_t *opt_p;	/* attach to process with a given pid */
 
 extern struct opt_e_t *opt_e;	/* list of function names to display */
 extern int opt_e_enable;	/* 0 if '!' is used, 1 otherwise */
 
-extern struct opt_e_t *opt_x;	/* list of functions to break at */
+extern struct opt_x_t *opt_x;	/* list of functions to break at */
 
 extern char **process_options(int argc, char **argv);

Modified: ltrace/branches/ltrace-powerpc-secure-plt/output.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/output.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/output.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -24,7 +24,7 @@
 
 struct dict *dict_opt_c = NULL;
 
-static pid_t current_pid = 0;
+static struct process *current_proc = 0;
 static int current_depth = 0;
 static int current_column = 0;
 
@@ -134,10 +134,14 @@
 	if (opt_c) {
 		return;
 	}
-	if (current_pid) {
-		fprintf(output, " <unfinished ...>\n");
+	if (current_proc) {
+		if (current_proc->callstack[current_depth].return_addr) {
+			fprintf(output, " <unfinished ...>\n");
+		} else {
+			fprintf(output, " <no return ...>\n");
+		}
 	}
-	current_pid = 0;
+	current_proc = 0;
 	if (!fmt) {
 		return;
 	}
@@ -164,12 +168,12 @@
 	if (opt_c) {
 		return;
 	}
-	if (current_pid) {
+	if (current_proc) {
 		fprintf(output, " <unfinished ...>\n");
-		current_pid = 0;
+		current_proc = 0;
 		current_column = 0;
 	}
-	current_pid = proc->pid;
+	current_proc = proc;
 	current_depth = proc->callstack_depth;
 	proc->type_being_displayed = type;
 	begin_of_line(type, proc);
@@ -248,12 +252,12 @@
 //                              current_time_spent.tv_sec, (int)current_time_spent.tv_usec);
 		return;
 	}
-	if (current_pid && (current_pid != proc->pid ||
+	if (current_proc && (current_proc != proc ||
 			    current_depth != proc->callstack_depth)) {
 		fprintf(output, " <unfinished ...>\n");
-		current_pid = 0;
+		current_proc = 0;
 	}
-	if (current_pid != proc->pid) {
+	if (current_proc != proc) {
 		begin_of_line(type, proc);
 #ifdef USE_DEMANGLE
 		current_column +=
@@ -297,6 +301,6 @@
 			(int)current_time_spent.tv_usec);
 	}
 	fprintf(output, "\n");
-	current_pid = 0;
+	current_proc = 0;
 	current_column = 0;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/process_event.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/process_event.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/process_event.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -260,10 +260,23 @@
 static void process_breakpoint(struct event *event)
 {
 	int i, j;
-	struct breakpoint *sbp;
+	struct breakpoint *sbp, *nxtbp;
 
 	debug(2, "event: breakpoint (%p)", event->e_un.brk_addr);
-	if (event->proc->breakpoint_being_enabled) {
+	if ((sbp = event->proc->breakpoint_being_enabled) != 0) {
+#ifdef __powerpc__
+		char nop_inst[] = PPC_NOP;
+                if (memcmp(sbp->orig_value, nop_inst, PPC_NOP_LENGTH) == 0) {
+                	nxtbp = address2bpstruct(event->proc,
+                                                 event->e_un.brk_addr +
+                                                 	PPC_NOP_LENGTH);
+			if (nxtbp != 0) {
+				enable_breakpoint(event->proc->pid, sbp);
+				continue_after_breakpoint(event->proc, nxtbp);
+				return;
+			}
+		}
+#endif
 		/* Reinsert breakpoint */
 		continue_enabling_breakpoint(event->proc->pid,
 					     event->proc->
@@ -284,9 +297,9 @@
 			unsigned long a;
 			struct library_symbol *libsym =
 			    event->proc->callstack[i].c_un.libfunc;
-			void *addr = plt2addr(event->proc, libsym->enter_addr);
+			void *addr = sym2addr(event->proc, libsym);
 
-			if (event->proc->e_machine == EM_PPC) {
+			if (libsym->plt_type != LS_TOPLT_POINT) {
 				unsigned char break_insn[] = BREAKPOINT_VALUE;
 
 				sbp = address2bpstruct(event->proc, addr);
@@ -294,7 +307,7 @@
 				a = ptrace(PTRACE_PEEKTEXT, event->proc->pid,
 					   addr);
 
-				if (memcmp(&a, break_insn, 4)) {
+				if (memcmp(&a, break_insn, BREAKPOINT_LENGTH)) {
 					sbp->enabled--;
 					insert_breakpoint(event->proc, addr,
 							  libsym);
@@ -302,9 +315,10 @@
 			} else {
 				sbp = libsym->brkpnt;
 				assert(sbp);
-				if (addr != sbp->addr)
+				if (addr != sbp->addr) {
 					insert_breakpoint(event->proc, addr,
 							  libsym);
+				}
 			}
 #endif
 			for (j = event->proc->callstack_depth - 1; j > i; j--) {
@@ -385,7 +399,9 @@
 	elem->c_un.libfunc = sym;
 
 	elem->return_addr = proc->return_addr;
-	insert_breakpoint(proc, elem->return_addr, 0);
+        if (elem->return_addr) {
+		insert_breakpoint(proc, elem->return_addr, 0);
+	}
 
 	proc->callstack_depth++;
 	if (opt_T || opt_c) {
@@ -400,7 +416,7 @@
 	assert(proc->callstack_depth > 0);
 
 	elem = &proc->callstack[proc->callstack_depth - 1];
-	if (!elem->is_syscall) {
+	if (!elem->is_syscall && elem->return_addr) {
 		delete_breakpoint(proc, elem->return_addr);
 	}
 	proc->callstack_depth--;

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/alpha/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/alpha/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/alpha/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -7,7 +7,7 @@
 	return lte->plt_addr + ndx * 12 + 32;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/arm/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/arm/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/arm/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -7,7 +7,7 @@
 	return lte->plt_addr + 20 + ndx * 12;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/breakpoint.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/breakpoint.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/breakpoint.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -33,7 +33,7 @@
 		     && i * sizeof(long) + j < BREAKPOINT_LENGTH; j++) {
 			unsigned char *bytes = (unsigned char *)&a;
 
-			sbp->orig_value[i * sizeof(long) + j] = bytes[+j];
+			sbp->orig_value[i * sizeof(long) + j] = bytes[j];
 			bytes[j] = break_insn[i * sizeof(long) + j];
 		}
 		ptrace(PTRACE_POKETEXT, pid, sbp->addr + i * sizeof(long), a);
@@ -52,9 +52,7 @@
 {
 	int i, j;
 
-	if (opt_d > 1) {
-		output_line(0, "disable_breakpoint(%d,%p)", pid, sbp->addr);
-	}
+	debug(2, "disable_breakpoint(%d,%p)", pid, sbp->addr);
 
 	for (i = 0; i < 1 + ((BREAKPOINT_LENGTH - 1) / sizeof(long)); i++) {
 		long a =

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/i386/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/i386/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/i386/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -7,7 +7,7 @@
 	return lte->plt_addr + (ndx + 1) * 16;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ia64/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ia64/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ia64/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -42,7 +42,7 @@
 	return addr;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/m68k/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/m68k/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/m68k/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -8,7 +8,7 @@
 	    * ((lte->ehdr.e_flags & EF_CPU32) ? 24 : 12);
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/arch.h
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/arch.h	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/arch.h	2006-03-10 23:13:20 UTC (rev 32)
@@ -5,12 +5,19 @@
 
 #define LT_ELFCLASS	ELFCLASS32
 #define LT_ELF_MACHINE	EM_PPC
-#ifdef __powerpc64__
+#ifdef __powerpc64__	// Says 'ltrace' is 64 bits, says nothing about target.
 #define LT_ELFCLASS2	ELFCLASS64
 #define LT_ELF_MACHINE2	EM_PPC64
 
 #define PLTs_INIT_BY_HERE E_ENTRY_NAME
 
+#define PPC_NOP { 0x60, 0x00, 0x00, 0x00 }
+#define PPC_NOP_LENGTH 4
+
+#if (PPC_NOP_LENGTH != BREAKPOINT_LENGTH)
+#error "Length of the breakpoint value not equal to the length of a nop instruction"
+#endif
+
 #else
 
 #define PLTs_INIT_BY_HERE NULL

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/ppc/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -10,31 +10,49 @@
 	return rela->r_offset;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	long addr;
+	long addr = sym->enter_addr;
+	long pt_ret;
 
 	debug(3, 0);
 
-	if (proc->e_machine == EM_PPC || plt == 0)
-		return (void *)plt;
+	if (sym->plt_type != LS_TOPLT_POINT) {
+		return addr;
+	}
 
-	if (proc->pid == 0)
-		return (void *)0;
+	if (proc->pid == 0) {
+		return 0;
+	}
 
+	if (opt_d >= 3) {
+		xinfdump(proc->pid, (void *)(((long)addr-32)&0xfffffff0),
+			 sizeof(void*)*8);
+	}
+
 	// On a PowerPC-64 system, a plt is three 64-bit words: the first is the
-	// 64-bit address of the routine.  Before the PLT has been initialized, this
-	// will be 0x0. In fact, the symbol table won't have the plt's address even.
-	// Ater the PLT has been initialized, but before it has been resolved, the
-	// first word will be the address of the function in the dynamic linker that
-	// will reslove the PLT.  After the PLT is resolved, this will will be the
-	// address of the routine whose symbol is in the symbol table.
+	// 64-bit address of the routine.  Before the PLT has been initialized,
+	// this will be 0x0. In fact, the symbol table won't have the plt's
+	// address even.  Ater the PLT has been initialized, but before it has
+	// been resolved, the first word will be the address of the function in
+	// the dynamic linker that will reslove the PLT.  After the PLT is
+	// resolved, this will will be the address of the routine whose symbol
+	// is in the symbol table.
 
-	addr = ptrace(PTRACE_PEEKTEXT, proc->pid, plt);
+	// On a PowerPC-32 system, there are two types of PLTs: secure (new) and
+	// non-secure (old).  For the secure case, the PLT is simply a pointer
+	// and we can treat it much as we do for the PowerPC-64 case.  For the
+	// non-secure case, the PLT is executable code and we can put the
+	// break-point right in the PLT.
 
-	if (opt_d >= 3) {
-		xinfdump(proc->pid, plt, sizeof(void *) * 3);
+	pt_ret = ptrace(PTRACE_PEEKTEXT, proc->pid, addr, 0);
+
+	if (proc->mask_32bit) {
+		// Assume big-endian.
+		addr = (void *)((pt_ret >> 32) & 0xffffffff);
+	} else {
+		addr = (void *)pt_ret;
 	}
 
-	return (void *)addr;
+	return addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/s390/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/s390/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/s390/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -7,7 +7,7 @@
 	return lte->plt_addr + (ndx + 1) * 32;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/sparc/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/sparc/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/sparc/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -7,7 +7,7 @@
 	return rela->r_offset + 4;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Modified: ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/x86_64/plt.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/x86_64/plt.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/sysdeps/linux-gnu/x86_64/plt.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -7,7 +7,7 @@
 	return lte->plt_addr + (ndx + 1) * 16;
 }
 
-void *plt2addr(struct process *proc, void **plt)
+void *sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	return (void *)plt;
+	return sym->enter_addr;
 }

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/Makefile.in
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/Makefile.in	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/Makefile.in	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,72 @@
+# Copyright (C) 1992 - 2001 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+AUTOMAKE_OPTIONS = dejagnu
+EXPECT 	= 	expect
+RUNTEST = 	runtest
+CC	=	@CC@
+
+srcdir = 	.
+RUNTESTDEFAULTFLAGS = --srcdir $(srcdir)
+
+CLEANFILES = *.log *.sum site.bak setval.tmp site.exp
+
+SUBDIRS = ltrace.main ltrace.minor ltrace.torture
+
+#all: all-recursive
+
+.SUFFIXES:
+
+check-DEJAGNU: site.exp
+	EXPECT=$(EXPECT); export EXPECT;
+	@$(RUNTEST) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS);
+
+site.exp:
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+	@test ! -f site.exp || \
+	sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
+
+check: check-DEJAGNU
+
+clean:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	echo "Making clean in $$subdir"; \
+	(cd $$subdir && $(MAKE) clean ) done;
+	
+	-rm -f $(CLEANFILES)
+
+distclean:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	echo "Making clean in $$subdir"; \
+	(cd $$subdir && $(MAKE) distclean ) done;
+	-rm -f Makefile
+	-rm -f $(CLEANFILES)
+
+.PHONY: $(RECURSIVE_TARGETS) check  clean distclean realclean
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/README
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/README	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/README	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,244 @@
+                     README for ltrace testsuite
+              18, October, 2005 by Yao Qi  <qiyao at cn.ibm.com>
+
+This is the README file for ltrace testsuite.
+
+Quick Overview
+==============
+
+   This testsuite is based on the dejagnu framework, which is again 
+dependent on Expect and Tcl.  So all these three package (tcl, expect
+and dejagnu) should be installed on your system before running these 
+tests.
+
+   After unpacking file ltrace-0.3.36.tar.gz:
+
+	tar -zxvfm ltrace-0.3.36.tar.gz
+
+   you'll find a directory named ltrace-0.3.36, which contains:
+
+ debian etc testsuite sysdeps
+
+you can first build this package, then run the testsuite in the 
+following steps:
+
+	1 cd ltrace-0.3.36
+
+	2 Confiugre ltrace for 32-bit mode or 64-bit mode.
+	./configure
+	 OR CC='gcc -m64' ./configure
+
+	3 Build ltace
+	make
+
+	4 Run all the test in default mode.
+	make check
+
+	The default is to test the ltrace just built, using the default
+compiler options.  You can control this by adding a symbol to 'make check':
+
+	To test the shipped ltrace tool (as opposed to the just built by "make")
+
+	   --tool_exec=/usr/bin/ltrace
+
+	To change compiler switches for the target test cases
+
+	   CFLAGS_FOR_TARGET=-m64
+
+    	To change the target compiler (instead of shipped gcc)
+
+           CC_FOR_TARGET=/opt/gcc-4.0/bin/gcc
+
+
+	You can run all the tests in different mode respectively as follows,
+ 
+	(1) ./run-my-tests.sh -m32
+	OR make check
+
+	(test ltrace in build tree and compile test cases in 32-bit mode)
+
+	(2) ./run-my-tests.sh -m64
+	OR make check RUNTESTFLAGS="CFLAGS_FOR_TARGET=-m64"
+
+	(test ltrace in build tree and compile test cases in 64-bit mode)
+
+	(3) ./run-my-tests.sh -m32 /usr/bin/ltrace
+	OR make check RUNTESTFLAGS="--tool_exec=/usr/bin/ltrace"
+
+	(test shipped ltrace and compile test cases in 32-bit mode)
+
+	(4) ./run-my-tests.sh -m64 /usr/bin/ltrace
+	OR make check RUNTESTFLAGS="--tool_exec=/usr/bin/ltrace CFLAGS_FOR_TARGET=-m64"
+
+	(run shipped ltrace and compile test cases in 64-bit mode)
+
+	(5) cd testsuite; make test
+
+	(run ltrace in build tree and compile test cases same as ltrace itself)
+
+
+	(6) make check RUNTESTFLAGS="--tool_exec=/usr/bin/ltrace CFLAGS_FOR_TARGET=-m64 CC_FOR_TARGET=/opt/gcc-4.0/bin/gcc"
+
+	(run shipped ltrace and compile test cases in 64 bit mode by /opt/gcc-4.0/bin/gcc)
+Ltrace Testsuite
+================
+
+   This testsuite for ltrace is a DejaGNU based testsuite that can 
+either be used to test your newly built ltrace, or for regression 
+testing a ltrace with local modifications.
+
+   Running the testsuite requires the prior installation of DejaGNU.
+The directory ftp://sources.redhat.com/pub/dejagnu/ will contain a 
+recent snapshot.  Once DejaGNU is installed or built and add the 
+location of runtest into $PATH, you can run the tests in one of the 
+four ways it mentioned in Quick Overview.  The DejaGNU framework could
+be built in following steps:
+
+    1 Uppack these three packages.
+    tar zxvf dejagnu-1.4.4.tar.gz
+    tar zxvf tcl8.4.9-src.tar.gz
+    tar zxvf expect-5.43.0.tar.gz
+
+    2 Build them and install.
+    cd dejagnu-1.4.4
+    ./configure
+    make
+    make install
+    cd ..
+
+    cd tcl8.4.9/unix
+    ./configure
+    make
+    make install
+    cd ..
+
+    cd expect-5.43
+    ./configure
+    make
+    make install
+    cd .. 
+
+   See the DejaGNU documentation and dejagnu-1.4.4/README for further 
+details.
+
+
+Componets in ltrace testsuite
+=============================
+
+   This testsuite include all the source code you need for ltrace
+test in a single directory, which is "ltrace-0.3.36/testsuite".
+This directory includes the following files and sub-directories:
+
+`config/unix.exp`
+   configuration file for dejagnu-based test.
+
+`lib/ltrace.exp`
+   some basic functions used in all the test cases.
+
+`ltrace.main/`
+   some basic tests for major fetures of ltrace.
+
+   (1) ltrace.main/main.exp does tests on tracing a function 
+implemented in a shared library.
+
+   (2) ltrace.main/main-internal.exp does tests on tracing a function
+implemented in main executable.
+
+   (3) ltrace.main/signals.exp do test on tracing user-defined signals
+sent by program to itself.
+
+   (4) ltrace.main/system_calls.exp do test on tracing all the system 
+calls in program.
+
+`ltrace.minor/`
+   some tests for minor fetures of ltrace.
+   
+   (1) ltrace.minor/attach-process.exp do test on attching a process.
+
+   (2) ltrace.minor/count-record.exp do test on counting time and 
+calls.
+
+   (3) ltrace.minor/demangle.exp do test on demangling the C++ symbols.
+
+   (4) ltrace.minor/time-record-T.exp do test on showing the time spent
+inside each call.
+
+   (5) ltrace.minor/time-record-tt.exp
+   (6) ltrace.minor/time-record-ttt.exp  do test on printing absolute 
+timestamps in different format.
+
+   (7) ltrace.minor/trace-clone.exp do test on following clone to child
+process.
+
+   (8) ltrace.minor/trace-fork.exp do test on following fork to child
+process.
+
+`ltrace.torture/`
+   some tests in extreme condations.
+
+   (1) ltrace.torture/signals.exp do test on tracing flooded signals
+send to program itself.
+	
+Trouble shootings
+=================
+
+   (1) Running ltrace with -u option requires the superuser privilege. 
+You must make sure you are root or have already got root's password.
+
+   (2) Check the *.ltrace files in each ltrace.* directories if there are
+some FAILs in the output.  They are informative. 
+
+    (3) Add --verbose option in RUNTESTFLAGS when 'make check' if you want
+to see more details of these tests.
+
+Test case extension
+===================
+
+   Current testsuite is quite basic.  The framework of testsuite is 
+extendable and scalealbe, so you can add new testcases into it easily.
+I will describe how to do that in different ways.
+
+   (1) Add new test case in an existed testcase directory.
+
+    It is simple.  Just add a foo.exp script and a relevant foo.c if 
+necessary.  The dejagnu framework can run that script automatically when 
+you run "make check".  The executable and object file would be generate 
+in the test, please add them in 'clean' entry in Makefile.in to ensure
+that they could be cleaned up automatically when run 'make clean'.
+
+   (2) Add new test case in a new testcase directory.
+
+   It is a little complicated.  Fisrt create a new directory in 
+testsuite/ with the same pattern as others, for example ltrace.bar, 
+and then create a Makefile.in, an Expect script foo.exp, and relative 
+foo.c if necessary.  Then modify the configure.ac in ltrace-0.3.36/, 
+and add "testsuite/ltrace.bar/Makefile" into macro AC_OUTPUT,
+testsuite/ltrace.bar/Makefile will be generated when you configure 
+this package.
+
+   Adding Makefile.in in the new directroy is just to remove 
+intermediate files and log files automatically later, such as foo.ltrace,
+object files and executables.  For example, if you want to remove A.ltrace,
+B.ltrace, A and B at the time of cleanup, you can write Makefile.in 
+like this:
+
+   clean:
+        -rm -f A B
+        -rm -f *.o
+        -rm -f *.ltrace
+   distclean: clean
+        -rm -f Makefile
+
+   At last add the new directory 'ltrace.bar' into the macro SUBDIRS 
+in testsuite/Makefile.in.
+
+   Rerun the autoconf and ./configure in ./ltrace-0.3.36, the Makefile 
+will be updated.
+
+
+
+^L
+(this is for editing this file with GNU emacs)
+Local Variables:
+mode: text
+End:

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/config/unix.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/config/unix.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/config/unix.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1 @@
+load_lib ltrace.exp

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,58 @@
+/* This test file is part of GDB, the GNU debugger.
+
+   Copyright 1995, 1997, 1999, 2003, 2004 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+ 
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   */
+
+/* Sometimes the behavior of a test depends upon the compiler used to
+   compile the test program.  A test script can call get_compiler_info
+   to figure out the compiler version and test_compiler_info to test it.
+
+   get_compiler_info runs the preprocessor on this file and then eval's
+   the result.  This sets various symbols for use by test_compiler_info.
+
+   TODO: make compiler_info a local variable for get_compiler_info and
+   test_compiler_info.
+
+   TODO: all clients should use test_compiler_info and should not
+   use gcc_compiled, hp_cc_compiler, or hp_aCC_compiler.
+
+   */
+
+/* Note the semicolon at the end of this line.  Older versions of
+   hp c++ have a bug in string preprocessing: if the last token on a
+   line is a string, then the preprocessor concatenates the next line
+   onto the current line and eats the newline!  That messes up TCL of
+   course.  That happens with HP aC++ A.03.13, but it no longer happens
+   with HP aC++ A.03.45. */
+
+set compiler_info "unknown" ;
+
+#if defined (__GNUC__)
+#if defined (__GNUC_PATCHLEVEL__)
+/* Only GCC versions >= 3.0 define the __GNUC_PATCHLEVEL__ macro.  */
+set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__} -]
+#else
+set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ "unknown"} -]
+#endif
+#endif
+
+#if defined (__xlc__)
+/* IBM'x xlc compiler. NOTE:  __xlc__ expands to a double quoted string of four
+   numbers seperated by '.'s: currently "7.0.0.0" */
+set need_a_set [regsub -all {\.} [join {xlc __xlc__} -] - compiler_info]
+#endif

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.cc
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.cc	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/compiler.cc	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,45 @@
+/* This test file is part of GDB, the GNU debugger.
+
+   Copyright 1995, 1999, 2003, 2004 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+ 
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   */
+
+/* This file is exactly like compiler.c.  I could just use compiler.c if
+   I could be sure that every C++ compiler accepted extensions of ".c".  */
+
+/* Note the semicolon at the end of this line.  Older versions of
+   hp c++ have a bug in string preprocessing: if the last token on a
+   line is a string, then the preprocessor concatenates the next line
+   onto the current line and eats the newline!  That messes up TCL of
+   course.  That happens with HP aC++ A.03.13, but it no longer happens
+   with HP aC++ A.03.45. */
+
+set compiler_info "unknown" ;
+
+#if defined (__GNUC__)
+#if defined (__GNUC_PATCHLEVEL__)
+/* Only GCC versions >= 3.0 define the __GNUC_PATCHLEVEL__ macro.  */
+set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__} -]
+#else
+set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ "unknown"} -]
+#endif
+#endif
+
+#if defined (__xlC__)
+/* xlC++ version like 800 */
+set compiler_info [join {xlc++ __IBMCPP__} -]
+#endif

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/ltrace.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/ltrace.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/lib/ltrace.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,277 @@
+# This file was written by Yao Qi. (qiyao at cn.ibm.com)
+
+# Generic ltrace test subroutines that should work for any target.  If these
+# need to be modified for any target, it can be done with a variable
+# or by passing arguments.
+
+
+global LTRACE
+if [info exists TOOL_EXECUTABLE] {
+	set LTRACE $TOOL_EXECUTABLE
+} else {
+	set LTRACE $objdir/../ltrace
+}
+
+global LTRACE_OPTIONS
+set LTRACE_OPTIONS "";
+
+# ltrace_compile SOURCE DEST TYPE OPTIONS 
+#
+# Compile PUT(program under test) by native compiler.   ltrace_compile runs 
+# the right compiler, and TCL captures the output, and I evaluate the output.
+#
+# SOURCE is the name of program under test, with full directory.
+# DEST is the name of output of compilation, with full directory.
+# TYPE is an enum-like variable to affect the format or result of compiler
+#   output.  Values:
+#   executable   if output is an executable.
+#   object       if output is an object.
+# OPTIONS is option to compiler in this compilation.
+proc ltrace_compile {source dest type options} {
+    global LTRACE_TESTCASE_OPTIONS;
+    
+  # Add platform-specific options if a shared library was specified using
+  # "shlib=librarypath" in OPTIONS.
+  set new_options ""
+  set shlib_found 0
+
+  foreach opt $options {
+      if [regexp {^shlib=(.*)} $opt dummy_var shlib_name] {
+	  if [test_compiler_info "xlc*"] {
+	      # IBM xlc compiler doesn't accept shared library named other
+	      # than .so: use "-Wl," to bypass this
+	      lappend source "-Wl,$shlib_name"
+	  } else {
+	      lappend source $shlib_name
+	  }
+	  
+	  if {$shlib_found == 0} {
+	      set shlib_found 1
+	      
+	      if { ([test_compiler_info "gcc-*"]&& ([istarget "powerpc*-*-aix*"]|| [istarget "rs6000*-*-aix*"] ))} {
+		  lappend options "additional_flags=-L${objdir}/${subdir}"
+	      } elseif { [istarget "mips-sgi-irix*"] } {
+		  lappend options "additional_flags=-rpath ${objdir}/${subdir}"
+	      }
+	  }
+	  
+      } else {
+	  lappend new_options $opt
+      }
+  }
+    #end of for loop
+    set options $new_options
+    # dump some information for debug purpose.
+    verbose "options are $options"
+    verbose "source is $source $dest $type $options"
+    
+    set result [target_compile $source $dest $type $options];
+    verbose "result is $result"
+    regsub "\[\r\n\]*$" "$result" "" result;
+    regsub "^\[\r\n\]*" "$result" "" result;
+    if { $result != "" && [lsearch $options quiet] == -1} {
+	clone_output "compile failed for ltrace test, $result"
+    }
+    return $result;
+}
+
+proc get_compiler_info {binfile args} {
+    # For compiler.c and compiler.cc
+    global srcdir
+
+    # I am going to play with the log to keep noise out.
+    global outdir
+    global tool
+
+    # These come from compiler.c or compiler.cc
+    global compiler_info
+
+    # Legacy global data symbols.
+    #global gcc_compiled
+
+    # Choose which file to preprocess.
+    set ifile "${srcdir}/lib/compiler.c"
+    if { [llength $args] > 0 && [lindex $args 0] == "c++" } {
+	    set ifile "${srcdir}/lib/compiler.cc"
+    }
+
+    # Run $ifile through the right preprocessor.
+    # Toggle ltrace.log to keep the compiler output out of the log.
+    #log_file
+    set cppout [ ltrace_compile "${ifile}" "" preprocess [list "$args" quiet] ]
+    #log_file -a "$outdir/$tool.log" 
+
+    # Eval the output.
+    set unknown 0
+    foreach cppline [ split "$cppout" "\n" ] {
+	    if { [ regexp "^#" "$cppline" ] } {
+	      # line marker
+	    } elseif { [ regexp "^\[\n\r\t \]*$" "$cppline" ] } {
+	      # blank line
+	    } elseif { [ regexp "^\[\n\r\t \]*set\[\n\r\t \]" "$cppline" ] } {
+	    # eval this line
+	      verbose "get_compiler_info: $cppline" 2
+	      eval "$cppline"
+	  } else {
+	    # unknown line
+	    verbose "get_compiler_info: $cppline"
+	    set unknown 1
+	  }
+      }
+
+    # Reset to unknown compiler if any diagnostics happened.
+    if { $unknown } {
+	    set compiler_info "unknown"
+    }
+  return 0
+}
+
+proc test_compiler_info { {compiler ""} } {
+    global compiler_info
+    verbose "compiler_info=$compiler_info"
+     # if no arg, return the compiler_info string
+
+     if [string match "" $compiler] {
+         if [info exists compiler_info] {
+             return $compiler_info
+         } else {
+             perror "No compiler info found."
+         }
+     }
+
+    return [string match $compiler $compiler_info]
+}
+
+proc ltrace_compile_shlib {sources dest options} {
+    set obj_options $options
+    verbose "+++++++ [test_compiler_info]" 
+    switch -glob [test_compiler_info] {
+	"xlc-*" {
+	    lappend obj_options "additional_flags=-qpic"
+	}
+	"gcc-*" {
+	    if { !([istarget "powerpc*-*-aix*"]
+		   || [istarget "rs6000*-*-aix*"]) } {
+                lappend obj_options "additional_flags=-fpic"
+	    }
+          }
+  "xlc++-*" {
+      lappend obj_options "additional_flags=-qpic"
+  }
+
+	default {
+	    fail "Bad compiler!"
+            }
+    }
+    
+    set outdir [file dirname $dest]
+    set objects ""
+    foreach source $sources {
+	set sourcebase [file tail $source]
+       if {[ltrace_compile $source "${outdir}/${sourcebase}.o" object $obj_options] != ""} {
+           return -1
+       }
+	lappend objects ${outdir}/${sourcebase}.o
+    }
+
+    set link_options $options
+    if { [test_compiler_info "xlc-*"] || [test_compiler_info "xlc++-*"]} {
+	lappend link_options "additional_flags=-qmkshrobj"
+    } else {
+	lappend link_options "additional_flags=-shared"
+    }
+    if {[ltrace_compile "${objects}" "${dest}" executable $link_options] != ""} {
+	return -1
+    }
+}
+
+#
+# ltrace_options OPTIONS_LIST
+# Pass ltrace commandline options.
+# 
+proc ltrace_options { args } {
+	
+	global LTRACE_OPTIONS
+	set LTRACE_OPTIONS $args
+}
+
+#
+# ltrace_runtest LD_LIBRARY_PATH BIN FILE
+# Trace the execution of BIN and return result.
+#
+# BIN is program-under-test.
+# LD_LIBRARY_PATH is the env for program-under-test to run.
+# FILE is to save the output from ltrace with default name $BIN.ltrace.
+# Retrun output from ltrace.
+#
+proc ltrace_runtest { args } {
+
+	global LTRACE
+	global LTRACE_OPTIONS
+
+	verbose "LTRACE = $LTRACE"
+	
+	set LD_LIBRARY_PATH_ [lindex $args 0]
+	set BIN [lindex $args 1]
+
+	# specify the output file, the default one is $BIN.ltrace
+	if [llength $args]==3 then {
+		set file [lindex $args 2]
+	} else {
+		set file $BIN.ltrace
+	}
+	# append this option to LTRACE_OPTIONS.
+	lappend LTRACE_OPTIONS "-o"
+	lappend LTRACE_OPTIONS "$file"
+	verbose "LTRACE_OPTIONS = $LTRACE_OPTIONS"
+	#ltrace the PUT.
+	catch "exec sh -c {export LD_LIBRARY_PATH=$LD_LIBRARY_PATH_; $LTRACE $LTRACE_OPTIONS $BIN;exit}" output
+	
+	# return output from ltrace.
+	return $output
+}
+
+#
+# ltrace_saveoutput OUTPUT FILE
+# Save OUTPUT from ltrace to file FILE.
+# OUTPUT is output from ltrace or return value of ltrace_runtest.
+# FILE is file save output.
+#
+proc ltrace_saveoutput { args } {
+	
+	set output [lindex $args 0]
+	set file [lindex $args 1]
+
+	set fd [open $file w]
+     	puts $fd $output
+	close $fd
+}
+
+
+#
+# ltrace_verify_output FILE_TO_SEARCH PATTERN MAX_LINE
+# Verify the ltrace output by comparing the number of PATTERN in 
+# FILE_TO_SEARCH with INSTANCE_NO.  Do not specify INSTANCE_NO if
+# instance number is ignored in this test.
+# Reutrn:
+#      0 = number of PATTERN in FILE_TO_SEARCH inqual to INSTANCE_NO.
+#      1 = number of PATTERN in FILE_TO_SEARCH qual to INSTANCE_NO.
+#
+proc ltrace_verify_output { file_to_search pattern {instance_no 0}} {
+
+	# compute the number of PATTERN in FILE_TO_SEARCH by grep and wc.
+	catch "exec sh -c {grep $pattern $file_to_search | wc -l ;exit}" output
+	verbose "output = $output"
+	
+	if { $instance_no == 0 } then {
+		if { $output == 0 } then {
+			fail "Fail to find $pattern in $file_to_search"
+		} else {
+			pass "$pattern in $file_to_search"
+		}
+	} elseif { $output >= $instance_no } then {
+		pass "$pattern in $file_to_search for $output times"
+	} else {
+		fail "$pattern in $file_to_search for $output times ,should be $instance_no"
+	}
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/Makefile.in
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/Makefile.in	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/Makefile.in	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,34 @@
+# Copyright (C) 1992 - 2001 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+CLEANFILES = *.log *.sum site.bak setval.tmp site.exp
+
+.SUFFIXES:	
+clean:
+	-rm -f main main-internal system_calls signals 
+	-rm -f *.o *.so 
+	-rm -f *.ltrace
+	-rm -f $(CLEANFILES)
+distclean: clean
+	-rm -f Makefile
+
+
+.PHONY: $(RECURSIVE_TARGETS) check  clean distclean realclean
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal-1.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal-1.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal-1.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,8 @@
+#include<stdio.h>
+
+void 
+display ( char* s )
+{
+  printf("%s\n",s);
+}
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,19 @@
+ /* Ltrace Test : main-internal.c.
+    Objectives  : Verify that ltrace can trace call from main 
+    executable within it.
+    This file was written by Yao Qi <qiyao at cn.ibm.com>. */
+#include<stdio.h>
+
+extern void display ( char* );
+
+#define DISPLAY_LOOP	12
+
+int 
+main ()
+{
+	int i;
+	printf ("should not show up if '-X display' is used.\n");
+	for (i=0; i< DISPLAY_LOOP; i++)
+		display ("Function call within executable.");
+}
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-internal.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,33 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "main-internal"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c ${srcdir}/${subdir}/${testfile}-1.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-x" "display"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't do static plt2addr} $exec_output ] {
+	fail "Couldn't do static plt2addr!"
+	return
+} elseif [regexp {Couldn't get .hash data from} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+set pattern "display"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 12 

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-lib.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-lib.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main-lib.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,7 @@
+#include<stdio.h>
+
+void 
+print(char* s)
+{
+	printf("%s\n",s);
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,21 @@
+/* Ltrace Test : main.c.
+   Objectives  : Verify that ltrace can trace call a library function 
+   from main executable.  
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+
+extern void print ( char* );
+
+#define	PRINT_LOOP	10
+
+int
+main ()
+{
+  int i;
+
+  for (i=0; i<PRINT_LOOP; i++)
+    print ("Library function call!");
+  
+  return 0;
+}
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/main.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,39 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "main"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+set libfile "main-lib"
+set libsrc $srcdir/$subdir/$libfile.c
+set lib_sl $srcdir/$subdir/lib$testfile.so
+
+
+if [get_compiler_info $binfile] {
+  return -1
+}
+
+verbose "compiling source file now....."
+if { [ltrace_compile_shlib $libsrc $lib_sl debug ] != "" 
+  || [ltrace_compile $srcdir/$subdir/$srcfile $srcdir/$subdir/$binfile executable [list debug shlib=$lib_sl] ] != ""} {
+  send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-l" "$srcdir/$subdir/libmain.so"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return 
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Verify the output by checking numbers of print in main.ltrace.
+set pattern "print"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 10

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,48 @@
+/* Ltrace Test : signals.c.
+   Objectives  : Verify that ltrace can trace user defined signal.
+   This file was written by Yao Qi <qiyao at cn.ibm.com>. */
+
+#include<stdio.h>
+#include<signal.h>
+#include <sys/types.h>
+
+#define LOOP	7
+
+void 
+handler(int signum,siginfo_t *info,void *act)
+{
+  /* Trace printf in signal handler.  */
+  printf("sival_int = %d\n",info->si_value.sival_int);
+}
+
+int 
+main ()
+{
+  struct sigaction act;	
+  union sigval mysigval;
+  int i;
+  int sig;
+  pid_t pid;
+  
+  mysigval.sival_int=0;
+  
+  /* Use an user-defined signal 1.  */
+  sig = SIGUSR1;
+  pid=getpid();
+  
+  sigemptyset(&act.sa_mask);
+  act.sa_sigaction=handler;
+  act.sa_flags=SA_SIGINFO;
+  
+  if(sigaction(sig,&act,NULL) < 0)
+    {
+      printf("install sigal error\n");
+    }
+  
+  for(i=0; i<LOOP; i++)
+    {
+      sleep(1);
+      sigqueue(pid,sig,mysigval);
+    }
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/signals.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,39 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "signals"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail\n."
+}
+
+# set options for ltrace.
+ltrace_options "-L"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+     	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Extract LOOP from source file.
+set fd [ open $srcdir/$subdir/$srcfile r]
+while { [gets $fd line] >= 0 } {
+	 regexp {define LOOP.*([0-9]+)} $line match count
+}
+close $fd
+
+# Verify the output of ltrace by checking the number of SIGUSR1 in signal.ltrace
+set pattern "SIGUSR1"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern $count

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,68 @@
+/* Ltrace Test : system_calls.c.
+   Objectives  : Verify that Ltrace can trace all the system calls in
+   execution.
+
+   You can add new system calls in it and add its verification in 
+   system_calls correspondingly.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+void exit (int);
+
+#define	BUF_SIZE	100
+
+int 
+main ()
+{
+  FILE* fp;
+  char s[]="system_calls";
+  char buffer[BUF_SIZE];
+  struct stat state;
+  
+  /*  SYS_open.  */
+  fp = fopen ("system_calls.tmp", "w");
+  if (fp == NULL)
+    {
+      printf("Can not create system_calls.tmp\n");
+      exit (0);
+    }
+  /*  SYS_write.  */
+  fwrite(s, sizeof(s), 1, fp);
+  /*  SYS_lseek.  */
+  fseek (fp, 0, SEEK_CUR);
+  /*  SYS_read.  */
+  fread(buffer, sizeof(s), 1, fp);
+  /*  SYS_close.  */
+  fclose(fp);
+
+  /*  SYS_getcwd.  */
+  getcwd (buffer, BUF_SIZE);
+  /*  SYS_chdir.  */
+  chdir (".");
+  /*  SYS_symlink.  */
+  symlink ("system_calls.tmp", "system_calls.link");
+  /*  SYS_unlink.  */
+  remove("system_calls.link");
+  /*  SYS_rename.  */
+  rename ("system_calls.tmp", "system_calls.tmp1");
+  /*  SYS_stat.  */
+  stat ("system_calls.tmp", &state);
+  /*  SYS_access.  */
+  access ("system_calls.tmp", R_OK);
+  remove("system_calls.tmp1");
+  
+  /*  SYS_mkdir.  */
+  mkdir ("system_call_mkdir", 0777);
+  /*  SYS_rmdir.  */
+  rmdir ("system_call_mkdir");
+  
+  return 0;
+}
+
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.main/system_calls.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,67 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "system_calls"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-S"
+
+#Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+#check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+        return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+
+set pattern "SYS_munmap"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 2
+set pattern "SYS_write"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_unlink"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+
+set pattern "SYS_brk"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_open"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_fstat"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_mmap"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_close"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+
+set pattern "SYS_getcwd"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_chdir"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_symlink"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_unlink"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_stat"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_access"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_rename"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_mkdir"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "SYS_rmdir"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/Makefile.in
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/Makefile.in	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/Makefile.in	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,37 @@
+# Copyright (C) 1992 - 2001 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+CLEANFILES = *.log *.sum site.bak setval.tmp site.exp
+
+.SUFFIXES:	
+clean:
+	-rm -f demangle trace-fork trace-clone 
+	-rm -f time-record-tt time-record-ttt time-record-T
+	-rm -f attach-process count-record
+	-rm -f print-instruction-pointer
+	-rm -f *.o *.so 
+	-rm -f *.ltrace
+	-rm -f $(CLEANFILES)
+distclean: clean
+	-rm -f Makefile
+
+
+.PHONY: $(RECURSIVE_TARGETS) check  clean distclean realclean
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,16 @@
+/* Ltrace Test : attach-process.c.
+   Objectives  : Verify that ltrace can attach to a running process 
+   by its PID.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+
+#include<unistd.h>
+#include <sys/types.h>
+
+int 
+main ()
+{
+  sleep (5);
+  sleep (1);
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/attach-process.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,38 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "attach-process"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# Run the program and get PID of it.
+catch "exec $srcdir/$subdir/$binfile &" output
+
+# get PID from ps output.
+regexp {([0-9]+)} $output match PID
+verbose "PID = $PID"
+
+# Run PUT for ltarce.
+global LTRACE
+catch "exec $LTRACE -S -p $PID -o ${srcdir}/${subdir}/${testfile}.ltrace" exec_output
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+     	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Verify the output in attach-process.ltrace by checking the number 
+# of sleep.
+set pattern "sleep"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,51 @@
+/* Ltrace Test : count-record.c.
+   Objectives  : Verify that Ltrace can count all the system calls in
+   execution and report a summary on exit.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+void exit (int);
+
+#define	BUF_SIZE	100
+
+/*  Do as many operations as possible to record these calls.  */
+int 
+main ()
+{
+  FILE* fp;
+  char s[]="system_calls";
+  char buffer[BUF_SIZE];
+  struct stat state;
+	
+  fp = fopen ("system_calls.tmp", "w");
+  if (fp == NULL)
+    {
+      printf("Can not create system_calls.tmp\n");
+      exit (0);
+    }
+
+  fwrite(s, sizeof(s), 1, fp);
+  fseek (fp, 0, SEEK_CUR);
+  fread(buffer, sizeof(s), 1, fp);
+  fclose(fp);
+  
+  getcwd (buffer, BUF_SIZE);
+  chdir (".");
+  symlink ("system_calls.tmp", "system_calls.link");
+  remove("system_calls.link");
+  rename ("system_calls.tmp", "system_calls.tmp1");
+  stat ("system_calls.tmp", &state);
+  access ("system_calls.tmp", R_OK);
+  remove("system_calls.tmp1");
+  
+  mkdir ("system_call_mkdir", 0777);
+  rmdir ("system_call_mkdir");
+  
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/count-record.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,77 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "count-record"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-c"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+
+ltrace_saveoutput $exec_output $srcdir/$subdir/$binfile.ltrace
+
+#
+#  This is a sample output and Verify the forth and fifth column.
+#
+#  13.31    0.001051        1051         1 rmdir
+#  12.81    0.001012        1012         1 fopen
+#  10.32    0.000815         407         2 remove
+#   9.56    0.000755         755         1 mkdir
+#   7.86    0.000621         621         1 fseek
+#   6.86    0.000542         542         1 fwrite
+#   6.60    0.000521         521         1 fclose
+#   6.03    0.000476         476         1 rename
+#   5.61    0.000443         443         1 symlink
+#   5.05    0.000399         399         1 chdir
+#   4.80    0.000379         379         1 access
+#   4.00    0.000316         316         1 __xstat
+#   3.81    0.000301         301         1 getcwd
+#   3.39    0.000268         268         1 fread
+#
+
+set pattern "\'1 rmdir\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 fopen\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'2 remove\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 mkdir\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 fseek\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 fwrite\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 fclose\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 rename\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 symlink\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 chdir\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 access\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 getcwd\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+set pattern "\'1 fread\'"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle-lib.cpp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle-lib.cpp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle-lib.cpp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,97 @@
+#include<stddef.h>
+#include<iostream>
+
+#include"demangle.h"
+
+/* Number of arguments */
+int Fi_i(int bar) 		{ return 0; }
+int Fi_s(short bar) 		{return 0; }
+int Fii_i(int bar, int goo) 	{ return 0; }
+int Fiii_i(int bar, int goo, int hoo) { return 0; }
+int Fie_i(int bar, ...) 	{ return 0; }
+
+/* Return types */
+void Fv_v(void) 		{ ; }
+char Fv_c(void) 		{ return 0; }
+signed char Fv_Sc(void) 	{ return 0; }
+unsigned char Fv_Uc(void) 	{ return 0; }
+short Fv_s(void) 		{ return 0; }
+unsigned short Fv_Us(void) 	{ return 0; }
+int Fv_i(void) 			{ return 0; }
+const int Fv_Ci(void) 		{ return 0; }
+unsigned int Fv_Ui(void) 	{ return 0; }
+volatile int Fv_Vi(void) 	{ return 0; }
+long Fv_l(void) 		{ return 0; }
+unsigned long Fv_Ul(void) 	{ return 0; }
+float Fv_f(void) 		{ return 0; }
+double Fv_g(void) 		{ return 0; }
+long double Fv_Lg(void) 	{ return 0; }
+
+/* Pointers */
+void *Fv_Pv(void) 		{ return 0; }
+void **Fv_PPv(void) 		{ return 0; }
+
+/* References */
+int& Fv_Ri(void) 		{ static int x; return x; }
+
+/* Argument types */
+int FPi_i(int *a) 		{ return 0; }
+int FA10_i_i(int a[10]) 	{ return 0; }
+int Fc_i(char bar) 		{ return 0; }
+int Ff_i(float bar) 		{ return 0; }
+int Fg_i(double bar) 		{ return 0; }
+
+/* Function pointers */
+typedef int (*x)(int);
+typedef int (*y)(short);
+
+int Fx_i(x fnptr) 		{ return 0; }
+int Fxx_i(x fnptr, x fnptr2) 	{ return 0; }
+int Fxxx_i(x fnptr, x fnptr2, 
+	x fnptr3) 		{ return 0; }
+int Fxxi_i(x fnptr, x fnptr2, 
+	x fnptr3, int i) 	{ return 0; }
+int Fxix_i(x fnptr, int i, 
+	x fnptr3) 		{ return 0; }
+int Fxyxy_i(x fnptr, y fnptr2, 
+	x fnptr3, y fnptr4) 	{ return 0; }
+
+/* Class methods */
+class myclass;
+myclass::myclass(void) 		{ myint = 0; }
+myclass::myclass(int x) 	{ myint = x; }
+myclass::~myclass() 		{ ; }
+
+int myclass::Fi_i(int bar) 	{ return myint; }
+int myclass::Fis_i(int bar) 	{ return bar; }
+
+void* myclass::operator new(size_t size)
+{
+  void* p = malloc(size);return p;
+}
+void myclass::operator delete(void *p) {free(p);}
+
+myclass myclass::operator++() 	{ return myclass(++myint); }
+myclass myclass::operator++(int) { return myclass(myint++); }
+
+/* Binary */
+myclass myclass::operator+(int x) { return myclass(myint + x); }
+
+/* Assignment */
+myclass& myclass::operator=(const myclass& from) 
+{ 
+	myint = from.myint; 
+	return *this; 
+}
+
+/* test clashes */
+class nested;
+
+nested::nested(void) 		{ ; }
+nested::~nested() 		{ ; }
+int nested::Fi_i(int bar) 	{ return bar; }
+
+void Fmyclass_v(myclass m) 	{ ; }
+void Fmxmx_v(myclass arg1, x arg2, 
+	myclass arg3, x arg4) 	{ ; }
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.cpp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.cpp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.cpp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,121 @@
+/* Ltrace Test : demangle.cpp
+   Objectives  : Verify that ltrace can demangle C++ symbols.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+
+#include<stddef.h>
+#include"demangle.h"
+
+/* Number of arguments */
+extern int Fi_i(int);
+extern int Fi_s (short);
+extern int Fii_i(int , int);
+extern int Fiii_i(int, int, int);
+extern int Fie_i(int bar, ...);
+
+/* Return types */
+extern void Fv_v(void);
+extern char Fv_c(void);
+extern signed char Fv_Sc(void);
+extern unsigned char Fv_Uc(void);
+extern short Fv_s(void);
+extern unsigned short Fv_Us(void);
+extern int Fv_i(void);
+extern const int Fv_Ci(void);
+extern unsigned int Fv_Ui(void);
+extern volatile int Fv_Vi(void);
+extern long Fv_l(void);
+extern unsigned long Fv_Ul(void);
+extern float Fv_f(void) ;
+extern double Fv_g(void);
+extern long double Fv_Lg(void);
+
+
+/* Pointers */
+extern void * Fv_Pv(void);
+extern void ** Fv_PPv(void);
+
+/* References */
+extern int& Fv_Ri(void);
+
+/* Argument types */
+extern int FPi_i(int *a);
+extern int FA10_i_i(int a[10]) ;
+extern int Fc_i(char bar);
+extern int Ff_i(float bar);
+extern int Fg_i(double bar);
+
+/* Function pointers */
+typedef int (*x)(int);
+typedef int (*y)(short);
+
+extern int Fx_i(x);
+extern int Fxx_i(x fnptr, x fnptr2);
+extern int Fxxx_i(x fnptr, x fnptr2, x fnptr3);
+extern int Fxxi_i(x fnptr, x fnptr2, x fnptr3, int i);
+extern int Fxix_i(x fnptr, int i, x fnptr3);
+extern int Fxyxy_i(x fnptr, y fnptr2, x fnptr3, y fnptr4);
+
+
+extern void Fmyclass_v(myclass m);
+extern void Fmxmx_v(myclass arg1, x arg2, myclass arg3, x arg4);
+
+int main ()
+{
+  int i;
+
+  i = Fi_i (0);
+  i = Fii_i (0,0);
+  i = Fiii_i (0,0,0);
+  i = Fie_i (0);
+
+  Fv_v ();
+  Fv_c ();
+  Fv_Sc ();
+  Fv_Uc ();
+  Fv_s ();
+  Fv_Us ();
+  Fv_i ();
+  Fv_Ci ();
+  Fv_Ui ();
+  Fv_Vi ();
+  Fv_l ();
+  Fv_Ul ();
+  Fv_f ();
+  Fv_g ();
+  Fv_Lg ();
+
+  Fv_Pv ();
+  Fv_PPv ();
+	
+  Fv_Ri ();
+
+  FPi_i (&i);
+  FA10_i_i (&i);
+  Fc_i ('a');
+  Ff_i (1.1f);
+  Fg_i (1.1);
+
+  Fx_i (Fi_i);
+  Fxx_i (Fi_i, Fi_i);
+  Fxxx_i (Fi_i, Fi_i, Fi_i);
+  Fxxi_i (Fi_i, Fi_i, Fi_i, 0);
+  Fxyxy_i (Fi_i, Fi_s, Fi_i, Fi_s);
+
+  myclass a,c;
+  myclass* b;
+  
+  a.Fi_i (0);
+  a.Fis_i (0);
+  a++;
+  c = a + 2;
+  
+  nested n;  
+  n.Fi_i (0);
+
+  b = (myclass*) new myclass(0);
+  delete (b);
+  Fmyclass_v (a);
+
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,63 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "demangle"
+set srcfile ${testfile}.cpp
+set binfile ${testfile}
+set libfile "demangle-lib"
+set libsrc $srcdir/$subdir/$libfile.cpp
+set lib_sl $srcdir/$subdir/lib$testfile.so
+
+verbose "compiling source file now....."
+if [get_compiler_info $binfile "c++"] {
+  return -1
+}
+
+verbose "compiling source file now....."
+if { [ltrace_compile_shlib $libsrc $lib_sl [list debug c++]] != ""
+  || [ltrace_compile $srcdir/$subdir/$srcfile $srcdir/$subdir/$binfile executable [list debug shlib=$lib_sl c++] ] != ""} {
+  send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-C"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# read function declarations from demangle.cpp and verify them in demangle.ltrace.
+set fd [ open $srcdir/$subdir/$srcfile r]
+while { [gets $fd line] >= 0 } {
+    if [regexp {extern (double|float|void|char|int|short|long|void \*|void \*\*) ([^ ])\(} $line match type fun] {
+	ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $fun
+    }
+}
+close $fd
+
+#read member fucntions of classs from demangle-lib.cpp and verify them in demagle.ltrace.
+set fd [ open $srcdir/$subdir/$testfile-lib.cpp r]
+while { [gets $fd line] >= 0 } {
+    if [ regexp {((myclass|nested)::[^\(]*)\(} $line match fun] {
+	# For Debug purpose.
+        verbose "fun = $fun"
+	# Extract new/delete for remove extra SPACE in $fun, for example,
+	# $fun = "myclass::operator delete" will confuse ltrace_verify_output if it
+	# was an argument to it.
+	if [regexp {(new|delete)} $fun match sub_fun] {
+	    ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $sub_fun
+	} else {
+	    # Verify class member functions without SPACE.
+	    ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $fun
+	}
+    }
+}
+close $fd

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.h
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.h	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/demangle.h	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,36 @@
+
+class myclass {
+  int myint;
+ public:
+  myclass(int x);
+  myclass(void);
+  ~myclass();
+  static int Fis_i(int bar);
+  int Fi_i(int bar);
+  /* Overloaded operators */
+  void* operator new(size_t);
+  void operator delete(void *);
+  /* Unary operation.  */
+  myclass operator++();// Preincrement
+  myclass operator++(int);// Postincrement
+
+  /* Binary operation.  */
+  myclass operator+(int);
+
+  /* Assignment */
+  myclass& operator=(const myclass& from);
+  /* Nested classes */
+  class nested {
+  public:
+    nested();
+    ~nested();
+    int Fi_i(int bar);
+  };
+};
+
+class nested {
+ public:
+  nested();
+  ~nested();
+  int Fi_i(int bar);
+};

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int main ()
+{
+  int i=0;
+  printf("%d\n",i);
+  i=1;
+  printf("%d\n",i);
+  
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/print-instruction-pointer.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,42 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "print-instruction-pointer"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if { [ltrace_compile "${srcdir}/${subdir}/${srcfile}" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-i"
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return 
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Get the addrss by objdump and sed.
+catch "exec sh -c {objdump -d $srcdir/$subdir/$binfile | sed -n '/^\[0-9a-fA-F\]\[0-9a-fA-F\]* <main>/,/^\[0-9a-fA-F\]\[0-9a-fA-F\]* </p'| grep -A 1 'call\\|bl' }" output
+#verbose "output=$output"
+catch "exec sh -c {echo \"$output\" | sed -n '2p'| awk -F' ' '{print \$1}'|awk -F: '{print \$1}'}" addr1
+catch "exec sh -c {echo \"$output\" | sed -n '5p'| awk -F' ' '{print \$1}'|awk -F: '{print \$1}'}" addr2
+
+verbose "addr1 = $addr1"
+verbose "addr2 = $addr2"
+# Verify the output by checking numbers of print in main.ltrace.
+set pattern "$addr1.*printf"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+
+set pattern "$addr2.*printf"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-T.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-T.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-T.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,84 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "time-record"
+set srcfile ${testfile}.c
+set binfile ${testfile}-T
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# set options for ltrace.
+ltrace_options "-T"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+verbose "ltrace runtest output: $exec_output\n"
+
+# Check the output of this program.
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Get the time of nanosleep in C source file.
+set fd [ open $srcdir/$subdir/$srcfile r]
+while { [gets $fd line] >= 0 } {
+	if [ regexp {define NANOSLEEP_COUNT ([0-9]+)} $line match nanosleep_usec] then {
+	break
+	}
+}
+close $fd
+
+
+# Verify the time for calling sleep.
+set fd [ open $srcdir/$subdir/$binfile.ltrace r]
+set FOUND 0
+while { [gets $fd line] >= 0 } {
+	# match the line with sleep and extract the spent time in sleep and sleep argument.
+	if [ regexp {sleep\(([0-9]+).*<([0-9]+\.[0-9]+)>} $line match  sleep_sec sec ] then {
+		verbose "sleep_sec = $sleep_sec, sec = $sec"
+
+		if { $sec >= $sleep_sec } then {
+			pass "Correct Time spent inside call."
+		} else {
+			fail "Spent $sec inside call, but PUT call sleep($sleep_sec)!"
+		}
+	set FOUND 1
+	break
+        }
+}
+close $fd
+
+if {$FOUND != 1} then {
+	fail "Fail to find call sleep!"
+}
+
+#  Verify the time for calling nanosleep.
+set FOUND 0
+set fd [ open $srcdir/$subdir/$binfile.ltrace r]
+while { [gets $fd line] >= 0 } {
+        # match the line with nanosleep and extract spent time and nanosleep argument.
+        if [ regexp {nanosleep.*<([0-9]+\.[0-9]+)>} $line match usec] then {
+                verbose "nanosleep_usec = $nanosleep_usec, usec = $usec"
+
+                if { $usec * 1000 >= $nanosleep_usec} then {
+                        pass "Correct Time spent inside call."
+                } else {
+                        fail "Spent $usec inside call, but PUT call nanosleep($nanosleep_usec)!"
+                }
+        set FOUND 1
+        break
+        }
+}
+
+if { $FOUND != 1} then {
+	fail "Fail to find nanosleep"
+}
+close $fd
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-tt.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-tt.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-tt.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,107 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "time-record"
+set srcfile ${testfile}.c
+set binfile ${testfile}-tt
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# Set options for ltrace.
+ltrace_options "-tt"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Verify the time for calling sleep.
+set fd [ open $srcdir/$subdir/$binfile.ltrace r]
+set FOUND 0
+while { [gets $fd line] >= 0 } {
+	# match the line with sleep and extract the strat time and sleep argument.
+	if [ regexp {[0-9]+:([0-9]+):([0-9]+)\.[0-9]+ sleep\(([0-9]+)} $line match start_min start_sec sleep_sec] then {
+		# Remove extra zero.
+		regexp {0([1-9])} $start_min match start_min
+		regexp {0([1-9])} $start_sec match start_sec
+
+		verbose "start_sec = $start_sec, sleep_sec = $sleep_sec"
+		# get a new line for the end time of sleep
+		gets $fd line
+		regexp {[0-9]+:([0-9]+):([0-9]+)} $line match end_min end_sec
+		verbose "end_sec = $end_sec"
+
+		# Remove extra zero.
+		regexp {0([1-9])} $end_min match end_min
+		regexp {0([1-9])} $end_sec match end_sec
+
+		if { (($end_min - $start_min)*60 + $end_sec - $start_sec)== $sleep_sec } then {
+			pass "Correct Timestamp."
+		} else {
+			fail "Start at $start_sec, End at $end_sec, but PUT call sleep($sleep_sec)!"
+		}
+	set FOUND 1
+	break
+        }
+}
+close $fd
+
+if {$FOUND != 1} then {
+	fail "Fail to find call sleep!"
+}
+
+# Get the time of sleep and nanosleep in C source file.
+set fd [ open $srcdir/$subdir/$srcfile r]
+while { [gets $fd line] >= 0 } {
+        if [ regexp {define NANOSLEEP_COUNT ([0-9]+)} $line match nanosleep_usec] then {
+        break
+        }
+}
+close $fd
+
+#  Verify the time for calling nanosleep.
+set FOUND 0
+set fd [ open $srcdir/$subdir/$binfile.ltrace r]
+while { [gets $fd line] >= 0 } {
+        # match the line with sleep and extract the strat time and sleep argument.
+        if [ regexp {[0-9]+:[0-9]+:([0-9]+)\.([0-9][0-9][0-9]).* nanosleep} $line match start_sec start_usec ] then {
+		# Remove extra zeros.
+		regexp {0([1-9])} $start_sec match start_sec
+		regexp {0*([1-9][0-9]*)} $start_usec match start_usec
+
+                verbose "start_sec = $start_sec, start_usec = $start_usec, sleep_usec = $nanosleep_usec"
+                # get a new line for the end time of sleep
+                gets $fd line
+                regexp {[0-9]+:[0-9]+:([0-9]+)\.([0-9][0-9][0-9])} $line match end_sec end_usec
+
+		# Remove extra zeros.
+		regexp {0([1-9])} $end_sec match end_sec
+		regexp {0*([1-9][0-9]*)} $end_usec match end_usec
+
+                verbose "end_sec = $end_sec, end_usec = $end_usec"
+                if { (($end_sec - $start_sec)*1000 + $end_usec - $start_usec) >= $nanosleep_usec} then {
+                        pass "Correct Timestamp."
+                } else {
+                        fail "Start at $start_usec, End at $end_usec, but PUT call nanosleep($nanosleep_usec)!"
+                }
+        set FOUND 1
+        break
+        }
+}
+
+if { $FOUND != 1} then {
+	fail "Fail to find nanosleep"
+}
+close $fd
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-ttt.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-ttt.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record-ttt.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,112 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "time-record"
+set srcfile ${testfile}.c
+set binfile ${testfile}-ttt
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+
+# Set options for ltrace.
+ltrace_options "-ttt"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Verify the time for calling sleep.
+set fd [ open $srcdir/$subdir/$binfile.ltrace r]
+set FOUND 0
+while { [gets $fd line] >= 0 } {
+	# match the line with sleep and extract the strat time and sleep argument.
+	if [ regexp {([0-9]+)\.([0-9][0-9][0-9]).* sleep\(([0-9]+)} $line match start_sec start_usec sleep_sec] then {
+
+		# Remove extra zeros.
+		regexp {0*([1-9][0-9]*)} $start_sec match start_sec
+		regexp {0*([1-9][0-9]*)} $start_usec match start_usec
+
+		verbose "start_sec = $start_sec, start_usec = $start_usec,sleep_sec = $sleep_sec"
+		# get a new line for the end time of sleep
+		gets $fd line
+		regexp {([0-9]+)\.([0-9][0-9][0-9])} $line match end_sec end_usec
+		verbose "end_sec = $end_sec, end_usec=$end_usec"
+
+		# Remove extra zeros.
+		regexp {0*([1-9][0-9]*)} $end_sec match end_sec
+		regexp {0*([1-9][0-9]*)} $end_usec match end_usec
+
+		if { $end_sec - $start_sec >= $sleep_sec } then {
+			pass "Correct Timestamp."
+		} else {
+			fail "Start at $start_sec, End at $end_sec, but PUT call sleep($sleep_sec)!"
+		}
+	set FOUND 1
+	break
+        }
+}
+
+close $fd
+
+if {$FOUND != 1} then {
+	fail "Fail to find call sleep!"
+}
+
+
+# Get the time of nanosleep in C source file.
+set fd [ open $srcdir/$subdir/$srcfile r]
+while { [gets $fd line] >= 0 } {
+        if [ regexp {define NANOSLEEP_COUNT ([0-9]+)} $line match nanosleep_usec] then {
+        break
+        }
+}
+close $fd
+
+#  Verify the time for calling nanosleep.
+set FOUND 0
+set fd [ open $srcdir/$subdir/$binfile.ltrace r]
+while { [gets $fd line] >= 0 } {
+        # match the line with sleep and extract the strat time and sleep argument.
+        if [ regexp {([0-9]+)\.([0-9][0-9][0-9]).* nanosleep} $line match start_sec start_usec ] then {
+
+		# Remove extra zeros.
+		regexp {0*([1-9][0-9]*)} $start_sec match start_sec
+		regexp {0*([1-9][0-9]*)} $start_usec match start_usec
+
+                verbose "start_sec = $start_sec, start_usec = $start_usec, nanosleep_usec = $nanosleep_usec"
+                # get a new line for the end time of sleep
+                gets $fd line
+                regexp {([0-9]+)\.([0-9][0-9][0-9])} $line match end_sec end_usec
+
+		# Remove extra zeros.
+		regexp {0*([1-9][0-9]*)} $end_sec match end_sec
+		regexp {0*([1-9][0-9]*)} $end_usec match end_usec
+
+                verbose "end_sec = $end_sec, end_usec = $end_usec"
+                if { ($end_sec - $start_sec)*1000 + $end_usec - $start_usec >= $nanosleep_usec} then {
+                        pass "Correct Timestamp."
+                } else {
+                        fail "Start at $start_usec, End at $end_usec, but PUT call nanosleep($nanosleep_usec)!"
+                }
+        set FOUND 1
+        break
+        }
+}
+
+if { $FOUND != 1} then {
+	fail "Fail to find nanosleep"
+}
+close $fd
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/time-record.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,23 @@
+/* Ltrace Test : time-record.c.
+   Objectives  : Verify that Ltrace can record timestamp and spent
+   time inside each call.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+#include <stdio.h>
+#include <time.h>
+
+#define SLEEP_COUNT 2
+#define NANOSLEEP_COUNT 50
+
+int 
+main ()
+{
+  struct timespec request, remain;
+  request.tv_sec = 0;
+  request.tv_nsec = NANOSLEEP_COUNT * 1000000;
+  
+  sleep (SLEEP_COUNT);
+  nanosleep (&request, NULL);
+  
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,31 @@
+/* Ltrace Test : trace-clone.c.
+   Objectives  : Verify that ltrace can trace to child process after
+   clone called.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sched.h>
+
+int child ()
+{
+  return 0;
+}
+
+typedef int (* myfunc)();
+
+int main ()
+{
+  pid_t pid;
+  static char stack[1024];
+  
+  if ((pid = clone((myfunc)&child, stack,CLONE_FS, NULL )) < 0)
+    {
+      perror("clone called failed");
+      exit (1);
+    }
+  
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-clone.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,44 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "trace-clone"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+global LTRACE
+
+#Run PUT for ltarce.
+spawn $LTRACE -f $srcdir/$subdir/$binfile
+set timeout 4
+expect timeout  {
+        fail "Time out! Maybe caused by ltrace segment fault or improper timeout value here!"
+        return
+}
+
+catch "exec $LTRACE -f $srcdir/$subdir/$binfile" exec_output
+# Save the output
+ltrace_saveoutput "${exec_output}" ${srcdir}/${subdir}/${testfile}.ltrace
+
+#check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Operation not permitted} $exec_output ] {
+        fail "Operation not permitted, see testrun.log for details!"
+        return
+} elseif [ regexp {killed by SIGKILL} $exec_output ] {
+        fail "killed by SIGKILL!"
+        return
+}
+
+
+
+set pattern "clone"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,33 @@
+/* Ltrace Test : trace-fork.c
+   Objectives  : Verify that ltrace can trace to child process after
+   fork called.
+
+   This file was written by Yao Qi <qiyao at cn.ibm.com>.  */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+void 
+child ()
+{
+  printf("Fork Child\n");
+  sleep(1);
+}
+
+int 
+main ()
+{
+  pid_t pid;
+  pid = fork ();
+  
+  if (pid == -1)
+    printf("fork failed!\n");
+  else if (pid == 0)
+    child();
+  else
+    {
+      printf("My child pid is %d\n",pid);
+      wait(); 
+    }
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.minor/trace-fork.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,40 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "trace-fork"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
+}
+global LTRACE
+set exec_output ""
+
+#Run PUT for ltarce.
+spawn $LTRACE -f $srcdir/$subdir/$binfile
+set timeout 4
+expect timeout  {
+	fail "Time out! Maybe caused by ltrace segment fault or improper timeout value here!"
+	return
+}
+
+catch "exec $LTRACE -f $srcdir/$subdir/$binfile" exec_output
+
+#check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+ltrace_saveoutput "${exec_output}" ${srcdir}/${subdir}/${testfile}.ltrace
+
+set pattern "fork"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/Makefile.in
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/Makefile.in	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/Makefile.in	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,34 @@
+# Copyright (C) 1992 - 2001 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+CLEANFILES = *.log *.sum site.bak setval.tmp site.exp
+
+.SUFFIXES:	
+clean:
+	-rm -f signals 
+	-rm -f *.o *.so 
+	-rm -f *.ltrace
+	-rm -f $(CLEANFILES)
+distclean: clean
+	-rm -f Makefile
+
+
+.PHONY: $(RECURSIVE_TARGETS) check  clean distclean realclean
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.c
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.c	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.c	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,44 @@
+/* Ltrace Test : signals.c.
+   Objectives  : Verify that ltrace can trace user defined signal.
+   This file was written by Yao Qi <qiyao at cn.ibm.com>. */
+
+#include<stdio.h>
+#include<signal.h>
+#include <sys/types.h>
+
+#define LOOP	20
+
+void 
+handler(int signum,siginfo_t *info,void *act)
+{
+}
+
+int 
+main ()
+{
+  struct sigaction act;	
+  union sigval mysigval;
+  int i;
+  int sig;
+  pid_t pid;
+  
+  mysigval.sival_int=0;
+  sig = 10;
+  pid=getpid();
+  
+  sigemptyset(&act.sa_mask);
+  act.sa_sigaction=handler;
+  act.sa_flags=SA_SIGINFO;
+  
+  if(sigaction(sig,&act,NULL) < 0)
+    {
+      printf("install sigal error\n");
+    }
+  
+  for(i=0; i< LOOP; i++)
+    {
+      usleep(100);
+      sigqueue(pid,sig,mysigval);
+    }
+  return 0;
+}

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.exp
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.exp	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/ltrace.torture/signals.exp	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,37 @@
+# This file was written by Yao Qi <qiyao at cn.ibm.com>.
+
+set testfile "signals"
+set srcfile ${testfile}.c
+set binfile ${testfile}
+
+
+verbose "compiling source file now....."
+# Build the shared libraries this test case needs.
+if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.c" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
+     send_user "Testcase compile failed, so all tests in this file will automatically fail\n."
+}
+
+# Set options for ltrace.
+ltrace_options "-L"
+
+# Run PUT for ltarce.
+set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
+
+# Check the output of this program.
+verbose "ltrace runtest output: $exec_output\n"
+if [regexp {ELF from incompatible architecture} $exec_output] {
+	fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
+	return
+} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
+	fail "Couldn't get .hash data!"
+	return
+}
+
+# Extract LOOP from source file.
+set fd [ open $srcdir/$subdir/$srcfile r]
+while { [gets $fd line] >= 0 } {
+         regexp {define LOOP.*([0-9]+)} $line match count
+}
+set pattern "SIGUSR1"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern $count
+

Added: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/run-my-tests.sh
===================================================================
--- ltrace/branches/ltrace-powerpc-secure-plt/testsuite/run-my-tests.sh	2006-03-05 22:23:42 UTC (rev 31)
+++ ltrace/branches/ltrace-powerpc-secure-plt/testsuite/run-my-tests.sh	2006-03-10 23:13:20 UTC (rev 32)
@@ -0,0 +1,43 @@
+#! /bin/sh
+bitmode=""
+
+# This shell script is used to run the ltrace test suite.  It is possible to
+# run it via 'make check' using RUNTESTFLAGS.  This script just makes it easy.
+
+function usage
+{
+  echo usage: `basename $0` '-m32|-m64 [<tool> | ""] [<test.exp>]'
+}
+
+# The first argument is not optional: it must either be -m32 or -m64.  If the
+# second argument is used, it specifies the file name of the ltrace to be
+# tested.  The third argument specifies a particular test case to run.  If
+# the third argument is omitted, then all test cases are run.  If you wish to
+# use the third argument, but not the second, specify the second as "".
+
+# there is a secret argument: if the name of this script is 'test', then
+# the --verbose argument is added to RUNTESTFLAGS.
+
+if [ x"$1" == x -o x"$1" != x-m32 -a x"$1" != x-m64 ]; then
+  usage
+  exit 1
+fi
+
+flags=''
+
+if [ `basename $0` == test ]; then
+  flags="--verbose "
+fi
+
+if [ x"$2" != x ]; then
+  flags="${flags}--tool_exec=$2 "
+fi
+
+flags="${flags}CFLAGS_FOR_TARGET=$1"
+
+if [ x"$3" != x ]; then
+  flags="$flags $3"
+fi
+
+set -o xtrace
+make check RUNTESTFLAGS="$flags"


Property changes on: ltrace/branches/ltrace-powerpc-secure-plt/testsuite/run-my-tests.sh
___________________________________________________________________
Name: svn:executable
   + *




More information about the Ltrace-devel mailing list