GNU Binutils with patches for OS216
修订版 | 19f1935d91bfabbe4176ffdaca95bc789b593153 (tree) |
---|---|
时间 | 2016-11-17 09:23:17 |
作者 | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
gdb/tracepoint.c: Don't use printf_vma
I noticed that bfd's printf_vma prints to stdout directly:
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.
@@ -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 | + | |
1 | 11 | 2016-11-16 Kevin Buettner <kevinb@redhat.com> |
2 | 12 | |
3 | 13 | * frame.c (get_prev_frame): Stash frame id for current frame |
@@ -906,15 +906,12 @@ collection_list::add_register (unsigned int regno) | ||
906 | 906 | /* Add a memrange to a collection list. */ |
907 | 907 | |
908 | 908 | 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, | |
910 | 911 | unsigned long len) |
911 | 912 | { |
912 | 913 | 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); | |
918 | 915 | |
919 | 916 | /* type: memrange_absolute == memory, other n == basereg */ |
920 | 917 | /* base: addr if memory, offset if reg relative. */ |
@@ -955,19 +952,16 @@ collection_list::collect_symbol (struct symbol *sym, | ||
955 | 952 | offset = SYMBOL_VALUE_ADDRESS (sym); |
956 | 953 | if (info_verbose) |
957 | 954 | { |
958 | - char tmp[40]; | |
959 | - | |
960 | - sprintf_vma (tmp, offset); | |
961 | 955 | printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n", |
962 | 956 | SYMBOL_PRINT_NAME (sym), len, |
963 | - tmp /* address */); | |
957 | + paddress (gdbarch, offset)); | |
964 | 958 | } |
965 | 959 | /* A struct may be a C++ class with static fields, go to general |
966 | 960 | expression handling. */ |
967 | 961 | if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT) |
968 | 962 | treat_as_expr = 1; |
969 | 963 | else |
970 | - add_memrange (memrange_absolute, offset, len); | |
964 | + add_memrange (gdbarch, memrange_absolute, offset, len); | |
971 | 965 | break; |
972 | 966 | case LOC_REGISTER: |
973 | 967 | reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch); |
@@ -991,36 +985,36 @@ collection_list::collect_symbol (struct symbol *sym, | ||
991 | 985 | offset = frame_offset + SYMBOL_VALUE (sym); |
992 | 986 | if (info_verbose) |
993 | 987 | { |
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); | |
998 | 992 | } |
999 | - add_memrange (reg, offset, len); | |
993 | + add_memrange (gdbarch, reg, offset, len); | |
1000 | 994 | break; |
1001 | 995 | case LOC_REGPARM_ADDR: |
1002 | 996 | reg = SYMBOL_VALUE (sym); |
1003 | 997 | offset = 0; |
1004 | 998 | if (info_verbose) |
1005 | 999 | { |
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); | |
1010 | 1004 | } |
1011 | - add_memrange (reg, offset, len); | |
1005 | + add_memrange (gdbarch, reg, offset, len); | |
1012 | 1006 | break; |
1013 | 1007 | case LOC_LOCAL: |
1014 | 1008 | reg = frame_regno; |
1015 | 1009 | offset = frame_offset + SYMBOL_VALUE (sym); |
1016 | 1010 | if (info_verbose) |
1017 | 1011 | { |
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); | |
1022 | 1016 | } |
1023 | - add_memrange (reg, offset, len); | |
1017 | + add_memrange (gdbarch, reg, offset, len); | |
1024 | 1018 | break; |
1025 | 1019 | |
1026 | 1020 | case LOC_UNRESOLVED: |
@@ -1186,7 +1180,6 @@ char ** | ||
1186 | 1180 | collection_list::stringify () |
1187 | 1181 | { |
1188 | 1182 | char temp_buf[2048]; |
1189 | - char tmp2[40]; | |
1190 | 1183 | int count; |
1191 | 1184 | int ndx = 0; |
1192 | 1185 | char *(*str_list)[]; |
@@ -1233,12 +1226,12 @@ collection_list::stringify () | ||
1233 | 1226 | for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++) |
1234 | 1227 | { |
1235 | 1228 | QUIT; /* Allow user to bail out with ^C. */ |
1236 | - sprintf_vma (tmp2, m_memranges[i].start); | |
1237 | 1229 | if (info_verbose) |
1238 | 1230 | { |
1239 | 1231 | printf_filtered ("(%d, %s, %ld)\n", |
1240 | 1232 | m_memranges[i].type, |
1241 | - tmp2, | |
1233 | + paddress (target_gdbarch (), | |
1234 | + m_memranges[i].start), | |
1242 | 1235 | (long) (m_memranges[i].end |
1243 | 1236 | - m_memranges[i].start)); |
1244 | 1237 | } |
@@ -1259,9 +1252,11 @@ collection_list::stringify () | ||
1259 | 1252 | "FFFFFFFF" (or more, depending on sizeof (unsigned)). |
1260 | 1253 | Special-case it. */ |
1261 | 1254 | 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); | |
1263 | 1257 | 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); | |
1265 | 1260 | } |
1266 | 1261 | |
1267 | 1262 | count += strlen (end); |
@@ -1454,7 +1449,8 @@ encode_actions_1 (struct command_line *action, | ||
1454 | 1449 | addr = value_address (tempval); |
1455 | 1450 | /* Initialize the TYPE_LENGTH if it is a typedef. */ |
1456 | 1451 | check_typedef (exp->elts[1].type); |
1457 | - collect->add_memrange (memrange_absolute, addr, | |
1452 | + collect->add_memrange (target_gdbarch (), | |
1453 | + memrange_absolute, addr, | |
1458 | 1454 | TYPE_LENGTH (exp->elts[1].type)); |
1459 | 1455 | collect->append_exp (exp.get ()); |
1460 | 1456 | break; |
@@ -252,7 +252,8 @@ public: | ||
252 | 252 | void add_aexpr (agent_expr_up aexpr); |
253 | 253 | |
254 | 254 | 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, | |
256 | 257 | unsigned long len); |
257 | 258 | void collect_symbol (struct symbol *sym, |
258 | 259 | struct gdbarch *gdbarch, |