|
|
689258 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
689258 |
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
689258 |
Date: Thu, 9 Aug 2018 17:17:46 +0200
|
|
|
689258 |
Subject: gdb-rhbz1187581-power8-regs-5of7.patch
|
|
|
689258 |
|
|
|
689258 |
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
|
|
|
689258 |
|
|
|
689258 |
commit a04b9d62a234923826e431a209d396a628661548
|
|
|
689258 |
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
|
|
689258 |
Date: Mon Aug 6 16:24:55 2018 -0300
|
|
|
689258 |
|
|
|
689258 |
Variable size for regs mask in collection list
|
|
|
689258 |
|
|
|
689258 |
This patch changes collection_list to allow larger register masks.
|
|
|
689258 |
|
|
|
689258 |
The mask is changed from an array to a vector and is initialized to
|
|
|
689258 |
hold the maximum possible remote register number. The stringify
|
|
|
689258 |
method is updated to resize temp_buf if needed.
|
|
|
689258 |
|
|
|
689258 |
gdb/ChangeLog:
|
|
|
689258 |
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
|
|
689258 |
|
|
|
689258 |
* tracepoint.h (collection_list) <m_regs_mask>: Change type to
|
|
|
689258 |
std::vector<unsigned char>.
|
|
|
689258 |
* tracepoint.c (collection_list::collection_list): Remove
|
|
|
689258 |
m_regs_mask initializer from initializer list. Resize
|
|
|
689258 |
m_regs_mask using the largest remote register number.
|
|
|
689258 |
(collection_list::add_remote_register): Remove size check on
|
|
|
689258 |
m_regs_mask. Use at to access element.
|
|
|
689258 |
(collection_list::stringify): Change type of temp_buf to
|
|
|
689258 |
gdb::char_vector. Update uses of temp_buf. Resize if needed to
|
|
|
689258 |
stringify the register mask. Use pack_hex_byte for the register
|
|
|
689258 |
mask.
|
|
|
689258 |
|
|
|
689258 |
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
|
|
689258 |
+
|
|
|
689258 |
+ * tracepoint.h (collection_list) <m_regs_mask>: Change type to
|
|
|
689258 |
+ std::vector<unsigned char>.
|
|
|
689258 |
+ * tracepoint.c (collection_list::collection_list): Remove
|
|
|
689258 |
+ m_regs_mask initializer from initializer list. Resize
|
|
|
689258 |
+ m_regs_mask using the largest remote register number.
|
|
|
689258 |
+ (collection_list::add_remote_register): Remove size check on
|
|
|
689258 |
+ m_regs_mask. Use at to access element.
|
|
|
689258 |
+ (collection_list::stringify): Change type of temp_buf to
|
|
|
689258 |
+ gdb::char_vector. Update uses of temp_buf. Resize if needed to
|
|
|
689258 |
+ stringify the register mask. Use pack_hex_byte for the register
|
|
|
689258 |
+ mask.
|
|
|
689258 |
+
|
|
|
689258 |
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
|
|
|
689258 |
|
|
|
689258 |
* tracepoint.h (class collection_list) <add_register>: Remove.
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
|
|
|
689258 |
--- a/gdb/tracepoint.c
|
|
|
689258 |
+++ b/gdb/tracepoint.c
|
|
|
689258 |
@@ -822,10 +822,8 @@ collection_list::add_remote_register (unsigned int regno)
|
|
|
689258 |
{
|
|
|
689258 |
if (info_verbose)
|
|
|
689258 |
printf_filtered ("collect register %d\n", regno);
|
|
|
689258 |
- if (regno >= (8 * sizeof (m_regs_mask)))
|
|
|
689258 |
- error (_("Internal: register number %d too large for tracepoint"),
|
|
|
689258 |
- regno);
|
|
|
689258 |
- m_regs_mask[regno / 8] |= 1 << (regno % 8);
|
|
|
689258 |
+
|
|
|
689258 |
+ m_regs_mask.at (regno / 8) |= 1 << (regno % 8);
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
/* Add all the registers from the mask in AEXPR to the mask in the
|
|
|
689258 |
@@ -1136,9 +1134,20 @@ collection_list::add_static_trace_data ()
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
collection_list::collection_list ()
|
|
|
689258 |
- : m_regs_mask (),
|
|
|
689258 |
- m_strace_data (false)
|
|
|
689258 |
+ : m_strace_data (false)
|
|
|
689258 |
{
|
|
|
689258 |
+ int max_remote_regno = 0;
|
|
|
689258 |
+ for (int i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
|
|
|
689258 |
+ {
|
|
|
689258 |
+ int remote_regno = (gdbarch_remote_register_number
|
|
|
689258 |
+ (target_gdbarch (), i));
|
|
|
689258 |
+
|
|
|
689258 |
+ if (remote_regno >= 0 && remote_regno > max_remote_regno)
|
|
|
689258 |
+ max_remote_regno = remote_regno;
|
|
|
689258 |
+ }
|
|
|
689258 |
+
|
|
|
689258 |
+ m_regs_mask.resize ((max_remote_regno / 8) + 1);
|
|
|
689258 |
+
|
|
|
689258 |
m_memranges.reserve (128);
|
|
|
689258 |
m_aexprs.reserve (128);
|
|
|
689258 |
}
|
|
|
689258 |
@@ -1148,7 +1157,8 @@ collection_list::collection_list ()
|
|
|
689258 |
std::vector<std::string>
|
|
|
689258 |
collection_list::stringify ()
|
|
|
689258 |
{
|
|
|
689258 |
- char temp_buf[2048];
|
|
|
689258 |
+ gdb::char_vector temp_buf (2048);
|
|
|
689258 |
+
|
|
|
689258 |
int count;
|
|
|
689258 |
char *end;
|
|
|
689258 |
long i;
|
|
|
689258 |
@@ -1158,35 +1168,45 @@ collection_list::stringify ()
|
|
|
689258 |
{
|
|
|
689258 |
if (info_verbose)
|
|
|
689258 |
printf_filtered ("\nCollecting static trace data\n");
|
|
|
689258 |
- end = temp_buf;
|
|
|
689258 |
+ end = temp_buf.data ();
|
|
|
689258 |
*end++ = 'L';
|
|
|
689258 |
- str_list.emplace_back (temp_buf, end - temp_buf);
|
|
|
689258 |
+ str_list.emplace_back (temp_buf.data (), end - temp_buf.data ());
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
- for (i = sizeof (m_regs_mask) - 1; i > 0; i--)
|
|
|
689258 |
+ for (i = m_regs_mask.size () - 1; i > 0; i--)
|
|
|
689258 |
if (m_regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */
|
|
|
689258 |
break;
|
|
|
689258 |
if (m_regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */
|
|
|
689258 |
{
|
|
|
689258 |
if (info_verbose)
|
|
|
689258 |
printf_filtered ("\nCollecting registers (mask): 0x");
|
|
|
689258 |
- end = temp_buf;
|
|
|
689258 |
+
|
|
|
689258 |
+ /* One char for 'R', one for the null terminator and two per
|
|
|
689258 |
+ mask byte. */
|
|
|
689258 |
+ std::size_t new_size = (i + 1) * 2 + 2;
|
|
|
689258 |
+ if (new_size > temp_buf.size ())
|
|
|
689258 |
+ temp_buf.resize (new_size);
|
|
|
689258 |
+
|
|
|
689258 |
+ end = temp_buf.data ();
|
|
|
689258 |
*end++ = 'R';
|
|
|
689258 |
for (; i >= 0; i--)
|
|
|
689258 |
{
|
|
|
689258 |
QUIT; /* Allow user to bail out with ^C. */
|
|
|
689258 |
if (info_verbose)
|
|
|
689258 |
printf_filtered ("%02X", m_regs_mask[i]);
|
|
|
689258 |
- sprintf (end, "%02X", m_regs_mask[i]);
|
|
|
689258 |
- end += 2;
|
|
|
689258 |
+
|
|
|
689258 |
+ end = pack_hex_byte (end, m_regs_mask[i]);
|
|
|
689258 |
}
|
|
|
689258 |
- str_list.emplace_back (temp_buf);
|
|
|
689258 |
+ *end = '\0';
|
|
|
689258 |
+
|
|
|
689258 |
+ str_list.emplace_back (temp_buf.data ());
|
|
|
689258 |
}
|
|
|
689258 |
if (info_verbose)
|
|
|
689258 |
printf_filtered ("\n");
|
|
|
689258 |
if (!m_memranges.empty () && info_verbose)
|
|
|
689258 |
printf_filtered ("Collecting memranges: \n");
|
|
|
689258 |
- for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
|
|
|
689258 |
+ for (i = 0, count = 0, end = temp_buf.data ();
|
|
|
689258 |
+ i < m_memranges.size (); i++)
|
|
|
689258 |
{
|
|
|
689258 |
QUIT; /* Allow user to bail out with ^C. */
|
|
|
689258 |
if (info_verbose)
|
|
|
689258 |
@@ -1200,9 +1220,9 @@ collection_list::stringify ()
|
|
|
689258 |
}
|
|
|
689258 |
if (count + 27 > MAX_AGENT_EXPR_LEN)
|
|
|
689258 |
{
|
|
|
689258 |
- str_list.emplace_back (temp_buf, count);
|
|
|
689258 |
+ str_list.emplace_back (temp_buf.data (), count);
|
|
|
689258 |
count = 0;
|
|
|
689258 |
- end = temp_buf;
|
|
|
689258 |
+ end = temp_buf.data ();
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
{
|
|
|
689258 |
@@ -1222,7 +1242,7 @@ collection_list::stringify ()
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
count += strlen (end);
|
|
|
689258 |
- end = temp_buf + count;
|
|
|
689258 |
+ end = temp_buf.data () + count;
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
for (i = 0; i < m_aexprs.size (); i++)
|
|
|
689258 |
@@ -1230,9 +1250,9 @@ collection_list::stringify ()
|
|
|
689258 |
QUIT; /* Allow user to bail out with ^C. */
|
|
|
689258 |
if ((count + 10 + 2 * m_aexprs[i]->len) > MAX_AGENT_EXPR_LEN)
|
|
|
689258 |
{
|
|
|
689258 |
- str_list.emplace_back (temp_buf, count);
|
|
|
689258 |
+ str_list.emplace_back (temp_buf.data (), count);
|
|
|
689258 |
count = 0;
|
|
|
689258 |
- end = temp_buf;
|
|
|
689258 |
+ end = temp_buf.data ();
|
|
|
689258 |
}
|
|
|
689258 |
sprintf (end, "X%08X,", m_aexprs[i]->len);
|
|
|
689258 |
end += 10; /* 'X' + 8 hex digits + ',' */
|
|
|
689258 |
@@ -1244,9 +1264,9 @@ collection_list::stringify ()
|
|
|
689258 |
|
|
|
689258 |
if (count != 0)
|
|
|
689258 |
{
|
|
|
689258 |
- str_list.emplace_back (temp_buf, count);
|
|
|
689258 |
+ str_list.emplace_back (temp_buf.data (), count);
|
|
|
689258 |
count = 0;
|
|
|
689258 |
- end = temp_buf;
|
|
|
689258 |
+ end = temp_buf.data ();
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
return str_list;
|
|
|
689258 |
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
|
|
|
689258 |
--- a/gdb/tracepoint.h
|
|
|
689258 |
+++ b/gdb/tracepoint.h
|
|
|
689258 |
@@ -293,8 +293,9 @@ public:
|
|
|
689258 |
{ return m_computed; }
|
|
|
689258 |
|
|
|
689258 |
private:
|
|
|
689258 |
- /* room for up to 256 regs */
|
|
|
689258 |
- unsigned char m_regs_mask[32];
|
|
|
689258 |
+ /* We need the allocator zero-initialize the mask, so we don't use
|
|
|
689258 |
+ gdb::byte_vector. */
|
|
|
689258 |
+ std::vector<unsigned char> m_regs_mask;
|
|
|
689258 |
|
|
|
689258 |
std::vector<memrange> m_memranges;
|
|
|
689258 |
|