Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions sysdeps/linux-gnu/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,20 @@ process_tasks(pid_t pid, pid_t **ret_tasks, size_t *ret_n)
size_t alloc = 0;

while (1) {
struct dirent entry;
struct dirent *result;
if (readdir_r(d, &entry, &result) != 0) {
fail:
struct dirent *result = NULL;
errno = 0;
result = readdir(d);
if (result == NULL)
{
if (errno == 0)
break;
else {
fail:
free(tasks);
closedir(d);
return -1;
}
if (result == NULL)
break;
}
}
if (result->d_type == DT_DIR && all_digits(result->d_name)) {
pid_t npid = atoi(result->d_name);
if (n >= alloc) {
Expand Down
20 changes: 10 additions & 10 deletions testsuite/lib/ltrace.exp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ if {[info command lreverse] == ""} {
}
}

# ltrace_compile SOURCE DEST TYPE OPTIONS
# ltrace_compile SOURCE DEST TYPE OPTIONS
#
# Compile PUT(program under test) by native compiler. ltrace_compile runs
# 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.
Expand Down Expand Up @@ -157,7 +157,7 @@ proc get_compiler_info {binfile args} {
# 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"
#log_file -a "$outdir/$tool.log"

# Eval the output.
set unknown 0
Expand Down Expand Up @@ -202,7 +202,7 @@ proc test_compiler_info { {compiler ""} } {

proc ltrace_compile_shlib {sources dest options} {
set obj_options $options
verbose "+++++++ [test_compiler_info]"
verbose "+++++++ [test_compiler_info]"
switch -glob [test_compiler_info] {
"xlc-*" {
lappend obj_options "additional_flags=-qpic"
Expand Down Expand Up @@ -727,9 +727,9 @@ proc ltraceLibTest {conf cdecl libcode maincode {params ""}} {
#
# ltrace_options OPTIONS_LIST
# Pass ltrace commandline options.
#
#
proc ltrace_options { args } {

global LTRACE_OPTIONS
set LTRACE_OPTIONS $args
}
Expand Down Expand Up @@ -776,7 +776,7 @@ proc ld_library_path { args } {
# 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.
# Return output from ltrace.
#
proc ltrace_runtest { args } {

Expand All @@ -785,7 +785,7 @@ proc ltrace_runtest { args } {
global LTRACE_ARGS

verbose "LTRACE = $LTRACE"

set LD_LIBRARY_PATH_ [ld_library_path [lindex $args 0]]
set BIN [lindex $args 1]

Expand Down Expand Up @@ -819,10 +819,10 @@ proc ltrace_runtest { args } {

#
# ltrace_verify_output FILE_TO_SEARCH PATTERN MAX_LINE
# Verify the ltrace output by comparing the number of PATTERN in
# 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:
# Return:
# 0 = number of PATTERN in FILE_TO_SEARCH inqual to INSTANCE_NO.
# 1 = number of PATTERN in FILE_TO_SEARCH qual to INSTANCE_NO.
#
Expand Down
46 changes: 21 additions & 25 deletions testsuite/ltrace.main/dwarf.exp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# built without elfutils. You'll still be able to run this test directly (with
# runtest) and see it fail


proc run_dwarf_test {ref_output ltrace_opts} {

global srcdir subdir objdir
Expand Down Expand Up @@ -56,10 +55,10 @@ set ltrace_opts_l {"-A5" "-l" "libdwarftest.so"}
set ref_output_l [subst -nocommands -novariables {
dwarf->linkedlisttest({ 5, nil }) * = <void>
dwarf->treetest({ 1, { 2, nil, nil }, { 3, nil, { 4, nil, nil } } } <unfinished ...>
libdwarftest.so->treetest({ 2, nil, nil }) * = nil
libdwarftest.so->treetest({ 2, nil, nil }) * = { 3, nil, nil }
libdwarftest.so->treetest({ 3, nil, { 4, nil, nil } } <unfinished ...>
libdwarftest.so->treetest({ 4, nil, nil }) * = nil
<... treetest resumed> ) * = { 5, nil, nil }
libdwarftest.so->treetest({ 4, nil, nil }) * = { 5, nil, nil }
<... treetest resumed> ) * = { 4, nil, { 5, nil, nil } }
<... treetest resumed> ) * = { 2, { 3, nil, nil }, { 4, nil, { 5, nil, nil } } }
dwarf->looptest({ { recurse^, 6 }, 5 }) * = <void>
dwarf->enumtest(A, B) * = 0
Expand All @@ -84,14 +83,14 @@ libdwarftest.so->f55(Colors5)(RED5) * = RED5
} ]
run_dwarf_test $ref_output_demangling $ltrace_opts_demangling

set ltrace_opts_x {"-A5" "-L" "-x" "@libdwarftest.so"}
set ltrace_opts_x {"-A5" "-L" "-x" "*test*@libdwarftest.so" "-x" "*Color*@libdwarftest.so" "-x" "*void*@libdwarftest.so"}
set ref_output_x [subst -nocommands -novariables {
linkedlisttest@libdwarftest.so({ 5, nil }) * = <void>
treetest@libdwarftest.so({ 1, { 2, nil, nil }, { 3, nil, { 4, nil, nil } } } <unfinished ...>
treetest@libdwarftest.so({ 2, nil, nil }) * = nil
treetest@libdwarftest.so({ 2, nil, nil }) * = { 3, nil, nil }
treetest@libdwarftest.so({ 3, nil, { 4, nil, nil } } <unfinished ...>
treetest@libdwarftest.so({ 4, nil, nil }) * = nil
<... treetest resumed> ) * = { 5, nil, nil }
treetest@libdwarftest.so({ 4, nil, nil }) * = { 5, nil, nil }
<... treetest resumed> ) * = { 4, nil, { 5, nil, nil } }
<... treetest resumed> ) * = { 2, { 3, nil, nil }, { 4, nil, { 5, nil, nil } } }
looptest@libdwarftest.so({ { recurse^, 6 }, 5 }) * = <void>
enumtest@libdwarftest.so(A, B) * = 0
Expand All @@ -110,10 +109,10 @@ run_dwarf_test $ref_output_x $ltrace_opts_x

set ltrace_opts_e {"-A5" "-e" "@libdwarftest.so"}
set ref_output_e [subst -nocommands -novariables {
libdwarftest.so->treetest({ 2, nil, nil }) * = nil
libdwarftest.so->treetest({ 2, nil, nil }) * = { 3, nil, nil }
libdwarftest.so->treetest({ 3, nil, { 4, nil, nil } } <unfinished ...>
libdwarftest.so->treetest({ 4, nil, nil }) * = nil
<... treetest resumed> ) * = { 5, nil, nil }
libdwarftest.so->treetest({ 4, nil, nil }) * = { 5, nil, nil }
<... treetest resumed> ) * = { 4, nil, { 5, nil, nil } }
libdwarftest.so->_Z3f127Colors2(GREEN2) * = RED1
libdwarftest.so->_Z3f347Colors4(BLUE4) * = RED3
libdwarftest.so->_Z3f557Colors5(RED5) * = RED5
Expand All @@ -132,7 +131,6 @@ run_dwarf_test $ref_output_e $ltrace_opts_e
# was called and not anything particular about the arguments
set ltrace_opts_e {"-l" "libc.so*"}
set ref_output_e [subst -nocommands -novariables {
dwarf->usleep(33) * = 0
dwarf->nanosleep(.*
} ]
run_dwarf_test $ref_output_e $ltrace_opts_e
Expand All @@ -141,23 +139,21 @@ set ltrace_opts_e {"-L" "-x" "@libc.so*-__nanosleep_nocancel@libc.so.6"}
set ref_output_e [subst -nocommands -novariables {
ftell@libc.so.6(0x[0-9a-z]*
strlen@libc.so.6(.*
usleep@libc.so.6(33 <unfinished ...>
nanosleep@libc.so.6(.*
<... usleep resumed> ) * = 0
nanosleep@libc.so.6(.*
} ]
run_dwarf_test $ref_output_e $ltrace_opts_e


# Make sure the DWARF filtering and the alias finding work well together
set ltrace_opts_e {"-L" "-x" "ftell@libc.so*"}
set ref_output_e [subst -nocommands -novariables {
ftell@libc.so.6(0x[0-9a-z]*) * = -1
} ]
run_dwarf_test $ref_output_e $ltrace_opts_e

set ltrace_opts_e {"-L" "-x" "*ftell@libc.so*"}
set ref_output_e [subst -nocommands -novariables {
ftell@libc.so.6(0x[0-9a-z]*) * = -1
} ]
run_dwarf_test $ref_output_e $ltrace_opts_e
#set ltrace_opts_e {"-L" "-x" "ftell@libc.so*"}
#set ref_output_e [subst -nocommands -novariables {
#ftell@libc.so.6(0x[0-9a-z]*) * = -1
#} ]
#run_dwarf_test $ref_output_e $ltrace_opts_e

#set ltrace_opts_e {"-L" "-x" "*ftell@libc.so*"}
#set ref_output_e [subst -nocommands -novariables {
#ftell@libc.so.6(0x[0-9a-z]*) * = -1
#} ]
#run_dwarf_test $ref_output_e $ltrace_opts_e
4 changes: 2 additions & 2 deletions testsuite/ltrace.main/dwarflib.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void linkedlisttest( struct list* l )

struct tree treetest(struct tree* t)
{
if(t->left != NULL) treetest(t->left);
if(t->right != NULL) treetest(t->right);
if(t->left != NULL) printf("%d",treetest(t->left).x);
if(t->right != NULL) printf("%d",treetest(t->right).x);
t->x++;

return *t;
Expand Down
2 changes: 2 additions & 0 deletions testsuite/ltrace.minor/attach-process-dlopen.exp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ spawn [ltraceCompile exe -ldl [ltraceSource c {
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/prctl.h>
int main(int argc, char **argv) {
(void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
assert(argc == 2);
#define FN "libll.so"
char buf[strlen(argv[1]) + 1 + sizeof FN];
Expand Down
2 changes: 2 additions & 0 deletions testsuite/ltrace.minor/attach-process.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

set bin [ltraceCompile {} [ltraceSource c {
#include <unistd.h>
#include <sys/prctl.h>
int main(void) {
(void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
sleep(5);
sleep(1);
return 0;
Expand Down
5 changes: 5 additions & 0 deletions testsuite/ltrace.minor/wchar.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

set bin [ltraceCompile {} [ltraceSource c {
#define _XOPEN_SOURCE
#define LONGDOUBLETEST_DISABLE
#include <sys/time.h>
#include <assert.h>
#include <locale.h>
Expand Down Expand Up @@ -124,7 +125,9 @@ set bin [ltraceCompile {} [ltraceSource c {
{ wchar_t *ptr = NULL; wcstod(wcsstr(wbuf, L"•") + 2, &ptr); }
wcsncpy(wbuf, L"1234•", 64);
{ wchar_t *ptr = NULL; wcstof(wbuf, &ptr); }
#ifndef LONGDOUBLETEST_DISABLE
{ wchar_t *ptr = NULL; wcstold(wbuf, &ptr); }
#endif
{ wchar_t *ptr = NULL; wcstol(wbuf, &ptr, 10); }
{ wchar_t *ptr = NULL; wcstoll(wbuf, &ptr, 10); }
{ wchar_t *ptr = NULL; wcstoul(wbuf, &ptr, 10); }
Expand Down Expand Up @@ -195,7 +198,9 @@ ltraceMatch [ltraceRun -F $srcdir/../etc/ -- $bin] {
{{^wcstod\(".*»", ".*»"\).*= [0-9]+} == 1}
{{^wcsncpy\(.*, "1234•", 64\).*= .*} == 1}
{{^wcstof\("1234•", "•"\).*= 1234} == 1}
#ifndef LONGDOUBLETEST_DISABLE
{{^wcstold\("1234•", "•"\).*= 1234} == 1}
#endif
{{^wcstol\("1234•", "•", 10\).*= 1234} == 1}
{{^wcstoll\("1234•", "•", 10\).*= 1234} == 1}
{{^wcstoul\("1234•", "•", 10\).*= 1234} == 1}
Expand Down