public:
/* Save the current globals and switch to the given inferior and the
- inferior's program space. PTID must name a thread in INF, it is
- used as the new inferior_ptid. */
- scoped_restore_current_inferior_for_memory (inferior *inf, ptid_t ptid)
+ inferior's program space. inferior_ptid is set to point to the
+ inferior's process id (and not to any particular thread). */
+ explicit scoped_restore_current_inferior_for_memory (inferior *inf)
: m_save_ptid (&inferior_ptid)
{
set_current_inferior (inf);
set_current_program_space (inf->pspace);
- inferior_ptid = ptid;
+ inferior_ptid = ptid_t (inf->pid);
}
DISABLE_COPY_AND_ASSIGN (scoped_restore_current_inferior_for_memory);
ps_xfer_memory (const struct ps_prochandle *ph, psaddr_t addr,
gdb_byte *buf, size_t len, int write)
{
- scoped_restore_current_inferior_for_memory save_inferior (ph->thread->inf,
- ph->thread->ptid);
+ scoped_restore_current_inferior_for_memory save_inferior (ph->thread->inf);
CORE_ADDR core_addr = ps_addr_to_core_addr (addr);
/* Use this scoped-restore because we want to be able to read
memory from an unwinder. */
scoped_restore_current_inferior_for_memory restore_inferior
- (inf->inferior, any_thread_of_inferior (inf->inferior)->ptid);
+ (inf->inferior);
buffer.reset ((gdb_byte *) xmalloc (length));
still used here, just to keep the code similar to other code
in this file. */
scoped_restore_current_inferior_for_memory restore_inferior
- (inf->inferior, any_thread_of_inferior (inf->inferior)->ptid);
+ (inf->inferior);
write_memory_with_notification (addr, buffer, length);
}
still used here, just to keep the code similar to other code
in this file. */
scoped_restore_current_inferior_for_memory restore_inferior
- (inf->inferior, any_thread_of_inferior (inf->inferior)->ptid);
+ (inf->inferior);
found = target_search_memory (start_addr, length,
buffer, pattern_size,
still used, just to keep the code similar to other code in
this file. */
scoped_restore_current_inferior_for_memory restore_inferior
- (inf->inferior, any_thread_of_inferior (inf->inferior)->ptid);
+ (inf->inferior);
name = main_name ();
}
static char *search_buf;
static int search_buf_size;
+int8_t int8_global = 42;
int f2 (int a)
{
big { set python_pack_char ">" }
}
+# Test memory read operations without execution.
+
+gdb_py_test_silent_cmd "python addr = gdb.lookup_global_symbol ('int8_global').value().address" \
+ "get global variable address" 0
+gdb_test "python \
+ int8_global_mv = gdb.selected_inferior().read_memory (addr, 1); \
+ print(int.from_bytes(int8_global_mv\[0\], byteorder='little'))" \
+ "\r\n42" \
+ "read memory without execution"
+
# The following tests require execution.
if {![runto_main]} {