GNU Binutils with patches for OS216
リビジョン | b5c3668253b909fd1f5b011893a35bb8dfd3be9b (tree) |
---|---|
日時 | 2017-04-25 09:43:52 |
作者 | Pedro Alves <palves@redh...> |
コミッター | Pedro Alves |
Don't memset non-POD types: struct btrace_insn
struct btrace_insn is not a POD [1] so we shouldn't be using memset to
initialize it [2].
Use list-initialization instead, wrapped in a "pt insn to btrace insn"
function, which looks like just begging to be added next to the
existing pt_reclassify_insn/pt_btrace_insn_flags functions.
[1] - because its field "flags" is not POD, because enum_flags has a
non-trivial default ctor.
gdb/ChangeLog:
2017-04-25 Pedro Alves <palves@redhat.com>
* btrace.c (pt_btrace_insn_flags): Change parameter type to
reference.
(pt_btrace_insn): New function.
(ftrace_add_pt): Remove memset call and use pt_btrace_insn.
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2017-04-25 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * btrace.c (pt_btrace_insn_flags): Change parameter type to | |
4 | + reference. | |
5 | + (pt_btrace_insn): New function. | |
6 | + (ftrace_add_pt): Remove memset call and use pt_btrace_insn. | |
7 | + | |
8 | +2017-04-25 Pedro Alves <palves@redhat.com> | |
9 | + | |
3 | 10 | * ada-lang.c (ada_catchpoint_location): Now a "class". Remove |
4 | 11 | "base" field and inherit from "bp_location" instead. Add |
5 | 12 | non-default ctor. |
@@ -1112,16 +1112,27 @@ pt_reclassify_insn (enum pt_insn_class iclass) | ||
1112 | 1112 | /* Return the btrace instruction flags for INSN. */ |
1113 | 1113 | |
1114 | 1114 | static btrace_insn_flags |
1115 | -pt_btrace_insn_flags (const struct pt_insn *insn) | |
1115 | +pt_btrace_insn_flags (const struct pt_insn &insn) | |
1116 | 1116 | { |
1117 | 1117 | btrace_insn_flags flags = 0; |
1118 | 1118 | |
1119 | - if (insn->speculative) | |
1119 | + if (insn.speculative) | |
1120 | 1120 | flags |= BTRACE_INSN_FLAG_SPECULATIVE; |
1121 | 1121 | |
1122 | 1122 | return flags; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | +/* Return the btrace instruction for INSN. */ | |
1126 | + | |
1127 | +static btrace_insn | |
1128 | +pt_btrace_insn (const struct pt_insn &insn) | |
1129 | +{ | |
1130 | + return {(CORE_ADDR) insn.ip, (gdb_byte) insn.size, | |
1131 | + pt_reclassify_insn (insn.iclass), | |
1132 | + pt_btrace_insn_flags (insn)}; | |
1133 | +} | |
1134 | + | |
1135 | + | |
1125 | 1136 | /* Add function branch trace using DECODER. */ |
1126 | 1137 | |
1127 | 1138 | static void |
@@ -1138,7 +1149,6 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, | ||
1138 | 1149 | end = *pend; |
1139 | 1150 | for (;;) |
1140 | 1151 | { |
1141 | - struct btrace_insn btinsn; | |
1142 | 1152 | struct pt_insn insn; |
1143 | 1153 | |
1144 | 1154 | errcode = pt_insn_sync_forward (decoder); |
@@ -1150,7 +1160,6 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, | ||
1150 | 1160 | break; |
1151 | 1161 | } |
1152 | 1162 | |
1153 | - memset (&btinsn, 0, sizeof (btinsn)); | |
1154 | 1163 | for (;;) |
1155 | 1164 | { |
1156 | 1165 | errcode = pt_insn_next (decoder, &insn, sizeof(insn)); |
@@ -1207,11 +1216,7 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, | ||
1207 | 1216 | /* Maintain the function level offset. */ |
1208 | 1217 | *plevel = std::min (*plevel, end->level); |
1209 | 1218 | |
1210 | - btinsn.pc = (CORE_ADDR) insn.ip; | |
1211 | - btinsn.size = (gdb_byte) insn.size; | |
1212 | - btinsn.iclass = pt_reclassify_insn (insn.iclass); | |
1213 | - btinsn.flags = pt_btrace_insn_flags (&insn); | |
1214 | - | |
1219 | + btrace_insn btinsn = pt_btrace_insn (insn); | |
1215 | 1220 | ftrace_update_insns (end, &btinsn); |
1216 | 1221 | } |
1217 | 1222 |