i swear to god one day ill remember to include the patches in the first post
From: =?utf-8?b?0L3QsNCx?= <[email protected]> Date: Tue, 25 Jul 2023 21:20:32 +0200 Subject: Add llong/ullong. Tested on i686/amd64
---
expr.c | 6 +++---
expr.h | 4 ++--
lens_default.c | 14 ++++++++++----
printf.c | 10 +++++-----
read_config_file.c | 4 ++++
sysdeps/linux-gnu/ia64/fetch.c | 4 ++++
sysdeps/linux-gnu/m68k/fetch.c | 2 ++
sysdeps/linux-gnu/ppc/fetch.c | 2 ++
sysdeps/linux-gnu/ppc/trace.c | 6 ++++++
sysdeps/linux-gnu/s390/fetch.c | 2 ++
sysdeps/linux-gnu/s390/trace.c | 6 ++++++
sysdeps/linux-gnu/x86/fetch.c | 15 ++++++++++++---
sysdeps/linux-gnu/x86/trace.c | 6 ++++++
type.c | 25 ++++++++++++++++++++++---
type.h | 2 ++
value.c | 16 ++++++++--------
value.h | 4 ++--
zero.c | 2 +-
18 files changed, 99 insertions(+), 31 deletions(-)
diff --git a/expr.c b/expr.c
index 32860fd..01ce4c6 100644
--- a/expr.c
+++ b/expr.c
@@ -246,7 +246,7 @@ eval_index(struct expr_node *node, struct value *context,
if (expr_eval(node->lhs, context, arguments, &lhs) < 0)
return -1;
- long l;
+ long long l;
if (expr_eval_word(node->u.node.n, context, arguments, &l) < 0) {
fail:
value_destroy(&lhs);
@@ -305,7 +305,7 @@ expr_eval(struct expr_node *node, struct value *context,
int
expr_eval_word(struct expr_node *node, struct value *context,
- struct value_dict *arguments, long *ret_value)
+ struct value_dict *arguments, long long *ret_value)
{
struct value val;
if (expr_eval(node, context, arguments, &val) < 0)
@@ -318,7 +318,7 @@ expr_eval_word(struct expr_node *node, struct value *context,
}
int
-expr_eval_constant(struct expr_node *node, long *valuep)
+expr_eval_constant(struct expr_node *node, long long *valuep)
{
assert(expr_is_compile_constant(node));
return expr_eval_word(node, NULL, NULL, valuep);
diff --git a/expr.h b/expr.h
index 53b75b7..aa4b0b6 100644
--- a/expr.h
+++ b/expr.h
@@ -135,7 +135,7 @@ int expr_eval(struct expr_node *node, struct value *context,
/* Evaluate compile-time expression. Returns 0 on success or negative
* value on failure. Computed value is passed back in *VALUEP. */
-int expr_eval_constant(struct expr_node *node, long *valuep);
+int expr_eval_constant(struct expr_node *node, long long *valuep);
/* Evaluate expression, whose result should fit into a word. In order
* to easily support all the structure and array accesses, we simply
@@ -143,7 +143,7 @@ int expr_eval_constant(struct expr_node *node, long *valuep);
* to be able to get out a word-size datum to use it as an index, a
* length, etc. */
int expr_eval_word(struct expr_node *node, struct value *context,
- struct value_dict *arguments, long *ret_value);
+ struct value_dict *arguments, long long *ret_value);
/* Returns non-zero value if the expression is a compile-time
* constant. Currently this is only EXPR_OP_CONST, but eventually
diff --git a/lens_default.c b/lens_default.c
index 36531c2..2fd4915 100644
--- a/lens_default.c
+++ b/lens_default.c
@@ -58,7 +58,7 @@ READER(read_double, double)
#define HANDLE_WIDTH(BITS) \
do { \
- long l; \
+ long long l; \
if (value_extract_word(value, &l, arguments) < 0) \
return -1; \
int##BITS##_t i = l; \
@@ -124,7 +124,7 @@ acc_fprintf(int *countp, FILE *stream, const char *format, ...)
static int
format_char(FILE *stream, struct value *value, struct value_dict *arguments)
{
- long lc;
+ long long lc;
if (value_extract_word(value, &lc, arguments) < 0)
return -1;
int c = (int)lc;
@@ -344,8 +344,8 @@ format_array(FILE *stream, struct value *value, struct value_dict *arguments,
{
/* We need "long" to be long enough to cover the whole address
* space. */
- (void)sizeof(char[1 - 2*(sizeof(long) < sizeof(void *))]);
- long l;
+ (void)sizeof(char[1 - 2*(sizeof(long long) < sizeof(void *))]);
+ long long l;
if (expr_eval_word(length, value, arguments, &l) < 0)
return -1;
size_t len = (size_t)l;
@@ -394,11 +394,13 @@ toplevel_format_lens(struct lens *lens, FILE *stream,
case ARGTYPE_SHORT:
case ARGTYPE_INT:
case ARGTYPE_LONG:
+ case ARGTYPE_LLONG:
return format_integer(stream, value, int_fmt, arguments);
case ARGTYPE_USHORT:
case ARGTYPE_UINT:
case ARGTYPE_ULONG:
+ case ARGTYPE_ULLONG:
if (int_fmt == INT_FMT_i || int_fmt == INT_FMT_default)
int_fmt = INT_FMT_u;
return format_integer(stream, value, int_fmt, arguments);
@@ -520,9 +522,11 @@ bool_lens_format_cb(struct lens *lens, FILE *stream,
case ARGTYPE_SHORT:
case ARGTYPE_INT:
case ARGTYPE_LONG:
+ case ARGTYPE_LLONG:
case ARGTYPE_USHORT:
case ARGTYPE_UINT:
case ARGTYPE_ULONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
if ((zero = value_is_zero(value, arguments)) < 0)
return -1;
@@ -578,9 +582,11 @@ string_lens_format_cb(struct lens *lens, FILE *stream,
case ARGTYPE_SHORT:
case ARGTYPE_INT:
case ARGTYPE_LONG:
+ case ARGTYPE_LLONG:
case ARGTYPE_USHORT:
case ARGTYPE_UINT:
case ARGTYPE_ULONG:
+ case ARGTYPE_ULLONG:
return toplevel_format_lens(lens, stream, value,
arguments, INT_FMT_default);
diff --git a/printf.c b/printf.c
index 9aa68a5..773d104 100644
--- a/printf.c
+++ b/printf.c
@@ -35,7 +35,7 @@
struct param_enum {
struct value array;
int percent;
- size_t *future_length;
+ unsigned long long *future_length;
char *format;
char const *ptr;
char const *end;
@@ -101,15 +101,15 @@ form_next_param(struct param_enum *self,
struct arg_type_info *infop)
{
/* XXX note: Some types are wrong because we lack
- ARGTYPE_LONGLONG, ARGTYPE_UCHAR and ARGTYPE_SCHAR. */
+ ARGTYPE_UCHAR and ARGTYPE_SCHAR. */
assert(lng <= 2);
assert(hlf <= 2);
static enum arg_type ints[] =
{ ARGTYPE_CHAR, ARGTYPE_SHORT, ARGTYPE_INT,
- ARGTYPE_LONG, ARGTYPE_ULONG };
+ ARGTYPE_LONG, ARGTYPE_LLONG };
static enum arg_type uints[] =
{ ARGTYPE_CHAR, ARGTYPE_USHORT, ARGTYPE_UINT,
- ARGTYPE_ULONG, ARGTYPE_ULONG };
+ ARGTYPE_ULONG, ARGTYPE_ULLONG };
struct arg_type_info *elt_info = NULL;
if (format_type == ARGTYPE_ARRAY || format_type == ARGTYPE_POINTER)
@@ -343,7 +343,7 @@ static enum param_status
param_printf_stop(struct param_enum *self, struct value *value)
{
if (self->future_length != NULL
- && value_extract_word(value, (long *)self->future_length, NULL) < 0)
+ && value_extract_word(value, (long long *)self->future_length, NULL) < 0)
drop_future_length(self);
return PPCB_CONT;
diff --git a/read_config_file.c b/read_config_file.c
index e247436..98278ac 100644
--- a/read_config_file.c
+++ b/read_config_file.c
@@ -79,6 +79,8 @@ parse_arg_type(char **name, enum arg_type *ret)
KEYWORD("uint", ARGTYPE_UINT);
KEYWORD("long", ARGTYPE_LONG);
KEYWORD("ulong", ARGTYPE_ULONG);
+ KEYWORD("llong", ARGTYPE_LLONG);
+ KEYWORD("ullong", ARGTYPE_ULLONG);
KEYWORD("char", ARGTYPE_CHAR);
KEYWORD("short", ARGTYPE_SHORT);
KEYWORD("ushort", ARGTYPE_USHORT);
@@ -912,6 +914,8 @@ parse_nonpointer_type(char **str, struct param **extra_param, size_t param_num,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
case ARGTYPE_SHORT:
case ARGTYPE_USHORT:
diff --git a/sysdeps/linux-gnu/ia64/fetch.c b/sysdeps/linux-gnu/ia64/fetch.c
index 54dc5b8..3828dd1 100644
--- a/sysdeps/linux-gnu/ia64/fetch.c
+++ b/sysdeps/linux-gnu/ia64/fetch.c
@@ -433,6 +433,8 @@ arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
return allocate_arg(ctx, proc, info, valuep);
@@ -467,6 +469,8 @@ arch_fetch_retval(struct fetch_context *ctx, enum tof type,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
case ARGTYPE_STRUCT:
return allocate_ret(ctx, proc, info, valuep);
diff --git a/sysdeps/linux-gnu/m68k/fetch.c b/sysdeps/linux-gnu/m68k/fetch.c
index f6d8a0b..0870c82 100644
--- a/sysdeps/linux-gnu/m68k/fetch.c
+++ b/sysdeps/linux-gnu/m68k/fetch.c
@@ -170,6 +170,8 @@ arch_fetch_retval(struct fetch_context *context, enum tof type,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
case ARGTYPE_SHORT:
case ARGTYPE_USHORT:
diff --git a/sysdeps/linux-gnu/ppc/fetch.c b/sysdeps/linux-gnu/ppc/fetch.c
index 9963a1e..6fa5b73 100644
--- a/sysdeps/linux-gnu/ppc/fetch.c
+++ b/sysdeps/linux-gnu/ppc/fetch.c
@@ -309,6 +309,8 @@ allocate_argument(struct fetch_context *ctx, struct Process *proc,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
break;
diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
index 4357a1e..c1e9e2e 100644
--- a/sysdeps/linux-gnu/ppc/trace.c
+++ b/sysdeps/linux-gnu/ppc/trace.c
@@ -197,6 +197,10 @@ arch_type_sizeof(struct Process *proc, struct arg_type_info *info)
case ARGTYPE_POINTER:
return proc->e_machine == EM_PPC64 ? 8 : 4;
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
+ return 8;
+
case ARGTYPE_FLOAT:
return 4;
case ARGTYPE_DOUBLE:
@@ -233,6 +237,8 @@ arch_type_alignof(struct Process *proc, struct arg_type_info *info)
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
case ARGTYPE_FLOAT:
case ARGTYPE_DOUBLE:
diff --git a/sysdeps/linux-gnu/s390/fetch.c b/sysdeps/linux-gnu/s390/fetch.c
index fa8f42d..b01a71a 100644
--- a/sysdeps/linux-gnu/s390/fetch.c
+++ b/sysdeps/linux-gnu/s390/fetch.c
@@ -252,6 +252,8 @@ arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
case ARGTYPE_SHORT:
case ARGTYPE_USHORT:
diff --git a/sysdeps/linux-gnu/s390/trace.c b/sysdeps/linux-gnu/s390/trace.c
index b9e05ff..6ded4fb 100644
--- a/sysdeps/linux-gnu/s390/trace.c
+++ b/sysdeps/linux-gnu/s390/trace.c
@@ -200,6 +200,10 @@ arch_type_sizeof(struct Process *proc, struct arg_type_info *info)
case ARGTYPE_POINTER:
return proc->e_class == ELFCLASS64 ? 8 : 4;
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
+ return 8;
+
case ARGTYPE_FLOAT:
return 4;
case ARGTYPE_DOUBLE:
@@ -240,6 +244,8 @@ arch_type_alignof(struct Process *proc, struct arg_type_info *info)
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
return proc->e_class == ELFCLASS64 ? 8 : 4;
diff --git a/sysdeps/linux-gnu/x86/fetch.c b/sysdeps/linux-gnu/x86/fetch.c
index 4dab4cc..b9ed8f1 100644
--- a/sysdeps/linux-gnu/x86/fetch.c
+++ b/sysdeps/linux-gnu/x86/fetch.c
@@ -259,7 +259,13 @@ allocate_integer(struct fetch_context *context, struct value *valuep,
HANDLE(0, rax);
HANDLE(1, rdx);
#else
- HANDLE(0, eax);
+ case 0: // u64 return in EAX:EDX
+ copy_int_register(context, valuep,
+ context->iregs.eax, offset);
+ if(sz == 8)
+ copy_int_register(context, valuep,
+ context->iregs.edx, offset + 4);
+ return CLASS_INTEGER;
#endif
default:
assert(!"Too many return value classes.");
@@ -448,9 +454,10 @@ classify(struct Process *proc, struct fetch_context *context,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
- /* and LONGLONG */
/* CLASS_INTEGER */
classes[0] = CLASS_INTEGER;
return 1;
@@ -470,7 +477,7 @@ classify(struct Process *proc, struct fetch_context *context,
* passed by value. */
assert(expr_is_compile_constant(info->u.array_info.length));
- long l;
+ long long l;
if (expr_eval_constant(info->u.array_info.length, &l) < 0)
return -1;
@@ -609,6 +616,8 @@ arch_fetch_retval_32(struct fetch_context *context, enum tof type,
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
case ARGTYPE_SHORT:
case ARGTYPE_USHORT:
diff --git a/sysdeps/linux-gnu/x86/trace.c b/sysdeps/linux-gnu/x86/trace.c
index ed8bdb4..802bd0f 100644
--- a/sysdeps/linux-gnu/x86/trace.c
+++ b/sysdeps/linux-gnu/x86/trace.c
@@ -134,6 +134,10 @@ arch_type_sizeof(struct Process *proc, struct arg_type_info *info)
case ARGTYPE_POINTER:
return proc->e_machine == EM_X86_64 ? 8 : 4;
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
+ return 8;
+
case ARGTYPE_FLOAT:
return 4;
case ARGTYPE_DOUBLE:
@@ -175,6 +179,8 @@ arch_type_alignof(struct Process *proc, struct arg_type_info *info)
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_POINTER:
return proc->e_machine == EM_X86_64 ? 8 : 4;
diff --git a/type.c b/type.c
index 3ce8563..0880e5b 100644
--- a/type.c
+++ b/type.c
@@ -43,6 +43,8 @@ type_get_simple(enum arg_type type)
HANDLE(ARGTYPE_UINT)
HANDLE(ARGTYPE_LONG)
HANDLE(ARGTYPE_ULONG)
+ HANDLE(ARGTYPE_LLONG)
+ HANDLE(ARGTYPE_ULLONG)
HANDLE(ARGTYPE_CHAR)
HANDLE(ARGTYPE_SHORT)
HANDLE(ARGTYPE_USHORT)
@@ -239,6 +241,8 @@ type_destroy(struct arg_type_info *info)
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
case ARGTYPE_SHORT:
case ARGTYPE_USHORT:
@@ -312,6 +316,10 @@ type_sizeof(struct Process *proc, struct arg_type_info *type)
case ARGTYPE_ULONG:
return sizeof(long);
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
+ return sizeof(long long);
+
case ARGTYPE_FLOAT:
return sizeof(float);
@@ -328,7 +336,7 @@ type_sizeof(struct Process *proc, struct arg_type_info *type)
case ARGTYPE_ARRAY:
if (expr_is_compile_constant(type->u.array_info.length)) {
- long l;
+ long long l;
if (expr_eval_constant(type->u.array_info.length,
&l) < 0)
return -1;
@@ -369,6 +377,7 @@ type_alignof(struct Process *proc, struct arg_type_info *type)
struct { char c; short s; } cs;
struct { char c; int i; } ci;
struct { char c; long l; } cl;
+ struct { char c; long long ll; } cll;
struct { char c; void* p; } cp;
struct { char c; float f; } cf;
struct { char c; double d; } cd;
@@ -377,12 +386,16 @@ type_alignof(struct Process *proc, struct arg_type_info *type)
static size_t short_alignment = alignof(s, cs);
static size_t int_alignment = alignof(i, ci);
static size_t long_alignment = alignof(l, cl);
+ static size_t llong_alignment = alignof(ll, cll);
static size_t ptr_alignment = alignof(p, cp);
static size_t float_alignment = alignof(f, cf);
static size_t double_alignment = alignof(d, cd);
switch (type->type) {
size_t alignment;
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
+ return llong_alignment;
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
return long_alignment;
@@ -467,7 +480,7 @@ type_aggregate_size(struct arg_type_info *info)
|| info->type == ARGTYPE_ARRAY);
switch (info->type) {
- long ret;
+ long long ret;
case ARGTYPE_ARRAY:
if (expr_eval_constant(info->u.array_info.length, &ret) < 0)
return (size_t)-1;
@@ -489,6 +502,8 @@ type_is_integral(enum arg_type type)
case ARGTYPE_UINT:
case ARGTYPE_LONG:
case ARGTYPE_ULONG:
+ case ARGTYPE_LLONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_CHAR:
case ARGTYPE_SHORT:
case ARGTYPE_USHORT:
@@ -517,11 +532,13 @@ type_is_signed(enum arg_type type)
case ARGTYPE_SHORT:
case ARGTYPE_INT:
case ARGTYPE_LONG:
+ case ARGTYPE_LLONG:
return 1;
+ case ARGTYPE_USHORT:
case ARGTYPE_UINT:
case ARGTYPE_ULONG:
- case ARGTYPE_USHORT:
+ case ARGTYPE_ULLONG:
return 0;
case ARGTYPE_VOID:
@@ -551,8 +568,10 @@ type_get_fp_equivalent(struct arg_type_info *info)
case ARGTYPE_SHORT:
case ARGTYPE_INT:
case ARGTYPE_LONG:
+ case ARGTYPE_LLONG:
case ARGTYPE_UINT:
case ARGTYPE_ULONG:
+ case ARGTYPE_ULLONG:
case ARGTYPE_USHORT:
case ARGTYPE_VOID:
case ARGTYPE_ARRAY:
diff --git a/type.h b/type.h
index e8dec71..95838a0 100644
--- a/type.h
+++ b/type.h
@@ -32,6 +32,8 @@ enum arg_type {
ARGTYPE_UINT,
ARGTYPE_LONG,
ARGTYPE_ULONG,
+ ARGTYPE_LLONG,
+ ARGTYPE_ULLONG,
ARGTYPE_CHAR,
ARGTYPE_SHORT,
ARGTYPE_USHORT,
diff --git a/value.c b/value.c
index f89570f..3209b9f 100644
--- a/value.c
+++ b/value.c
@@ -219,8 +219,8 @@ value_size(struct value *val, struct value_dict *arguments)
arguments, &length) < 0)
return (size_t)-1;
- size_t l;
- int o = value_extract_word(&length, (long *)&l, arguments);
+ uint64_t l;
+ int o = value_extract_word(&length, (long long *)&l, arguments);
value_destroy(&length);
if (o < 0)
@@ -278,7 +278,7 @@ value_init_deref(struct value *ret_val, struct value *valp)
/* Note: extracting a pointer value should not need value_dict
* with function arguments. */
- long l;
+ long long l;
if (value_extract_word(valp, &l, NULL) < 0)
return -1;
@@ -368,7 +368,7 @@ value_extract_buf_sz(struct value *value, unsigned char *tgt, size_t sz,
}
int
-value_extract_word(struct value *value, long *retp,
+value_extract_word(struct value *value, long long *retp,
struct value_dict *arguments)
{
size_t sz = type_sizeof(value->inferior, value->type);
@@ -387,16 +387,16 @@ value_extract_word(struct value *value, long *retp,
switch (sz) {
case 1:
- *retp = (long)u.u8;
+ *retp = (long long)u.u8;
return 0;
case 2:
- *retp = (long)u.u16;
+ *retp = (long long)u.u16;
return 0;
case 4:
- *retp = (long)u.u32;
+ *retp = (long long)u.u32;
return 0;
case 8:
- *retp = (long)u.u64;
+ *retp = (long long)u.u64;
return 0;
default:
assert(sz != sz);
diff --git a/value.h b/value.h
index 795573c..a527667 100644
--- a/value.h
+++ b/value.h
@@ -52,7 +52,7 @@ struct value {
union {
void *address; /* VAL_LOC_COPY, VAL_LOC_SHARED */
arch_addr_t inf_address; /* VAL_LOC_INFERIOR */
- long value; /* VAL_LOC_WORD */
+ long long value; /* VAL_LOC_WORD */
unsigned char buf[0];
} u;
enum value_location_t where;
@@ -137,7 +137,7 @@ size_t value_size(struct value *val, struct value_dict *arguments);
/* Extract at most word-sized datum from the value. Return 0 on
* success or negative value on failure. */
-int value_extract_word(struct value *val, long *retp,
+int value_extract_word(struct value *val, long long *retp,
struct value_dict *arguments);
/* Copy contents of VAL to DATA. The buffer must be large enough to
diff --git a/zero.c b/zero.c
index bc119ee..ddb5e0d 100644
--- a/zero.c
+++ b/zero.c
@@ -58,7 +58,7 @@ static int
zero_callback(struct value *ret_value, struct value *lhs,
struct value *rhs, struct value_dict *arguments, void *data)
{
- long l;
+ long long l;
if (value_extract_word(rhs, &l, arguments) < 0)
return -1;
if (l < 0)
From: =?utf-8?b?0L3QsNCx?= <[email protected]> Date: Wed, 26 Jul 2023 01:42:23 +0200 Subject: 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. --- etc/ltrace.conf | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/etc/ltrace.conf b/etc/ltrace.conf index 8f83986..855d373 100644 --- a/etc/ltrace.conf +++ b/etc/ltrace.conf @@ -55,15 +55,18 @@ int dlclose(addr); addr __errno_location(); ; fcntl.h -int open(string,int,octal); ; WARNING: 3rd argument may not be there -int open64(string,int,octal); ; WARNING: 3rd argument may not be there +typedef openat_fd = enum(AT_FDCWD=-100); +int open(string,hex(int),octal); ; WARNING: 3rd argument may not be there +int open64(string,hex(int),octal); ; WARNING: 3rd argument may not be there +int openat(openat_fd,string,hex(int),octal); ; WARNING: 4th argument may not be there +int openat64(openat_fd,string,hex(int),octal); ; WARNING: 4th argument may not be there ; fnmatch.h int fnmatch(string, string, int); ; getopt.h -int getopt_long(int,addr,string,addr,int*); -int getopt_long_only(int,addr,string,addr,addr); +int getopt_long(int,addr,string,addr,+int*); +int getopt_long_only(int,addr,string,addr,+int*); ; grp.h void endgrent(); @@ -194,6 +197,13 @@ ulong fread(addr,ulong,ulong,file); ulong fread_unlocked(addr,ulong,ulong,file); ulong fwrite(string,ulong,ulong,file); ulong fwrite_unlocked(string,ulong,ulong,file); +typedef lseek_whence = enum(SEEK_SET=0, SEEK_CUR=1, SEEK_END=2, SEEK_DATA=3, SEEK_HOLE=4); +int fseek(file,long,lseek_whence); +int fseeko(file,long,lseek_whence); +int fseeko64(file,llong,lseek_whence); +long ftell(file); +long ftello(file); +llong ftello64(file); int pclose(addr); void perror(string); addr popen(string, string); @@ -227,6 +237,7 @@ addr malloc(ulong); void qsort(addr,ulong,ulong,addr); int random(); addr realloc(addr,ulong); +addr reallocarray(addr,ulong,ulong); void srandom(uint); int system(string); @@ -335,6 +346,8 @@ int isatty(int); int link(string,string); int mkdir(string,octal); long read(int, +string[retval], ulong); +long pread(int,+string[retval],ulong,long); +long pread64(int,+string[retval],ulong,llong); int rmdir(string); int seteuid(uint); int setgid(int); @@ -350,11 +363,27 @@ string ttyname(int); int unlink(string); void usleep(uint); long write(int, string3, ulong); +long pwrite(int,string3,ulong,long); +long pwrite64(int,string3,ulong,llong); addr sbrk(long); int getpagesize(); -long lseek(int,long,int); +long lseek(int,long,lseek_whence); +long lseek64(int,llong,lseek_whence); int pipe(addr); +; sys/uio.h +typedef iovec = struct(string[elt2],ulong); +long readv(int,+array(iovec,arg3),int); +long writev(int,array(iovec,arg3),int); +long preadv(int,+array(iovec,arg3),int,long); +long pwritev(int,array(iovec,arg3),int,long); +long preadv64(int,+array(iovec,arg3),int,llong); +long pwritev64(int,array(iovec,arg3),int,llong); +long preadv2(int,+array(iovec,arg3),int,long,hex(int)); +long pwritev2(int,array(iovec,arg3),int,long,hex(int)); +long preadv64v2(int,+array(iovec,arg3),int,llong,hex(int)); +long pwritev64v2(int,array(iovec,arg3),int,llong,hex(int)); + ; utmp.h void endutent(); addr getutent(); @@ -414,6 +443,9 @@ addr acl_from_mode(octal); int acl_get_perm(addr,uint); string acl_to_any_text(addr,string,char,int); +; cxxabi.h +void __cxa_finalize(addr); + ; other symbols not included above long a64l(string); string l64a(long);
From: =?utf-8?b?0L3QsNCx?= <[email protected]> Date: Wed, 26 Jul 2023 02:55:43 +0200 Subject: 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 --- lens_default.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lens_default.c b/lens_default.c index 2fd4915..71d9584 100644 --- a/lens_default.c +++ b/lens_default.c @@ -231,7 +231,7 @@ static int format_struct(FILE *stream, struct value *value, struct value_dict *arguments) { int written = 0; - if (acc_fprintf(&written, stream, "{ ") < 0) + if (acc_fprintf(&written, stream, "{") < 0) return -1; int need_delim = 0; @@ -250,7 +250,7 @@ format_struct(FILE *stream, struct value *value, struct value_dict *arguments) written += o; } - if (acc_fprintf(&written, stream, " }") < 0) + if (acc_fprintf(&written, stream, "}") < 0) return -1; return written; } @@ -425,7 +425,7 @@ toplevel_format_lens(struct lens *lens, FILE *stream, case ARGTYPE_ARRAY: return format_array(stream, value, arguments, value->type->u.array_info.length, - options.arraylen, 1, "[ ", " ]", ", "); + options.arraylen, 1, "[", "]", ", "); } abort(); }
signature.asc
Description: PGP signature

