From eeaa5ffd60366a50d3b607760dfbb3ece70ce894 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 12 May 2014 17:07:27 +0200 Subject: [PATCH] Fix aarch64 gdbr profile and update sdb --- libr/debug/p/debug_gdb.c | 8 +++++++- libr/include/sdb/sdb.h | 1 + shlr/sdb/src/query.c | 15 +++++++++++---- shlr/sdb/src/sdb.c | 17 +++++++++++++++++ shlr/sdb/src/sdb.h | 1 + shlr/sdb/src/util.c | 2 +- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/libr/debug/p/debug_gdb.c b/libr/debug/p/debug_gdb.c index 103cdb7bb7..e086b6972b 100644 --- a/libr/debug/p/debug_gdb.c +++ b/libr/debug/p/debug_gdb.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2012 - pancake */ +/* radare - LGPL - Copyright 2009-2014 - pancake, defragger */ #include #include @@ -267,6 +267,12 @@ static const char *r_debug_gdb_reg_profile(RDebug *dbg) { ); } else if (dbg->bits == R_SYS_BITS_64) { return strdup ( + "=pc pc\n" + "=sp sp\n" + "=a0 r0\n" + "=a1 r1\n" + "=a2 r2\n" + "=a3 r3\n" "gpr x0 .8 0 0\n" "gpr x1 .8 8 0\n" "gpr x2 .8 16 0\n" diff --git a/libr/include/sdb/sdb.h b/libr/include/sdb/sdb.h index edeaa790b0..c4203bfbe4 100644 --- a/libr/include/sdb/sdb.h +++ b/libr/include/sdb/sdb.h @@ -95,6 +95,7 @@ char *sdb_get (Sdb*, const char *key, ut32 *cas); const char *sdb_const_get (Sdb*, const char *key, ut32 *cas); int sdb_set (Sdb*, const char *key, const char *data, ut32 cas); int sdb_concat(Sdb *s, const char *key, const char *value, ut32 cas); +int sdb_uncat(Sdb *s, const char *key, const char *value, ut32 cas); int sdb_add (Sdb* s, const char *key, const char *val, ut32 cas); void sdb_list(Sdb*); int sdb_sync (Sdb*); diff --git a/shlr/sdb/src/query.c b/shlr/sdb/src/query.c index bec03bd6a4..6098a77be5 100644 --- a/shlr/sdb/src/query.c +++ b/shlr/sdb/src/query.c @@ -259,15 +259,22 @@ next_quote: if (sdb_isnum (val)) { int op = *cmd; if (*val=='-') { - op = '-'; + if (*cmd == '-') { + op = '+'; + } else { + op = '-'; + } d = sdb_atoi (val+1); } else d = sdb_atoi (val); if (op=='+') sdb_num_inc (s, cmd+1, d, 0); - else - sdb_num_dec (s, cmd+1, d, 0); + else sdb_num_dec (s, cmd+1, d, 0); } else { - sdb_concat (s, cmd+1, val, 0); + if (*cmd=='+') { + sdb_concat (s, cmd+1, val, 0); + } else { + sdb_uncat (s, cmd+1, val, 0); + } } } else { int base = sdb_num_base (sdb_const_get (s, cmd+1, 0)); diff --git a/shlr/sdb/src/sdb.c b/shlr/sdb/src/sdb.c index b20c0039f3..b8522a03d7 100644 --- a/shlr/sdb/src/sdb.c +++ b/shlr/sdb/src/sdb.c @@ -231,6 +231,23 @@ SDB_API int sdb_unset (Sdb* s, const char *key, ut32 cas) { return key? sdb_set (s, key, "", cas): 0; } +// alias for '-key=str'.. '+key=str' concats +SDB_API int sdb_uncat(Sdb *s, const char *key, const char *value, ut32 cas) { + // remove 'value' from current key value. + // TODO: cas is ignored here + char *p, *v = sdb_get (s, key, NULL); + int vlen = strlen (value); + int mod = 0; + while ((p = strstr (v, value))) { + memmove (p, p+vlen, strlen (p+vlen)+1); + mod = 1; + } + if (mod) + sdb_set (s, key, v, 0); + free (v); + return 0; +} + SDB_API int sdb_concat(Sdb *s, const char *key, const char *value, ut32 cas) { int ret, kl, vl; const char *p; diff --git a/shlr/sdb/src/sdb.h b/shlr/sdb/src/sdb.h index edeaa790b0..c4203bfbe4 100644 --- a/shlr/sdb/src/sdb.h +++ b/shlr/sdb/src/sdb.h @@ -95,6 +95,7 @@ char *sdb_get (Sdb*, const char *key, ut32 *cas); const char *sdb_const_get (Sdb*, const char *key, ut32 *cas); int sdb_set (Sdb*, const char *key, const char *data, ut32 cas); int sdb_concat(Sdb *s, const char *key, const char *value, ut32 cas); +int sdb_uncat(Sdb *s, const char *key, const char *value, ut32 cas); int sdb_add (Sdb* s, const char *key, const char *val, ut32 cas); void sdb_list(Sdb*); int sdb_sync (Sdb*); diff --git a/shlr/sdb/src/util.c b/shlr/sdb/src/util.c index f625eaf64f..8b673366b6 100644 --- a/shlr/sdb/src/util.c +++ b/shlr/sdb/src/util.c @@ -157,7 +157,7 @@ SDB_API ut64 sdb_unow () { } SDB_API int sdb_isnum (const char *s) { - if (*s=='-') // || *s=='+') + if (*s=='-' || *s=='+') return 1; if (*s>='0' && *s<='9') return 1;