public inbox for archer-commits@sourceware.org help / color / mirror / Atom feed
From: sergiodj@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-sergiodj-stap: Fixing small nits; commenting the code a little more. Date: Sun, 20 Mar 2011 23:20:00 -0000 [thread overview] Message-ID: <20110320232043.27267.qmail@sourceware.org> (raw) The branch, archer-sergiodj-stap has been updated via fbdebe3724cc56ea4cca3dc836afe64ef37df27e (commit) from 35e2367a245fac7a4d262e2fb88f84932aab9e87 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit fbdebe3724cc56ea4cca3dc836afe64ef37df27e Author: Sergio Durigan Junior <sergiodj@redhat.com> Date: Sun Mar 20 20:20:16 2011 -0300 Fixing small nits; commenting the code a little more. ----------------------------------------------------------------------- Summary of changes: gdb/stap-probe.c | 73 +++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 50 insertions(+), 23 deletions(-) First 500 lines of diff: diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index eb2fb7f..30fb088 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -114,12 +114,20 @@ static struct stap_args_info dummy_stap_args_info = the left side of the expression, and PREC is the precedence of the last operator identified before calling the function. */ -static struct value * -stap_evaluate_probe_argument_2 (struct stap_evaluation_info *eval_info, - struct value *lhs, int prec); +static struct value *stap_evaluate_probe_argument_2 + (struct stap_evaluation_info *eval_info, + struct value *lhs, int prec); -static struct value * -stap_evaluate_conditionally (struct stap_evaluation_info *eval_info); +/* This function is responsible for checking the necessary type of evaluation + depending on what is the next "thing" in the buffer. Valid values are: + + - Unary operators; + - Integer constants; + - Register displacement, indirection, and direct access; + - Parenthesized operand. */ + +static struct value *stap_evaluate_conditionally + (struct stap_evaluation_info *eval_info); static void stap_skip_whitespace_cond (char **s, int inside_paren) @@ -780,12 +788,19 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info, #define REG_NAME_MAX_SIZE 20 char regname[REG_NAME_MAX_SIZE + 1]; int len, regnum, indirect_p = 0; - struct value *ret; + struct value *ret = NULL; /* The function which called us did not check if the expression buffer was empty. */ gdb_assert (s && *s); + if (eval_info->compiling_p) + /* If we are compiling, we cannot return NULL because that would + lead to errors in future evaluations. That's why we just make + this dummy value, representing that the return value of this + function is not NULL. */ + ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); + /* Valid register name on x86 platforms are: [paren]%{a-z0-9}[paren] @@ -826,7 +841,7 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info, len = s - start; - if (*s == ')') + if (indirect_p && *s == ')') ++s; if (len >= REG_NAME_MAX_SIZE) @@ -851,7 +866,7 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info, if (indirect_p) { struct type *t = NULL; - enum agent_op aop; + enum agent_op aop = aop_ref32; /* If the user has specified that the register must be indirected, we should know what's the correct type to cast it before making @@ -863,10 +878,21 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info, { case STAP_ARG_BITNESS_UNDEFINED: if (eval_info->compiling_p) - aop = aop_ref32; + { + if (gdbarch_addr_bit (gdbarch) == 32) + aop = aop_ref32; + else + aop = aop_ref64; + } else - t = lookup_pointer_type - (builtin_type (gdbarch)->builtin_unsigned_long); + { + if (gdbarch_addr_bit (gdbarch) == 32) + t = lookup_pointer_type + (builtin_type (gdbarch)->builtin_uint32); + else + t = lookup_pointer_type + (builtin_type (gdbarch)->builtin_uint64); + } break; case STAP_ARG_BITNESS_32BIT_SIGNED: @@ -932,7 +958,7 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info, some modifications to it before. */ eval_info->exp_buf = s; - return eval_info->compiling_p ? (struct value *) 1 : ret; + return ret; } /* This function tries to evaluate a single operand of the expression. @@ -949,7 +975,14 @@ stap_evaluate_single_operand (struct stap_evaluation_info *eval_info) struct gdbarch *gdbarch = eval_info->gdbarch; struct frame_info *frame = eval_info->frame; enum stap_arg_bitness bitness = eval_info->bitness; - struct value *res; + struct value *res = NULL; + + if (eval_info->compiling_p) + /* If we are compiling, we cannot return NULL because that would + lead to errors in future evaluations. That's why we just make + this dummy value, representing that the return value of this + function is not NULL. */ + res = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); switch (*eval_info->exp_buf) { @@ -957,7 +990,7 @@ stap_evaluate_single_operand (struct stap_evaluation_info *eval_info) { char c = *eval_info->exp_buf; - /* This is a binary operator (either `-' or `~'). + /* This is an unary operator (either `-' or `~'). If it is followed by a parenthesis, and this parenthesis is NOT followed by a `%', then we are dealing with an expression @@ -1122,6 +1155,7 @@ stap_evaluate_single_operand (struct stap_evaluation_info *eval_info) { /* Register access, with or without indirection. */ res = stap_fetch_reg_value (eval_info, /*displacement=*/NULL); + eval_info->exp_buf = skip_spaces (eval_info->exp_buf); } break; @@ -1132,17 +1166,9 @@ stap_evaluate_single_operand (struct stap_evaluation_info *eval_info) } } - return eval_info->compiling_p ? (struct value *) 1 : res; + return res; } -/* This function is responsible for checking the necessary type of evaluation - depending on what is the next "thing" in the buffer. Valid values are: - - - Unary operators; - - Integer constants; - - Register displacement, indirection, and direct access; - - Parenthesized operand. */ - static struct value * stap_evaluate_conditionally (struct stap_evaluation_info *eval_info) { @@ -1170,6 +1196,7 @@ stap_evaluate_conditionally (struct stap_evaluation_info *eval_info) if (*eval_info->exp_buf != ')') error (_("Missign close-paren on expression `%s'."), eval_info->saved_expr); + ++eval_info->exp_buf; eval_info->exp_buf = skip_spaces (eval_info->exp_buf); } hooks/post-receive -- Repository for Project Archer.
reply other threads:[~2011-03-20 23:20 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20110320232043.27267.qmail@sourceware.org \ --to=sergiodj@sourceware.org \ --cc=archer-commits@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).