aboutsummaryrefslogtreecommitdiff
path: root/cpu/mt.opc
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-11-24 10:39:30 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2017-11-24 10:39:31 -0500
commit089354bb0613ca1559813f0a79fbe73655113785 (patch)
treec80fccf71444a91fb1103b8d750d04fcb2e71d33 /cpu/mt.opc
parentd044bac8ce5e6737d13e7e5180f5a5641053e690 (diff)
downloadgdb-089354bb0613ca1559813f0a79fbe73655113785.zip
gdb-089354bb0613ca1559813f0a79fbe73655113785.tar.gz
gdb-089354bb0613ca1559813f0a79fbe73655113785.tar.bz2
Create private_inferior class hierarchy
There are currently multiple definitions of private_inferior, defined in remote.c and darwin-nat.h. The patch that poisons XNEW and friends for non-POD types trips on that, because private_inferior is freed in ~inferior(), where it is an opaque type. Since the compiler can't tell whether the type is POD, it gives an error. Also, we can't start using C++ features in these structures (make them non-POD) as long as there are multiple definitions with the same name. For these reasons, this patch makes a class hierarchy, with private_inferior being the abstract base class, and darwin_inferior & remote_inferior inheriting from it. Destruction is done through the virtual destructor. I stumbled on some suspicious code in the darwin implementation though. darwin_check_new_threads does an XCNEW(darwin_thread_t) when it finds a new thread, allocating a new structure for it (darwin_thread_t is a typedef for private_thread_info). It then VEC_safe_pushes it in a vector defined as DEF_VEC_O (a vector of objects). This means that the structure content gets copied in the vector. The thread_info object is created with the XCNEW'ed structure as the private thread info, while the rest of the code works with the instance in the vector. We have therefore two distinct instances of darwin_thread_t/private_thread_info for each thread. This is not really a problem in practice, because thread_info::priv is not used in the darwin code. I still find it weird and far from ideal, so I tried to fix it by changing the vector to be a vector of pointers. There should now be a single instance of the structure for each thread. The deallocation of the darwin_thread_t/private_thread_info structure is done by the thread_info destructor. I am able to build on macOS, but not really test, since the port seems a bit broken. I am not able to debug reliably on the machine I have access to, which runs macOS 10.12.6. gdb/ChangeLog: * inferior.h (private_inferior): Define structure type, add virtual pure destructor. (inferior) <priv>: Change type to unique_ptr. * inferior.c (private_inferior::~private_inferior): Provide default implementation. (inferior::~inferior): Don't free priv field. (exit_inferior_1): Likewise. * darwin-nat.h (struct darwin_exception_info): Initialize fields. (darwin_exception_info): Remove typedef. (DEF_VEC_O (darwin_thread_t)); Remove. (private_inferior): Rename to ... (darwin_private_inferior): ... this, extend private_inferior. (get_darwin_inferior): New. <threads>: Change type to std::vector of darwin_thread_t pointers. * darwin-nat.c (darwin_check_new_threads): Adjust. (find_inferior_task_it): Adjust. (darwin_find_thread); Adjust. (darwin_suspend_inferior): Adjust. (darwin_resume_inferior): Adjust. (darwin_find_new_inferior): Adjust. (darwin_decode_notify_message): Adjust. (darwin_send_reply): Adjust. (darwin_resume_inferior_threads): Adjust. (darwin_suspend_inferior_threads): Adjust. (darwin_decode_message): Adjust. (darwin_wait): Adjust. (darwin_interrupt): Adjust. (darwin_deallocate_threads): Adjust. (darwin_mourn_inferior): Adjust, don't free private data. (darwin_reply_to_all_pending_messages): Adjust. (darwin_stop_inferior): Adjust. (darwin_setup_exceptions): Adjust. (darwin_kill_inferior): Adjust. (darwin_setup_request_notification): Adjust. (darwin_attach_pid): Adjust. (darwin_init_thread_list): Adjust. (darwin_setup_fake_stop_event): Adjust. (darwin_attach): Adjust. (darwin_detach): Adjust. (darwin_xfer_partial): Adjust. (set_enable_mach_exceptions): Adjust. (darwin_pid_to_exec_file): Adjust. (darwin_get_ada_task_ptid): Adjust. * darwin-nat-info.c (get_task_from_args): Adjust. (info_mach_ports_command): Adjust. (info_mach_region_command): Adjust. (info_mach_exceptions_command): Adjust. * remote.c (private_inferior): Rename to ... (remote_private_inferior): ... this, initialize fields. (get_remote_inferior); New. (remote_commit_resume): Use get_remote_inferior. (check_pending_event_prevents_wildcard_vcont_callback): Likewise.
Diffstat (limited to 'cpu/mt.opc')
0 files changed, 0 insertions, 0 deletions