• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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.

変更サマリ

差分

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
11 2017-04-25 Pedro Alves <palves@redhat.com>
22
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+
310 * ada-lang.c (ada_catchpoint_location): Now a "class". Remove
411 "base" field and inherit from "bp_location" instead. Add
512 non-default ctor.
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1112,16 +1112,27 @@ pt_reclassify_insn (enum pt_insn_class iclass)
11121112 /* Return the btrace instruction flags for INSN. */
11131113
11141114 static btrace_insn_flags
1115-pt_btrace_insn_flags (const struct pt_insn *insn)
1115+pt_btrace_insn_flags (const struct pt_insn &insn)
11161116 {
11171117 btrace_insn_flags flags = 0;
11181118
1119- if (insn->speculative)
1119+ if (insn.speculative)
11201120 flags |= BTRACE_INSN_FLAG_SPECULATIVE;
11211121
11221122 return flags;
11231123 }
11241124
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+
11251136 /* Add function branch trace using DECODER. */
11261137
11271138 static void
@@ -1138,7 +1149,6 @@ ftrace_add_pt (struct pt_insn_decoder *decoder,
11381149 end = *pend;
11391150 for (;;)
11401151 {
1141- struct btrace_insn btinsn;
11421152 struct pt_insn insn;
11431153
11441154 errcode = pt_insn_sync_forward (decoder);
@@ -1150,7 +1160,6 @@ ftrace_add_pt (struct pt_insn_decoder *decoder,
11501160 break;
11511161 }
11521162
1153- memset (&btinsn, 0, sizeof (btinsn));
11541163 for (;;)
11551164 {
11561165 errcode = pt_insn_next (decoder, &insn, sizeof(insn));
@@ -1207,11 +1216,7 @@ ftrace_add_pt (struct pt_insn_decoder *decoder,
12071216 /* Maintain the function level offset. */
12081217 *plevel = std::min (*plevel, end->level);
12091218
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);
12151220 ftrace_update_insns (end, &btinsn);
12161221 }
12171222