Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: gdb/stap-probe.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/stap-probe.h ('k') | gdb/std-operator.def » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* SystemTap probe support for GDB. 1 /* SystemTap probe support for GDB.
2 2
3 Copyright (C) 2012 Free Software Foundation, Inc. 3 Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5 This file is part of GDB. 5 This file is part of GDB.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or 9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 #define STAP_BASE_SECTION_NAME ".stapsdt.base" 47 #define STAP_BASE_SECTION_NAME ".stapsdt.base"
48 48
49 /* Forward declaration. */ 49 /* Forward declaration. */
50 50
51 static const struct probe_ops stap_probe_ops; 51 static const struct probe_ops stap_probe_ops;
52 52
53 /* Should we display debug information for the probe's argument expression 53 /* Should we display debug information for the probe's argument expression
54 parsing? */ 54 parsing? */
55 55
56 static int stap_expression_debug = 0; 56 static unsigned int stap_expression_debug = 0;
57 57
58 /* The various possibilities of bitness defined for a probe's argument. 58 /* The various possibilities of bitness defined for a probe's argument.
59 59
60 The relationship is: 60 The relationship is:
61 61
62 - STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness. 62 - STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness.
63 - STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'. 63 - STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'.
64 - STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'. 64 - STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'.
65 - STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'. 65 - STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'.
66 - STAP_ARG_BITNESS_64BIT_SIGNED: argument string starts with `-8@'. */ 66 - STAP_ARG_BITNESS_64BIT_SIGNED: argument string starts with `-8@'. */
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (*p->arg == '-') 415 if (*p->arg == '-')
416 { 416 {
417 got_minus = 1; 417 got_minus = 1;
418 ++p->arg; 418 ++p->arg;
419 } 419 }
420 420
421 if (isdigit (*p->arg)) 421 if (isdigit (*p->arg))
422 { 422 {
423 /* The value of the displacement. */ 423 /* The value of the displacement. */
424 long displacement; 424 long displacement;
425 char *endp;
425 426
426 disp_p = 1; 427 disp_p = 1;
427 displacement = strtol (p->arg, (char **) &p->arg, 10); 428 displacement = strtol (p->arg, &endp, 10);
429 p->arg = endp;
428 430
429 /* Generating the expression for the displacement. */ 431 /* Generating the expression for the displacement. */
430 write_exp_elt_opcode (OP_LONG); 432 write_exp_elt_opcode (OP_LONG);
431 write_exp_elt_type (builtin_type (gdbarch)->builtin_long); 433 write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
432 write_exp_elt_longcst (displacement); 434 write_exp_elt_longcst (displacement);
433 write_exp_elt_opcode (OP_LONG); 435 write_exp_elt_opcode (OP_LONG);
434 if (got_minus) 436 if (got_minus)
435 write_exp_elt_opcode (UNOP_NEG); 437 write_exp_elt_opcode (UNOP_NEG);
436 } 438 }
437 439
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 - numeric literal; 593 - numeric literal;
592 - number (from register displacement) 594 - number (from register displacement)
593 - subexpression (beginning with `(') 595 - subexpression (beginning with `(')
594 596
595 We handle the register displacement here, and the other cases 597 We handle the register displacement here, and the other cases
596 recursively. */ 598 recursively. */
597 if (p->inside_paren_p) 599 if (p->inside_paren_p)
598 tmp = skip_spaces_const (tmp); 600 tmp = skip_spaces_const (tmp);
599 601
600 if (isdigit (*tmp)) 602 if (isdigit (*tmp))
601 » number = strtol (tmp, (char **) &tmp, 10); 603 » {
604 » char *endp;
605
606 » number = strtol (tmp, &endp, 10);
607 » tmp = endp;
608 » }
602 609
603 if (!reg_ind_prefix 610 if (!reg_ind_prefix
604 || strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0) 611 || strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0)
605 { 612 {
606 /* This is not a displacement. We skip the operator, and deal 613 /* This is not a displacement. We skip the operator, and deal
607 with it later. */ 614 with it later. */
608 ++p->arg; 615 ++p->arg;
609 stap_parse_argument_conditionally (p); 616 stap_parse_argument_conditionally (p);
610 if (c == '-') 617 if (c == '-')
611 write_exp_elt_opcode (UNOP_NEG); 618 write_exp_elt_opcode (UNOP_NEG);
612 else if (c == '~') 619 else if (c == '~')
613 write_exp_elt_opcode (UNOP_COMPLEMENT); 620 write_exp_elt_opcode (UNOP_COMPLEMENT);
614 } 621 }
615 else 622 else
616 { 623 {
617 /* If we are here, it means it is a displacement. The only 624 /* If we are here, it means it is a displacement. The only
618 operations allowed here are `-' and `+'. */ 625 operations allowed here are `-' and `+'. */
619 if (c == '~') 626 if (c == '~')
620 error (_("Invalid operator `%c' for register displacement " 627 error (_("Invalid operator `%c' for register displacement "
621 "on expression `%s'."), c, p->saved_arg); 628 "on expression `%s'."), c, p->saved_arg);
622 629
623 stap_parse_register_operand (p); 630 stap_parse_register_operand (p);
624 } 631 }
625 } 632 }
626 else if (isdigit (*p->arg)) 633 else if (isdigit (*p->arg))
627 { 634 {
628 /* A temporary variable, needed for lookahead. */ 635 /* A temporary variable, needed for lookahead. */
629 const char *tmp = p->arg; 636 const char *tmp = p->arg;
637 char *endp;
630 long number; 638 long number;
631 639
632 /* We can be dealing with a numeric constant (if `const_prefix' is 640 /* We can be dealing with a numeric constant (if `const_prefix' is
633 NULL), or with a register displacement. */ 641 NULL), or with a register displacement. */
634 number = strtol (tmp, (char **) &tmp, 10); 642 number = strtol (tmp, &endp, 10);
643 tmp = endp;
635 644
636 if (p->inside_paren_p) 645 if (p->inside_paren_p)
637 tmp = skip_spaces_const (tmp); 646 tmp = skip_spaces_const (tmp);
638 if (!const_prefix && reg_ind_prefix 647 if (!const_prefix && reg_ind_prefix
639 && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0) 648 && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0)
640 { 649 {
641 /* We are dealing with a numeric constant. */ 650 /* We are dealing with a numeric constant. */
642 write_exp_elt_opcode (OP_LONG); 651 write_exp_elt_opcode (OP_LONG);
643 write_exp_elt_type (builtin_type (gdbarch)->builtin_long); 652 write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
644 write_exp_elt_longcst (number); 653 write_exp_elt_longcst (number);
(...skipping 15 matching lines...) Expand all
660 stap_parse_register_operand (p); 669 stap_parse_register_operand (p);
661 else 670 else
662 error (_("Unknown numeric token on expression `%s'."), 671 error (_("Unknown numeric token on expression `%s'."),
663 p->saved_arg); 672 p->saved_arg);
664 } 673 }
665 else if (const_prefix 674 else if (const_prefix
666 && strncmp (p->arg, const_prefix, const_prefix_len) == 0) 675 && strncmp (p->arg, const_prefix, const_prefix_len) == 0)
667 { 676 {
668 /* We are dealing with a numeric constant. */ 677 /* We are dealing with a numeric constant. */
669 long number; 678 long number;
679 char *endp;
670 680
671 p->arg += const_prefix_len; 681 p->arg += const_prefix_len;
672 number = strtol (p->arg, (char **) &p->arg, 10); 682 number = strtol (p->arg, &endp, 10);
683 p->arg = endp;
673 684
674 write_exp_elt_opcode (OP_LONG); 685 write_exp_elt_opcode (OP_LONG);
675 write_exp_elt_type (builtin_type (gdbarch)->builtin_long); 686 write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
676 write_exp_elt_longcst (number); 687 write_exp_elt_longcst (number);
677 write_exp_elt_opcode (OP_LONG); 688 write_exp_elt_opcode (OP_LONG);
678 689
679 if (const_suffix) 690 if (const_suffix)
680 { 691 {
681 if (strncmp (p->arg, const_suffix, const_suffix_len) == 0) 692 if (strncmp (p->arg, const_suffix, const_suffix_len) == 0)
682 p->arg += const_suffix_len; 693 p->arg += const_suffix_len;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 907
897 Consider the following argument string (x86 syntax): 908 Consider the following argument string (x86 syntax):
898 909
899 `4@%eax 4@$10' 910 `4@%eax 4@$10'
900 911
901 We have two arguments, `%eax' and `$10', both with 32-bit unsigned bitness. 912 We have two arguments, `%eax' and `$10', both with 32-bit unsigned bitness.
902 This function basically handles them, properly filling some structures with 913 This function basically handles them, properly filling some structures with
903 this information. */ 914 this information. */
904 915
905 static void 916 static void
906 stap_parse_probe_arguments (struct stap_probe *probe, struct objfile *objfile) 917 stap_parse_probe_arguments (struct stap_probe *probe)
907 { 918 {
908 const char *cur; 919 const char *cur;
909 struct gdbarch *gdbarch = get_objfile_arch (objfile); 920 struct gdbarch *gdbarch = get_objfile_arch (probe->p.objfile);
910 921
911 gdb_assert (!probe->args_parsed); 922 gdb_assert (!probe->args_parsed);
912 cur = probe->args_u.text; 923 cur = probe->args_u.text;
913 probe->args_parsed = 1; 924 probe->args_parsed = 1;
914 probe->args_u.vec = NULL; 925 probe->args_u.vec = NULL;
915 926
916 if (!cur || !*cur || *cur == ':') 927 if (!cur || !*cur || *cur == ':')
917 return; 928 return;
918 929
919 while (*cur) 930 while (*cur)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 cur = skip_spaces_const (cur); 995 cur = skip_spaces_const (cur);
985 996
986 VEC_safe_push (stap_probe_arg_s, probe->args_u.vec, &arg); 997 VEC_safe_push (stap_probe_arg_s, probe->args_u.vec, &arg);
987 } 998 }
988 } 999 }
989 1000
990 /* Given PROBE, returns the number of arguments present in that probe's 1001 /* Given PROBE, returns the number of arguments present in that probe's
991 argument string. */ 1002 argument string. */
992 1003
993 static unsigned 1004 static unsigned
994 stap_get_probe_argument_count (struct probe *probe_generic, 1005 stap_get_probe_argument_count (struct probe *probe_generic)
995 » » » struct objfile *objfile)
996 { 1006 {
997 struct stap_probe *probe = (struct stap_probe *) probe_generic; 1007 struct stap_probe *probe = (struct stap_probe *) probe_generic;
998 1008
999 gdb_assert (probe_generic->pops == &stap_probe_ops); 1009 gdb_assert (probe_generic->pops == &stap_probe_ops);
1000 1010
1001 if (!probe->args_parsed) 1011 if (!probe->args_parsed)
1002 stap_parse_probe_arguments (probe, objfile); 1012 {
1013 if (probe_generic->pops->can_evaluate_probe_arguments (probe_generic))
1014 » stap_parse_probe_arguments (probe);
1015 else
1016 » {
1017 » static int have_warned_stap_incomplete = 0;
1018
1019 » if (!have_warned_stap_incomplete)
1020 » {
1021 » warning (_(
1022 "The SystemTap SDT probe support is not fully implemented on this target;\n"
1023 "you will not be able to inspect the arguments of the probes.\n"
1024 "Please report a bug against GDB requesting a port to this target."));
1025 » have_warned_stap_incomplete = 1;
1026 » }
1027
1028 » /* Marking the arguments as "already parsed". */
1029 » probe->args_u.vec = NULL;
1030 » probe->args_parsed = 1;
1031 » }
1032 }
1003 1033
1004 gdb_assert (probe->args_parsed); 1034 gdb_assert (probe->args_parsed);
1005 return VEC_length (stap_probe_arg_s, probe->args_u.vec); 1035 return VEC_length (stap_probe_arg_s, probe->args_u.vec);
1006 } 1036 }
1007 1037
1008 /* Return 1 if OP is a valid operator inside a probe argument, or zero 1038 /* Return 1 if OP is a valid operator inside a probe argument, or zero
1009 otherwise. */ 1039 otherwise. */
1010 1040
1011 static int 1041 static int
1012 stap_is_operator (const char *op) 1042 stap_is_operator (const char *op)
(...skipping 22 matching lines...) Expand all
1035 1065
1036 default: 1066 default:
1037 /* We didn't find any operator. */ 1067 /* We didn't find any operator. */
1038 ret = 0; 1068 ret = 0;
1039 } 1069 }
1040 1070
1041 return ret; 1071 return ret;
1042 } 1072 }
1043 1073
1044 static struct stap_probe_arg * 1074 static struct stap_probe_arg *
1045 stap_get_arg (struct stap_probe *probe, struct objfile *objfile, unsigned n) 1075 stap_get_arg (struct stap_probe *probe, unsigned n)
1046 { 1076 {
1047 if (!probe->args_parsed) 1077 if (!probe->args_parsed)
1048 stap_parse_probe_arguments (probe, objfile); 1078 stap_parse_probe_arguments (probe);
1049 1079
1050 return VEC_index (stap_probe_arg_s, probe->args_u.vec, n); 1080 return VEC_index (stap_probe_arg_s, probe->args_u.vec, n);
1051 } 1081 }
1052 1082
1083 /* Implement the `can_evaluate_probe_arguments' method of probe_ops. */
1084
1085 static int
1086 stap_can_evaluate_probe_arguments (struct probe *probe_generic)
1087 {
1088 struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
1089 struct gdbarch *gdbarch = get_objfile_arch (stap_probe->p.objfile);
1090
1091 /* For SystemTap probes, we have to guarantee that the method
1092 stap_is_single_operand is defined on gdbarch. If it is not, then it
1093 means that argument evaluation is not implemented on this target. */
1094 return gdbarch_stap_is_single_operand_p (gdbarch);
1095 }
1096
1053 /* Evaluate the probe's argument N (indexed from 0), returning a value 1097 /* Evaluate the probe's argument N (indexed from 0), returning a value
1054 corresponding to it. Assertion is thrown if N does not exist. */ 1098 corresponding to it. Assertion is thrown if N does not exist. */
1055 1099
1056 static struct value * 1100 static struct value *
1057 stap_evaluate_probe_argument (struct probe *probe_generic, 1101 stap_evaluate_probe_argument (struct probe *probe_generic, unsigned n)
1058 » » » struct objfile *objfile, unsigned n)
1059 { 1102 {
1060 struct stap_probe *stap_probe = (struct stap_probe *) probe_generic; 1103 struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
1061 struct stap_probe_arg *arg; 1104 struct stap_probe_arg *arg;
1062 int pos = 0; 1105 int pos = 0;
1063 1106
1064 gdb_assert (probe_generic->pops == &stap_probe_ops); 1107 gdb_assert (probe_generic->pops == &stap_probe_ops);
1065 1108
1066 arg = stap_get_arg (stap_probe, objfile, n); 1109 arg = stap_get_arg (stap_probe, n);
1067 return evaluate_subexp_standard (arg->atype, arg->aexpr, &pos, EVAL_NORMAL); 1110 return evaluate_subexp_standard (arg->atype, arg->aexpr, &pos, EVAL_NORMAL);
1068 } 1111 }
1069 1112
1070 /* Compile the probe's argument N (indexed from 0) to agent expression. 1113 /* Compile the probe's argument N (indexed from 0) to agent expression.
1071 Assertion is thrown if N does not exist. */ 1114 Assertion is thrown if N does not exist. */
1072 1115
1073 static void 1116 static void
1074 stap_compile_to_ax (struct probe *probe_generic, struct objfile *objfile, 1117 stap_compile_to_ax (struct probe *probe_generic, struct agent_expr *expr,
1075 » » struct agent_expr *expr, struct axs_value *value, 1118 » » struct axs_value *value, unsigned n)
1076 » » unsigned n)
1077 { 1119 {
1078 struct stap_probe *stap_probe = (struct stap_probe *) probe_generic; 1120 struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
1079 struct stap_probe_arg *arg; 1121 struct stap_probe_arg *arg;
1080 union exp_element *pc; 1122 union exp_element *pc;
1081 1123
1082 gdb_assert (probe_generic->pops == &stap_probe_ops); 1124 gdb_assert (probe_generic->pops == &stap_probe_ops);
1083 1125
1084 arg = stap_get_arg (stap_probe, objfile, n); 1126 arg = stap_get_arg (stap_probe, n);
1085 1127
1086 pc = arg->aexpr->elts; 1128 pc = arg->aexpr->elts;
1087 gen_expr (arg->aexpr, &pc, expr, value); 1129 gen_expr (arg->aexpr, &pc, expr, value);
1088 1130
1089 require_rvalue (expr, value); 1131 require_rvalue (expr, value);
1090 value->type = arg->atype; 1132 value->type = arg->atype;
1091 } 1133 }
1092 1134
1093 /* Destroy (free) the data related to PROBE. PROBE memory itself is not feed 1135 /* Destroy (free) the data related to PROBE. PROBE memory itself is not feed
1094 as it is allocated from OBJFILE_OBSTACK. */ 1136 as it is allocated from OBJFILE_OBSTACK. */
(...skipping 19 matching lines...) Expand all
1114 1156
1115 1157
1116 1158
1117 1159
1118 /* This is called to compute the value of one of the $_probe_arg* 1160 /* This is called to compute the value of one of the $_probe_arg*
1119 convenience variables. */ 1161 convenience variables. */
1120 1162
1121 static struct value * 1163 static struct value *
1122 compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar, 1164 compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
1123 void *data) 1165 void *data)

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/stap-probe.h ('k') | gdb/std-operator.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698