Package: ltrace / 0.7.91~git20230705.8eabf68-4

Metadata

Package Version Patches format
ltrace 0.7.91~git20230705.8eabf68-4 3.0 (quilt)

Patch series

view the series file
Patch File delta Description
fix ftbfs on riscv64.patch | (download)

sysdeps/linux-gnu/riscv64/plt.c | 1 1 + 0 - 0 !
sysdeps/linux-gnu/riscv64/regs.c | 2 2 + 0 - 0 !
2 files changed, 3 insertions(+)

 fix ftbfs on riscv64

fix ftbfs on loong64.patch | (download)

sysdeps/linux-gnu/loongarch/fetch.c | 1 1 + 0 - 0 !
sysdeps/linux-gnu/loongarch/plt.c | 1 1 + 0 - 0 !
sysdeps/linux-gnu/loongarch/regs.c | 2 2 + 0 - 0 !
sysdeps/linux-gnu/loongarch/trace.c | 1 1 + 0 - 0 !
4 files changed, 5 insertions(+)

 fix ftbfs on loong64

0003 Add llong ullong. Tested on i386 amd64.patch | (download)

dwarf_prototypes.c | 8 7 + 1 - 0 !
etc/libc.so-types.conf | 14 4 + 10 - 0 !
expr.c | 6 3 + 3 - 0 !
expr.h | 4 2 + 2 - 0 !
lens_default.c | 18 13 + 5 - 0 !
printf.c | 12 7 + 5 - 0 !
read_config_file.c | 4 4 + 0 - 0 !
sysdeps/linux-gnu/aarch64/fetch.c | 2 2 + 0 - 0 !
sysdeps/linux-gnu/arm/fetch.c | 2 2 + 0 - 0 !
sysdeps/linux-gnu/arm/trace.c | 4 4 + 0 - 0 !
sysdeps/linux-gnu/ia64/fetch.c | 4 4 + 0 - 0 !
sysdeps/linux-gnu/loongarch/fetch.c | 6 5 + 1 - 0 !
sysdeps/linux-gnu/loongarch/trace.c | 4 4 + 0 - 0 !
sysdeps/linux-gnu/m68k/fetch.c | 2 2 + 0 - 0 !
sysdeps/linux-gnu/ppc/fetch.c | 2 2 + 0 - 0 !
sysdeps/linux-gnu/ppc/trace.c | 6 6 + 0 - 0 !
sysdeps/linux-gnu/riscv64/fetch.c | 4 4 + 0 - 0 !
sysdeps/linux-gnu/s390/fetch.c | 2 2 + 0 - 0 !
sysdeps/linux-gnu/s390/trace.c | 6 6 + 0 - 0 !
sysdeps/linux-gnu/x86/fetch.c | 15 12 + 3 - 0 !
sysdeps/linux-gnu/x86/trace.c | 6 6 + 0 - 0 !
type.c | 27 24 + 3 - 0 !
type.h | 2 2 + 0 - 0 !
value.c | 16 8 + 8 - 0 !
value.h | 4 2 + 2 - 0 !
zero.c | 2 1 + 1 - 0 !
26 files changed, 138 insertions(+), 44 deletions(-)

 add llong/ullong. tested on i386/amd64


0004 ltrace.conf openat getopt_long consistency fseek fte.patch | (download)

etc/libc.so.conf | 42 37 + 5 - 0 !
1 file changed, 37 insertions(+), 5 deletions(-)

 ltrace.conf: openat*(), getopt_long*() consistency, fseek*(),
 ftell*(), reallocarray(), pread*(), pwrite*(), lseek*() with whence enum,
 *readv*(), *writev*(), __cxa_finalize()

Of course, this assumes that symbols ending in 64 are the only ones
taking a 64-bit off_t, and thus the ones that don't take longs.
This holds on x86, but probably not any new arches which just don't have
the weird broken *64() symbols.

0005 Remove extraneous whitespace around and.patch | (download)

lens_default.c | 6 3 + 3 - 0 !
1 file changed, 3 insertions(+), 3 deletions(-)

 remove extraneous whitespace around [] and {}

Compare
pread64(3, "14044\n14045\n14046\n14047\n14048\n14"..., 65536, 73152)                                      = 65536
memmove(0x5769c1a4, "6\n", 2)                                                                             = 0x5769c1a4
memcpy(0x5769c1a0, "2496", 4)                                                                             = 0x5769c1a0
writev(1, [ { "24966\n", 6 }, { "24965\n", 6 }, { "24964\n", 6 }, { "24963\n", 6 }... ], 1024)            = 6144
writev(1, [ { "23942\n", 6 }, { "23941\n", 6 }, { "23940\n", 6 }, { "23939\n", 6 }... ], 1024)            = 6144
writev(1, [ { "22918\n", 6 }, { "22917\n", 6 }, { "22916\n", 6 }, { "22915\n", 6 }... ], 1024)            = 6144
writev(1, [ { "21894\n", 6 }, { "21893\n", 6 }, { "21892\n", 6 }, { "21891\n", 6 }... ], 1024)            = 6144
writev(1, [ { "20870\n", 6 }, { "20869\n", 6 }, { "20868\n", 6 }, { "20867\n", 6 }... ], 1024)            = 6144
writev(1, [ { "19846\n", 6 }, { "19845\n", 6 }, { "19844\n", 6 }, { "19843\n", 6 }... ], 1024)            = 6144
writev(1, [ { "18822\n", 6 }, { "18821\n", 6 }, { "18820\n", 6 }, { "18819\n", 6 }... ], 1024)            = 6144
writev(1, [ { "17798\n", 6 }, { "17797\n", 6 }, { "17796\n", 6 }, { "17795\n", 6 }... ], 1024)            = 6144
writev(1, [ { "16774\n", 6 }, { "16773\n", 6 }, { "16772\n", 6 }, { "16771\n", 6 }... ], 1024)            = 6144
writev(1, [ { "15750\n", 6 }, { "15749\n", 6 }, { "15748\n", 6 }, { "15747\n", 6 }... ], 1024)            = 6144
writev(1, [ { "14726\n", 6 }, { "14725\n", 6 }, { "14724\n", 6 }, { "14723\n", 6 }... ], 682)             = 4092
memcpy(0x5769c1a0, "14044\n", 6)                                                                          = 0x5769c1a0
pread64(3, "5\n1746\n1747\n1748\n1749\n1750\n1751\n"..., 65536, 7616)                                     = 65536
writev(1, [ { "14044\n", 6 }, { "14043\n", 6 }, { "14042\n", 6 }, { "14041\n", 6 }... ], 1024)            = 6144
writev(1, [ { "13020\n", 6 }, { "13019\n", 6 }, { "13018\n", 6 }, { "13017\n", 6 }... ], 1024)            = 6144
writev(1, [ { "11996\n", 6 }, { "11995\n", 6 }, { "11994\n", 6 }, { "11993\n", 6 }... ], 1024)            = 6144
writev(1, [ { "10972\n", 6 }, { "10971\n", 6 }, { "10970\n", 6 }, { "10969\n", 6 }... ], 1024)            = 6093
writev(1, [ { "9948\n", 5 }, { "9947\n", 5 }, { "9946\n", 5 }, { "9945\n", 5 }... ], 1024)                = 5120
writev(1, [ { "8924\n", 5 }, { "8923\n", 5 }, { "8922\n", 5 }, { "8921\n", 5 }... ], 1024)                = 5120
writev(1, [ { "7900\n", 5 }, { "7899\n", 5 }, { "7898\n", 5 }, { "7897\n", 5 }... ], 1024)                = 5120
writev(1, [ { "6876\n", 5 }, { "6875\n", 5 }, { "6874\n", 5 }, { "6873\n", 5 }... ], 1024)                = 5120
writev(1, [ { "5852\n", 5 }, { "5851\n", 5 }, { "5850\n", 5 }, { "5849\n", 5 }... ], 1024)                = 5120
writev(1, [ { "4828\n", 5 }, { "4827\n", 5 }, { "4826\n", 5 }, { "4825\n", 5 }... ], 1024)                = 5120
writev(1, [ { "3804\n", 5 }, { "3803\n", 5 }, { "3802\n", 5 }, { "3801\n", 5 }... ], 1024)                = 5120
writev(1, [ { "2780\n", 5 }, { "2779\n", 5 }, { "2778\n", 5 }, { "2777\n", 5 }... ], 1024)                = 5120
writev(1, [ { "1756\n", 5 }, { "1755\n", 5 }, { "1754\n", 5 }, { "1753\n", 5 }... ], 11)                  = 55
memcpy(0x5769c1a0, "5\n", 2)                                                                              = 0x5769c1a0
pread64(3, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14"..., 7616, 0)                                   = 7616
memmove(0x5769c1a3, "5\n", 2)                                                                             = 0x5769c1a3
memcpy(0x5769c1a0, "174", 3)                                                                              = 0x5769c1a0
writev(1, [ { "1745\n", 5 }, { "1744\n", 5 }, { "1743\n", 5 }, { "1742\n", 5 }... ], 1024)                = 4842
writev(1, [ { "721\n", 4 }, { "720\n", 4 }, { "719\n", 4 }, { "718\n", 4 }... ], 720)                     = 2774
memcpy(0x5769c1a0, "1\n", 2)                                                                              = 0x5769c1a0
writev(1, [ { "1\n", 2 } ], 1)                                                                            = 2
close(3)                                                                                                  = 0

To
pread64(3, "14044\n14045\n14046\n14047\n14048\n14"..., 65536, 73152)                                      = 65536
memmove(0x574c41a4, "6\n", 2)                                                                             = 0x574c41a4
memcpy(0x574c41a0, "2496", 4)                                                                             = 0x574c41a0
writev(1, [{"24966\n", 6}, {"24965\n", 6}, {"24964\n", 6}, {"24963\n", 6}...], 1024)                      = 6144
writev(1, [{"23942\n", 6}, {"23941\n", 6}, {"23940\n", 6}, {"23939\n", 6}...], 1024)                      = 6144
writev(1, [{"22918\n", 6}, {"22917\n", 6}, {"22916\n", 6}, {"22915\n", 6}...], 1024)                      = 6144
writev(1, [{"21894\n", 6}, {"21893\n", 6}, {"21892\n", 6}, {"21891\n", 6}...], 1024)                      = 6144
writev(1, [{"20870\n", 6}, {"20869\n", 6}, {"20868\n", 6}, {"20867\n", 6}...], 1024)                      = 6144
writev(1, [{"19846\n", 6}, {"19845\n", 6}, {"19844\n", 6}, {"19843\n", 6}...], 1024)                      = 6144
writev(1, [{"18822\n", 6}, {"18821\n", 6}, {"18820\n", 6}, {"18819\n", 6}...], 1024)                      = 6144
writev(1, [{"17798\n", 6}, {"17797\n", 6}, {"17796\n", 6}, {"17795\n", 6}...], 1024)                      = 6144
writev(1, [{"16774\n", 6}, {"16773\n", 6}, {"16772\n", 6}, {"16771\n", 6}...], 1024)                      = 6144
writev(1, [{"15750\n", 6}, {"15749\n", 6}, {"15748\n", 6}, {"15747\n", 6}...], 1024)                      = 6144
writev(1, [{"14726\n", 6}, {"14725\n", 6}, {"14724\n", 6}, {"14723\n", 6}...], 682)                       = 4092
memcpy(0x574c41a0, "14044\n", 6)                                                                          = 0x574c41a0
pread64(3, "5\n1746\n1747\n1748\n1749\n1750\n1751\n"..., 65536, 7616)                                     = 65536
writev(1, [{"14044\n", 6}, {"14043\n", 6}, {"14042\n", 6}, {"14041\n", 6}...], 1024)                      = 6144
writev(1, [{"13020\n", 6}, {"13019\n", 6}, {"13018\n", 6}, {"13017\n", 6}...], 1024)                      = 6144
writev(1, [{"11996\n", 6}, {"11995\n", 6}, {"11994\n", 6}, {"11993\n", 6}...], 1024)                      = 6144
writev(1, [{"10972\n", 6}, {"10971\n", 6}, {"10970\n", 6}, {"10969\n", 6}...], 1024)                      = 6093
writev(1, [{"9948\n", 5}, {"9947\n", 5}, {"9946\n", 5}, {"9945\n", 5}...], 1024)                          = 5120
writev(1, [{"8924\n", 5}, {"8923\n", 5}, {"8922\n", 5}, {"8921\n", 5}...], 1024)                          = 5120
writev(1, [{"7900\n", 5}, {"7899\n", 5}, {"7898\n", 5}, {"7897\n", 5}...], 1024)                          = 5120
writev(1, [{"6876\n", 5}, {"6875\n", 5}, {"6874\n", 5}, {"6873\n", 5}...], 1024)                          = 5120
writev(1, [{"5852\n", 5}, {"5851\n", 5}, {"5850\n", 5}, {"5849\n", 5}...], 1024)                          = 5120
writev(1, [{"4828\n", 5}, {"4827\n", 5}, {"4826\n", 5}, {"4825\n", 5}...], 1024)                          = 5120
writev(1, [{"3804\n", 5}, {"3803\n", 5}, {"3802\n", 5}, {"3801\n", 5}...], 1024)                          = 5120
writev(1, [{"2780\n", 5}, {"2779\n", 5}, {"2778\n", 5}, {"2777\n", 5}...], 1024)                          = 5120
writev(1, [{"1756\n", 5}, {"1755\n", 5}, {"1754\n", 5}, {"1753\n", 5}...], 11)                            = 55
memcpy(0x574c41a0, "5\n", 2)                                                                              = 0x574c41a0
pread64(3, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14"..., 7616, 0)                                   = 7616
memmove(0x574c41a3, "5\n", 2)                                                                             = 0x574c41a3
memcpy(0x574c41a0, "174", 3)                                                                              = 0x574c41a0
writev(1, [{"1745\n", 5}, {"1744\n", 5}, {"1743\n", 5}, {"1742\n", 5}...], 1024)                          = 4842
writev(1, [{"721\n", 4}, {"720\n", 4}, {"719\n", 4}, {"718\n", 4}...], 720)                               = 2774
memcpy(0x574c41a0, "1\n", 2)                                                                              = 0x574c41a0
writev(1, [{"1\n", 2}], 1)                                                                                = 2
close(3)                                                                                                  = 0

0006 Read larger than word buffers with process_vm_readv..patch | (download)

expr.c | 6 6 + 0 - 0 !
expr.h | 3 3 + 0 - 0 !
lens_default.c | 10 9 + 1 - 0 !
sysdeps/linux-gnu/trace.c | 29 22 + 7 - 0 !
value.c | 47 47 + 0 - 0 !
value.h | 8 8 + 0 - 0 !
zero.c | 7 7 + 0 - 0 !
7 files changed, 102 insertions(+), 8 deletions(-)

 read larger-than-word buffers with process_vm_readv. pre-buffer
 arrays of primitives

The first optimisation is obvious: at one point, without it,
ltrace does ptrace(PTRACE_PEEKDATA) /79959 consecutive times/
(thus reading 640kB; imagine how much slower it'd be on
 i686 with double the syscall count and slower syscalls).

The second is necessary because arrays are reified
by reifying each element separately.
Thus, a 64kB string will cause ltrace to PTRACE_PEEKDATA 65`536 times.)

Instead, cooperatively notify the reification module before formatting
an array, and read (up to a megabyte) into a static buffer.
This means that the no-flag and -s9999999999 runs complete without ever
PTRACE_PEEKDATAing a singular character.

The zero() lens would (needlessly) check more than the required
mapping size, which is limited by -A and -s: restrict it to never
try more than the maximum of those + 1, which allows us to speculatively
pre-map the entire prospective NUL-terminated string too.

Evaluation:
The program consists almost exclusively of pread64(64kB)
of seven-byte-lines and writev(1024)s (where each iov is one line)
of the whole read buffer. The input file is 6.6M, of seq 1000000.

$ time out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m0.030s
user    0m0.017s
sys     0m0.013s

165kB of output:
$ time ltrace -o /dev/null -F /etc/ltrace.conf  out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m8.508s
user    0m2.081s
sys     0m6.389s
$ time ~/backports/ltrace/ltrace -o /dev/null -F /etc/ltrace.conf  out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m0.464s
user    0m0.173s
sys     0m0.282s

7.7MB of output:
$ time ltrace -o /dev/null -F /etc/ltrace.conf -s9999999999  out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m17.820s
user    0m5.384s
sys     0m12.395s
$ time ~/backports/ltrace/ltrace -o /dev/null -F /etc/ltrace.conf -s9999999999  out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m2.678s
user    0m2.377s
sys     0m0.265s

24M of output (especially torturous for the reasons mentioned above):
$ time ltrace -o /dev/null -F /etc/ltrace.conf -{A,s}9999999999  out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m37.834s
user    0m12.685s
sys     0m25.027s
$ time ~/backports/ltrace/ltrace -o /dev/null -F /etc/ltrace.conf -{A,s}9999999999  out/cmd/tail -r /tmp/1000000 > /dev/null

real    0m19.512s
user    0m8.392s
sys     0m10.997s

0007 Handle format b. Add bin lens.patch | (download)

lens_default.c | 21 21 + 0 - 0 !
lens_default.h | 3 3 + 0 - 0 !
ltrace.conf.5 | 3 3 + 0 - 0 !
printf.c | 4 4 + 0 - 0 !
read_config_file.c | 1 1 + 0 - 0 !
5 files changed, 32 insertions(+)

 handle format %b. add bin() lens


0008 Add w f WIDTH x glibc 2.38 C2x.patch | (download)

printf.c | 61 56 + 5 - 0 !
1 file changed, 56 insertions(+), 5 deletions(-)

 add %w[f]{width}x (glibc 2.38, c2x)

This even lets you trace programs that your libc doesn't have support
for! (By accident.)

  $ cat qwe.c
  int main() {
          printf("%#b\n", 69);
          printf("%w64x %s\n", "gameing", (char *)0);
          write(1, "zupa\n", 5);

  }
  $ ./ltrace -F ./ltrace.conf ./qwe  | tail
  printf("%#b\n", 0b1000101)                = 10
  printf("%w64x %s\n", 0x563ab86eb013, nil) = 14
  write(1, "zupa\n", 0b101)                 = 5
  
0009 Add splice copy_file_range sendfile 64.patch | (download)

etc/libc.so.conf | 6 6 + 0 - 0 !
1 file changed, 6 insertions(+)

 add splice()/copy_file_range()/sendfile[64]()

Before:
splice(3, 0x7ffd4b66f348, 1, 0)                = -1
copy_file_range(3, 0x7ffd772bbf28, 1, 0)       = -1
sendfile64(1, 3, 0x7ffd772bbf28, 0x400000)     = -1
pread64(3 <no return ...>
error: maximum array length seems negative
, "", 65536, -65536)                           = -1

After:
splice(3, -65536, 1, nil, 4194304, 0b101)      = -1
copy_file_range(3, -65536, 1, nil, 4194304, 0) = -1
sendfile64(1, 3, -65536, 4194304)              = -1
pread64(3 <no return ...>
error: maximum array length seems negative
, "", 65536, -65536)                           = -1

0010 __errno_location returns an int not addr.patch | (download)

etc/libc.so.conf | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)

 __errno_location() returns an int*, not addr

This means that before:
__errno_location() = 0x7f2707f256c0
__errno_location() = 0x7f2707f256c0
__errno_location() = 0x7f2707f256c0

After:
__errno_location() = 0
__errno_location() = 22
__errno_location() = 22

And thus __errno_location() is made useful

0011 pipe 2 with fds sysconf m un map 64 operator new del.patch | (download)

etc/libc.so.conf | 11 10 + 1 - 0 !
1 file changed, 10 insertions(+), 1 deletion(-)

 pipe[2]() with fds; sysconf(); m[un]map[64](); operator new/delete;
 regex.h suite

$ grep pipe ll
pipe2(0x7ffcd6d7baf0, 0x80000, 0x7ffcd6d7bb70, 0x7ffcd6d7bb70)                       = 0
$ grep pipe ll
pipe2([3, 4], 0x80000)                                                               = 0

nabijaczleweli@tarta:~/backports/ltrace$ grep -e mmap -e sysconf ll
sysconf(30, 0, 1, 0x393c)                                                            = 4096
mmap64(0, 0x3d3c, 1, 2)                                                              = 0x7fe67b29c000
nabijaczleweli@tarta:~/backports/ltrace$ grep -e mmap -e sysconf ll
sysconf(_SC_PAGE_SIZE)                                                               = 4096
mmap64(0, 15676, 0b1, 0x2, 0, 4096)                                                  = 0x7fa1b27ff000

regcomp(0x7fff5ee83120, ";", 0b100)                                                  = REG_OK

regexec(0x7fff5ee83040, "\nint   SYS_access(string,octal);"..., 1, [{0, 31}], 0b111) = REG_NOMATCH
regexec(0x7fff5ee83040, ";\nint   SYS_access(string,octal)"..., 1, [{0, 32}], 0b111) = REG_OK

regcomp(0x7ffece59ee70, "\\(", 0b100)                                                = REG_EPAREN
regerror(REG_EPAREN, 0x7ffece59ee70, nil, 0)                                         = 18
malloc(18)                                                                           = 0x5604c35c2140
regerror(REG_EPAREN, 0x7ffece59ee70, "Unmatched ( or \\(", 18)                       = 18

0012 Turn opt_p into an array.patch | (download)

libltrace.c | 20 7 + 13 - 0 !
options.c | 20 8 + 12 - 0 !
options.h | 8 2 + 6 - 0 !
sysdeps/linux-gnu/trace.c | 10 4 + 6 - 0 !
4 files changed, 21 insertions(+), 37 deletions(-)

 turn opt_p into an array


0013 Open o we instead of w then setting O_CLOEXEC manual.patch | (download)

options.c | 7 3 + 4 - 0 !
1 file changed, 3 insertions(+), 4 deletions(-)

 open -o "we" instead of "w" then setting o_cloexec manually


0014 Boolify pass for prototype read_config_file.patch | (download)

common.h | 1 1 + 0 - 0 !
libltrace.c | 4 2 + 2 - 0 !
options.c | 10 5 + 5 - 0 !
options.h | 3 2 + 1 - 0 !
prototype.c | 4 2 + 2 - 0 !
prototype.h | 10 5 + 5 - 0 !
read_config_file.c | 98 49 + 49 - 0 !
7 files changed, 66 insertions(+), 64 deletions(-)

 boolify pass for prototype/read_config_file


0015 Remove unused list_of_functions.patch | (download)

read_config_file.c | 2 0 + 2 - 0 !
1 file changed, 2 deletions(-)

 remove unused list_of_functions


0016 Full stat suite bare names appear in my C program at.patch | (download)

etc/libc.so.conf | 97 80 + 17 - 0 !
1 file changed, 80 insertions(+), 17 deletions(-)

 full stat/statfs suite,
 bare names (appear in my C++ program at least); strto*ll(); *locale();
 vfork(); time.h functions and struct tm; wgetch, tgetstr, MEVENT, getmouse;
 linkat, renameat{,2}, mkdirat; {,d,dc}gettext, nl_langinfo;
 ungetc, freopen, fmemopen, open_{,w}memstream, {v,}asprintf, getline,
 {,__}getdelim, __xpg_basename, strnlen, strverscmp, memcmp, bcmp, strtok_r,
 strpbrk, stat64, realpath, getsubopt, mbtowc; qsort_r(); boolify isw*();
 sync() family; canonicalize_file_name(); strncasecmp()


22.patch | (download)

NEWS | 1 1 + 0 - 0 !
README | 1 1 + 0 - 0 !
sysdeps/linux-gnu/loongarch/syscallent.h | 22 17 + 5 - 0 !
3 files changed, 19 insertions(+), 5 deletions(-)

 [patch 1/2] sysdeps: loongarch: update syscall lists [patch 2/2]
 Mention support of loongarch in README and NEWS

Generated syscallent.h with mksyscallent according to
Linux 6.10 uapi header file asm-generic/unistd.h. And
modified format and details manually to be consistent
with the kernel.

loongarch architecture has been supported since commit 5cffc0d.
So we should add it to README and NEWS.

Signed-off-by: Hui Li <lihui@loongson.cn>
0018 Fix printf parser treating field width as array leng.patch | (download)

printf.c | 72 32 + 40 - 0 !
1 file changed, 32 insertions(+), 40 deletions(-)

 fix printf() parser treating field width as array length for strings
 (Closes: #804494)

Given:
  #include <stdio.h>
  int main() {
    printf("'%8.4s' '%8s' '%.4s'\n",       "1234567890",    "1234567890",    "1234567890");
    printf("'%*.*s' '%*s' '%.*s'\n", 8, 4, "1234567890", 8, "1234567890", 4, "1234567890");
  }

Compare:
  $ ./ltrace.before -F etc ./q | cat
  printf("'%8.4s' '%8s' '%.4s'\n", "1234567890", "12345678", "1234")                                        = 31
  printf("'%*.*s' '%*s' '%.*s'\n", 8, 4, "1234", 8, "12345678", 4, "1234")                                  = 31
  '    1234' '1234567890' '1234'
  '    1234' '1234567890' '1234'
  
0019 Allow tracing shebanged programs directly Closes 614.patch | (download)

libltrace.c | 2 1 + 1 - 0 !
ltrace-elf.c | 20 18 + 2 - 0 !
ltrace-elf.h | 3 2 + 1 - 0 !
3 files changed, 21 insertions(+), 4 deletions(-)

 allow tracing shebanged #! programs directly (closes: #614994)


19.patch | (download)

dwarf_prototypes.c | 5 1 + 4 - 0 !
1 file changed, 1 insertion(+), 4 deletions(-)

 [patch] fix double free in get_enum

When result is destroyed it also runs the destructor on the lens it owns
and frees it.

21.patch | (download)

sysdeps/linux-gnu/riscv64/Makefile.am | 3 2 + 1 - 0 !
sysdeps/linux-gnu/riscv64/arch.h | 13 13 + 0 - 0 !
sysdeps/linux-gnu/riscv64/breakpoint.c | 110 110 + 0 - 0 !
3 files changed, 125 insertions(+), 1 deletion(-)

 risc-v: add support for c.ebreak,
 as 4-byte ebreak sometimes causes OOB

0022 ltrace crashes when trying to resolve memory mapped .patch | (download)

libltrace.c | 2 1 + 1 - 0 !
ltrace-elf.c | 11 8 + 3 - 0 !
ltrace-elf.h | 2 1 + 1 - 0 !
3 files changed, 10 insertions(+), 5 deletions(-)

 ltrace crashes when trying to resolve memory mapped shared libraries
 of an inferior under /proc/self/fd/*

Fixes: #15

0023 getcwd returns string not string2.patch | (download)

etc/libc.so.conf | 2 1 + 1 - 0 !
1 file changed, 1 insertion(+), 1 deletion(-)

 getcwd() returns string, not string2


0024 Add hton ls ntoh ls . More unbuffered stdio __overfl.patch | (download)

etc/libc.so.conf | 29 29 + 0 - 0 !
etc/libm.so.conf | 3 3 + 0 - 0 !
2 files changed, 32 insertions(+)

 add hton[ls]()/ntoh[ls](). more unbuffered stdio (__overflow,
 __fpending, fputs_unlocked). Checked printfs (__{v,}{f,s,as,}printf_chk,
 __obstack_{v,}printf_chk). dirname(), memmem(), fe[gs]etround()


0025 Fix SIGABRT if ltelf_init early exited.patch | (download)

ltrace-elf.c | 3 1 + 2 - 0 !
1 file changed, 1 insertion(+), 2 deletions(-)

 fix sigabrt if ltelf_init() early-exited

Repro with:
  #!/bin/sh -e
  cat <<__END__ | gcc -shared -O -o liblib.so -Wall -Werror -fPIC -xc -
  void DoNothing();
  void DoNothing() {}
  __END__

  cat <<__END__ | gcc -L$PWD -Wl,-rpath=$PWD -Wall -Werror -O -o bin -xc - -llib
  #include <stdio.h>
  #include <stdlib.h>
  #include <unistd.h>

  void DoNothing();

  int main() {
    while (1) {
      sleep(1);
      DoNothing();
    }
    return 0;
  }
  __END__

  ./bin &
  sleep 0.1

  mv liblib.so liblib.so.orig

  echo "===> Running ltrace -p $! ..."
  gdb --args ./ltrace -p $!

Yielding
> Can't open /tmp/tmp.oldWtch6po/liblib.so: No such file or directory
> Couldn't determine base address of /tmp/tmp.oldWtch6po/liblib.so
> ltrace: ltrace-elf.c:426: ltelf_destroy: Assertion `(&lte->plt_relocs)->elt_size == sizeof(GElf_Rela)' failed.

This corresponds to the last line in
  void
  ltelf_destroy(struct ltelf *lte)
  {
    debug(DEBUG_FUNCTION, "close_elf()");
    elf_end(lte->elf);
    close(lte->fd);
    VECT_DESTROY(&lte->plt_relocs, GElf_Rela, NULL, NULL);
  }
and removing it fixes it
  ===> Running ltrace -p 169396 ...
  Can't open /home/nabijaczleweli/uwu/repro/ltrace/liblib.so: No such file or directory
  Couldn't determine base address of /home/nabijaczleweli/uwu/repro/ltrace/liblib.so
  Couldn't load ELF object /home/nabijaczleweli/uwu/repro/ltrace/liblib.so: Bad file descriptor
  Can't open /home/nabijaczleweli/uwu/repro/ltrace/liblib.so: No such file or directory
  Couldn't determine base address of /home/nabijaczleweli/uwu/repro/ltrace/liblib.so
  Couldn't load ELF object /home/nabijaczleweli/uwu/repro/ltrace/liblib.so: Bad file descriptor
  DoNothing(0, 0, 0, 0x545634c3)                                                                            = 0
  sleep(1, 0, 0, 0x545634c3)                                                                                = 0
  DoNothing(0, 0, 0, 0x545634c3)                                                                            = 0
because it's never been initialised
  (gdb) p lte->plt_relocs
  $2 = {data = 0x0, size = 0, allocated = 0, elt_size = 0}

Initialsie the vect alongside initialising the lte, not just on success.

Closes: https://bugs.debian.org/1101361