• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

GNU Binutils with patches for OS216


Commit MetaInfo

修订版19f1935d91bfabbe4176ffdaca95bc789b593153 (tree)
时间2016-11-17 09:23:17
作者Pedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

gdb/tracepoint.c: Don't use printf_vma

I noticed that bfd's printf_vma prints to stdout directly:

bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)

This is a bad idea in gdb, where we should use
gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.

Eliminate uses of sprintf_vma too while at it.

Tested on Fedora 23, w/ gdbserver.

gdb/ChangeLog:
2016-11-17 Pedro Alves <palves@redhat.com>

* tracepoint.c (collection_list::add_memrange): Add gdbarch
parameter. Use paddress instead of printf_vma. Adjust recursive
calls.
(collection_list::stringify): Use paddress and phex_nz instead of
sprintf_vma. Adjust add_memrange call.
* tracepoint.h (collection_list::add_memrange): Add gdbarch
parameter.

更改概述

差异

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
1+2016-11-17 Pedro Alves <palves@redhat.com>
2+
3+ * tracepoint.c (collection_list::add_memrange): Add gdbarch
4+ parameter. Use paddress instead of printf_vma. Adjust recursive
5+ calls.
6+ (collection_list::stringify): Use paddress and phex_nz instead of
7+ sprintf_vma. Adjust add_memrange call.
8+ * tracepoint.h (collection_list::add_memrange): Add gdbarch
9+ parameter.
10+
111 2016-11-16 Kevin Buettner <kevinb@redhat.com>
212
313 * frame.c (get_prev_frame): Stash frame id for current frame
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -906,15 +906,12 @@ collection_list::add_register (unsigned int regno)
906906 /* Add a memrange to a collection list. */
907907
908908 void
909-collection_list::add_memrange (int type, bfd_signed_vma base,
909+collection_list::add_memrange (struct gdbarch *gdbarch,
910+ int type, bfd_signed_vma base,
910911 unsigned long len)
911912 {
912913 if (info_verbose)
913- {
914- printf_filtered ("(%d,", type);
915- printf_vma (base);
916- printf_filtered (",%ld)\n", len);
917- }
914+ printf_filtered ("(%d,%s,%ld)\n", type, paddress (gdbarch, base), len);
918915
919916 /* type: memrange_absolute == memory, other n == basereg */
920917 /* base: addr if memory, offset if reg relative. */
@@ -955,19 +952,16 @@ collection_list::collect_symbol (struct symbol *sym,
955952 offset = SYMBOL_VALUE_ADDRESS (sym);
956953 if (info_verbose)
957954 {
958- char tmp[40];
959-
960- sprintf_vma (tmp, offset);
961955 printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
962956 SYMBOL_PRINT_NAME (sym), len,
963- tmp /* address */);
957+ paddress (gdbarch, offset));
964958 }
965959 /* A struct may be a C++ class with static fields, go to general
966960 expression handling. */
967961 if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
968962 treat_as_expr = 1;
969963 else
970- add_memrange (memrange_absolute, offset, len);
964+ add_memrange (gdbarch, memrange_absolute, offset, len);
971965 break;
972966 case LOC_REGISTER:
973967 reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
@@ -991,36 +985,36 @@ collection_list::collect_symbol (struct symbol *sym,
991985 offset = frame_offset + SYMBOL_VALUE (sym);
992986 if (info_verbose)
993987 {
994- printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
995- SYMBOL_PRINT_NAME (sym), len);
996- printf_vma (offset);
997- printf_filtered (" from frame ptr reg %d\n", reg);
988+ printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
989+ " from frame ptr reg %d\n",
990+ SYMBOL_PRINT_NAME (sym), len,
991+ paddress (gdbarch, offset), reg);
998992 }
999- add_memrange (reg, offset, len);
993+ add_memrange (gdbarch, reg, offset, len);
1000994 break;
1001995 case LOC_REGPARM_ADDR:
1002996 reg = SYMBOL_VALUE (sym);
1003997 offset = 0;
1004998 if (info_verbose)
1005999 {
1006- printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset ",
1007- SYMBOL_PRINT_NAME (sym), len);
1008- printf_vma (offset);
1009- printf_filtered (" from reg %d\n", reg);
1000+ printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset %s"
1001+ " from reg %d\n",
1002+ SYMBOL_PRINT_NAME (sym), len,
1003+ paddress (gdbarch, offset), reg);
10101004 }
1011- add_memrange (reg, offset, len);
1005+ add_memrange (gdbarch, reg, offset, len);
10121006 break;
10131007 case LOC_LOCAL:
10141008 reg = frame_regno;
10151009 offset = frame_offset + SYMBOL_VALUE (sym);
10161010 if (info_verbose)
10171011 {
1018- printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
1019- SYMBOL_PRINT_NAME (sym), len);
1020- printf_vma (offset);
1021- printf_filtered (" from frame ptr reg %d\n", reg);
1012+ printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
1013+ " from frame ptr reg %d\n",
1014+ SYMBOL_PRINT_NAME (sym), len,
1015+ paddress (gdbarch, offset), reg);
10221016 }
1023- add_memrange (reg, offset, len);
1017+ add_memrange (gdbarch, reg, offset, len);
10241018 break;
10251019
10261020 case LOC_UNRESOLVED:
@@ -1186,7 +1180,6 @@ char **
11861180 collection_list::stringify ()
11871181 {
11881182 char temp_buf[2048];
1189- char tmp2[40];
11901183 int count;
11911184 int ndx = 0;
11921185 char *(*str_list)[];
@@ -1233,12 +1226,12 @@ collection_list::stringify ()
12331226 for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
12341227 {
12351228 QUIT; /* Allow user to bail out with ^C. */
1236- sprintf_vma (tmp2, m_memranges[i].start);
12371229 if (info_verbose)
12381230 {
12391231 printf_filtered ("(%d, %s, %ld)\n",
12401232 m_memranges[i].type,
1241- tmp2,
1233+ paddress (target_gdbarch (),
1234+ m_memranges[i].start),
12421235 (long) (m_memranges[i].end
12431236 - m_memranges[i].start));
12441237 }
@@ -1259,9 +1252,11 @@ collection_list::stringify ()
12591252 "FFFFFFFF" (or more, depending on sizeof (unsigned)).
12601253 Special-case it. */
12611254 if (m_memranges[i].type == memrange_absolute)
1262- sprintf (end, "M-1,%s,%lX", tmp2, (long) length);
1255+ sprintf (end, "M-1,%s,%lX", phex_nz (m_memranges[i].start, 0),
1256+ (long) length);
12631257 else
1264- sprintf (end, "M%X,%s,%lX", m_memranges[i].type, tmp2, (long) length);
1258+ sprintf (end, "M%X,%s,%lX", m_memranges[i].type,
1259+ phex_nz (m_memranges[i].start, 0), (long) length);
12651260 }
12661261
12671262 count += strlen (end);
@@ -1454,7 +1449,8 @@ encode_actions_1 (struct command_line *action,
14541449 addr = value_address (tempval);
14551450 /* Initialize the TYPE_LENGTH if it is a typedef. */
14561451 check_typedef (exp->elts[1].type);
1457- collect->add_memrange (memrange_absolute, addr,
1452+ collect->add_memrange (target_gdbarch (),
1453+ memrange_absolute, addr,
14581454 TYPE_LENGTH (exp->elts[1].type));
14591455 collect->append_exp (exp.get ());
14601456 break;
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -252,7 +252,8 @@ public:
252252 void add_aexpr (agent_expr_up aexpr);
253253
254254 void add_register (unsigned int regno);
255- void add_memrange (int type, bfd_signed_vma base,
255+ void add_memrange (struct gdbarch *gdbarch,
256+ int type, bfd_signed_vma base,
256257 unsigned long len);
257258 void collect_symbol (struct symbol *sym,
258259 struct gdbarch *gdbarch,