diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-09-29 14:24:38 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-10-10 10:44:35 -0400 |
commit | 99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee (patch) | |
tree | 7f642c989f7c7b49bd40ab5873fc12be632e6ea9 /gdb/target.c | |
parent | 72c4529c85907a5e1e04960ff1362a5a185553a0 (diff) | |
download | gdb-99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee.zip gdb-99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee.tar.gz gdb-99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee.tar.bz2 |
gdb: remove target_gdbarch
This function is just a wrapper around the current inferior's gdbarch.
I find that having that wrapper just obscures where the arch is coming
from, and that it's often used as "I don't know which arch to use so
I'll use this magical target_gdbarch function that gets me an arch" when
the arch should in fact come from something in the context (a thread,
objfile, symbol, etc). I think that removing it and inlining
`current_inferior ()->arch ()` everywhere will make it a bit clearer
where that arch comes from and will trigger people into reflecting
whether this is the right place to get the arch or not.
Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/target.c')
-rw-r--r-- | gdb/target.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/gdb/target.c b/gdb/target.c index 8cb4fa1..6853c14 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1281,7 +1281,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) { volatile CORE_ADDR addr = 0; struct target_ops *target = current_inferior ()->top_target (); - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); /* If OBJFILE is a separate debug object file, look for the original object file. */ @@ -1631,7 +1631,8 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object, if (len == 0) return TARGET_XFER_EOF; - memaddr = gdbarch_remove_non_address_bits (target_gdbarch (), memaddr); + memaddr = gdbarch_remove_non_address_bits (current_inferior ()->arch (), + memaddr); /* Fill in READBUF with breakpoint shadows, or WRITEBUF with breakpoint insns, thus hiding out from higher layers whether @@ -1803,8 +1804,9 @@ target_read_uint32 (CORE_ADDR memaddr, uint32_t *result) r = target_read_memory (memaddr, buf, sizeof buf); if (r != 0) return r; - *result = extract_unsigned_integer (buf, sizeof buf, - gdbarch_byte_order (target_gdbarch ())); + *result = extract_unsigned_integer + (buf, sizeof buf, + gdbarch_byte_order (current_inferior ()->arch ())); return 0; } @@ -1981,7 +1983,8 @@ target_read (struct target_ops *ops, || object == TARGET_OBJECT_STACK_MEMORY || object == TARGET_OBJECT_CODE_MEMORY || object == TARGET_OBJECT_RAW_MEMORY) - unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + unit_size = gdbarch_addressable_memory_unit_size + (current_inferior ()->arch ()); while (xfered_total < len) { @@ -2140,7 +2143,8 @@ read_memory_robust (struct target_ops *ops, const ULONGEST offset, const LONGEST len) { std::vector<memory_read_result> result; - int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + int unit_size + = gdbarch_addressable_memory_unit_size (current_inferior ()->arch ()); LONGEST xfered_total = 0; while (xfered_total < len) @@ -2215,7 +2219,8 @@ target_write_with_progress (struct target_ops *ops, || object == TARGET_OBJECT_STACK_MEMORY || object == TARGET_OBJECT_CODE_MEMORY || object == TARGET_OBJECT_RAW_MEMORY) - unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + unit_size = gdbarch_addressable_memory_unit_size + (current_inferior ()->arch ()); /* Give the progress callback a chance to set up. */ if (progress) @@ -2468,7 +2473,7 @@ target_pre_inferior (int from_tty) /* In some OSs, the shared library list is the same/global/shared across inferiors. If code is shared between processes, so are memory regions and features. */ - if (!gdbarch_has_global_solist (target_gdbarch ())) + if (!gdbarch_has_global_solist (current_inferior ()->arch ())) { no_shared_libraries (NULL, from_tty); @@ -2539,10 +2544,9 @@ target_detach (inferior *inf, int from_tty) ptid_t save_pid_ptid = ptid_t (inf->pid); /* As long as some to_detach implementations rely on the current_inferior - (either directly, or indirectly, like through target_gdbarch or by - reading memory), INF needs to be the current inferior. When that - requirement will become no longer true, then we can remove this - assertion. */ + (either directly, or indirectly, like through reading memory), INF needs + to be the current inferior. When that requirement will become no longer + true, then we can remove this assertion. */ gdb_assert (inf == current_inferior ()); prepare_for_detach (); @@ -3582,7 +3586,8 @@ static int default_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR addr, int len) { - return (len <= gdbarch_ptr_bit (target_gdbarch ()) / TARGET_CHAR_BIT); + gdbarch *arch = current_inferior ()->arch (); + return (len <= gdbarch_ptr_bit (arch) / TARGET_CHAR_BIT); } static int @@ -4284,7 +4289,7 @@ flash_erase_command (const char *cmd, int from_tty) { /* Used to communicate termination of flash operations to the target. */ bool found_flash_region = false; - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); std::vector<mem_region> mem_regions = target_memory_map (); |