[Ltrace-devel] [PATCH 7/11] short,ushort,float
Steve Fink
sphink at gmail.com
Sat Aug 5 23:57:11 UTC 2006
-------------- next part --------------
From 3a6b72d7d33bbd6e0e99982e54c431f39947a2fd Mon Sep 17 00:00:00 2001
From: Steve Fink sphink at gmail.com <sphink at gmail.com>
Date: Sat, 22 Jul 2006 17:04:49 -0700
Subject: [PATCH 7/11] Implement short, ushort, float
The 'float' stuff works here, but it may not be portable.
---
ChangeLog | 6 +++++-
display_args.c | 9 +++++++++
etc/ltrace.conf | 6 ++++--
ltrace.h | 3 +++
read_config_file.c | 6 ++++++
testsuite/ltrace.main/parameters-lib.c | 15 +++++++++++++++
testsuite/ltrace.main/parameters.c | 9 +++++++++
testsuite/ltrace.main/parameters.conf | 3 +++
testsuite/ltrace.main/parameters.exp | 8 ++++++++
9 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 83940b8..13239bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,12 @@
2006-07-20 Steve Fink <sphink at gmail.com>
+ * various: Implement short, ushort, float types
+
+2006-07-21 Steve Fink <sphink at gmail.com>
+
* various: Implement enumerated parameters
-2006-07-21 <sphink at gmail.com>
+2006-07-21 Steve Fink <sphink at gmail.com>
* various: add pointers as valid parameter descriptor
* display_args.c: switch to passing around values rather than
diff --git a/display_args.c b/display_args.c
index 2a6b34f..bb0bca0 100644
--- a/display_args.c
+++ b/display_args.c
@@ -91,6 +91,15 @@ int display_value(enum tof type, struct
tmp += display_char(value == -1 ? value : (char) value);
tmp += fprintf(output, "'");
return tmp;
+ case ARGTYPE_SHORT:
+ return fprintf(output, "%hd", (short) value);
+ case ARGTYPE_USHORT:
+ return fprintf(output, "%hu", (unsigned short) value);
+ case ARGTYPE_FLOAT: {
+ union { long l; float f; } cvt;
+ cvt.l = value;
+ return fprintf(output, "%f", cvt.f);
+ }
case ARGTYPE_ADDR:
if (!value)
return fprintf(output, "NULL");
diff --git a/etc/ltrace.conf b/etc/ltrace.conf
index bff45fa..66db092 100644
--- a/etc/ltrace.conf
+++ b/etc/ltrace.conf
@@ -14,6 +14,8 @@
; ulong == (unsigned long)
; octal == (unsigned) [written in octal]
; char
+; short == (short)
+; ushort == (unsigned short)
; addr == (void *) [unsigned, written in hexa]
; file == (FILE *) [TODO]
; format == ((const char *), ...) [printf() like] [TODO]
@@ -154,8 +156,8 @@ addr getservbyport(int, string);
addr getservent(void);
void herror(string);
string hstrerror(int);
-;int rcmd(addr, ushort, string, string, string, addr); FIXME implement ushort
-;int rcmd_af(addr, ushort, string, string, string, addr, int); FIXME implement ushort
+int rcmd(addr, ushort, string, string, string, addr);
+int rcmd_af(addr, ushort, string, string, string, addr, int);
int rexec(addr, int, string, string, string, addr);
int rexec_af(addr, int, string, string, string, addr, int);
int rresvport (addr);
diff --git a/ltrace.h b/ltrace.h
index 3b40cb3..2b34476 100644
--- a/ltrace.h
+++ b/ltrace.h
@@ -37,6 +37,9 @@ enum arg_type {
ARGTYPE_ULONG,
ARGTYPE_OCTAL,
ARGTYPE_CHAR,
+ ARGTYPE_SHORT,
+ ARGTYPE_USHORT,
+ ARGTYPE_FLOAT,
ARGTYPE_ADDR,
ARGTYPE_FILE,
ARGTYPE_FORMAT, /* printf-like format */
diff --git a/read_config_file.c b/read_config_file.c
index 5b114de..dab66b3 100644
--- a/read_config_file.c
+++ b/read_config_file.c
@@ -29,6 +29,9 @@ static struct list_of_pt_t {
"ulong", ARGTYPE_ULONG}, {
"octal", ARGTYPE_OCTAL}, {
"char", ARGTYPE_CHAR}, {
+ "short", ARGTYPE_SHORT}, {
+ "ushort", ARGTYPE_USHORT}, {
+ "float", ARGTYPE_FLOAT}, {
"addr", ARGTYPE_ADDR}, {
"file", ARGTYPE_FILE}, {
"format", ARGTYPE_FORMAT}, {
@@ -46,6 +49,9 @@ static arg_type_info arg_type_singletons
{ ARGTYPE_ULONG },
{ ARGTYPE_OCTAL },
{ ARGTYPE_CHAR },
+ { ARGTYPE_SHORT },
+ { ARGTYPE_USHORT },
+ { ARGTYPE_FLOAT },
{ ARGTYPE_ADDR },
{ ARGTYPE_FILE },
{ ARGTYPE_FORMAT },
diff --git a/testsuite/ltrace.main/parameters-lib.c b/testsuite/ltrace.main/parameters-lib.c
index b43de08..870809d 100644
--- a/testsuite/ltrace.main/parameters-lib.c
+++ b/testsuite/ltrace.main/parameters-lib.c
@@ -41,3 +41,18 @@ void func_enum(int x)
{
printf("enum: %d\n", x);
}
+
+void func_short(short x1, short x2)
+{
+ printf("short: %hd %hd\n", x1, x2);
+}
+
+void func_ushort(unsigned short x1, unsigned short x2)
+{
+ printf("ushort: %hu %hu\n", x1, x2);
+}
+
+void func_float(float f1, float f2)
+{
+ printf("%f %f\n", f1, f2);
+}
diff --git a/testsuite/ltrace.main/parameters.c b/testsuite/ltrace.main/parameters.c
index d7c225f..93811c1 100644
--- a/testsuite/ltrace.main/parameters.c
+++ b/testsuite/ltrace.main/parameters.c
@@ -19,6 +19,9 @@ int func_strlen(char*);
void func_strfixed(char*);
void func_ppp(int***);
void func_stringp(char**);
+void func_short(short, short);
+void func_ushort(unsigned short, unsigned short);
+void func_float(float, float);
typedef enum {
RED,
@@ -59,4 +62,10 @@ main ()
func_stringp(&s);
func_enum(BLUE);
+
+ func_short(-8, -9);
+ func_ushort(33, 34);
+ func_float(3.4, -3.4);
+
+ return 0;
}
diff --git a/testsuite/ltrace.main/parameters.conf b/testsuite/ltrace.main/parameters.conf
index debb1dc..394919b 100644
--- a/testsuite/ltrace.main/parameters.conf
+++ b/testsuite/ltrace.main/parameters.conf
@@ -6,3 +6,6 @@ void func_strfixed(string[4])
void func_ppp(int***)
void func_stringp(string*)
void func_enum(enum (RED=0,GREEN=1,BLUE=2,CHARTREUSE=3,PETUNIA=4))
+void func_short(short,short)
+void func_ushort(ushort, ushort)
+void func_float(float,float)
diff --git a/testsuite/ltrace.main/parameters.exp b/testsuite/ltrace.main/parameters.exp
index 024c3f3..e47dc0d 100644
--- a/testsuite/ltrace.main/parameters.exp
+++ b/testsuite/ltrace.main/parameters.exp
@@ -52,3 +52,11 @@ set pattern "func_stringp(\\\"Dude\\\")"
ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
set pattern "func_enum(BLUE)"
ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "func_short(-8, -9)"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "func_ushort(33, 34)"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "func_float(3.40*, -3.40*)"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
+set pattern "exited (status 0)"
+ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern 1
--
1.4.1
More information about the Ltrace-devel
mailing list