From patchwork Sat Dec 15 19:36:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svante Signell X-Patchwork-Id: 30681 Received: (qmail 104911 invoked by alias); 15 Dec 2018 19:36:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 104750 invoked by uid 89); 15 Dec 2018 19:36:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.2 required=5.0 tests=BAYES_50, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=Stop, value_type, We'll, UD:target.c X-HELO: mail-lj1-f196.google.com Received: from mail-lj1-f196.google.com (HELO mail-lj1-f196.google.com) (209.85.208.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Dec 2018 19:36:17 +0000 Received: by mail-lj1-f196.google.com with SMTP id l15-v6so7687996lja.9 for ; Sat, 15 Dec 2018 11:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:reply-to:to:date:organization:user-agent :mime-version; bh=o3zxQ192IZMhbaNOotxWdKEJZ24RGKsx5PtX9jnuylA=; b=KatLKjL2Bft7/FEysyiOU0kORtZ1Sw+xOIINc3DG1/KMZ7T9WMbQKYVM4+rdqRnXWV fbYbX/N7NmA5KhXlSRgfCrHYip49SUpqb8MExk4cPeXKfkCfuDJ0CuKFgxAN0hW32j1J KF4wKiFlIT2E1lWRw/IcWUVzwG5tqhDZLDfu6NWpfPpFD1+5eiERDTd5cEgJdzCuoNuE Rc0aR8BUQUscCBhhNxuEr7Cq/Y57XKZOzL/As8gSuMomE4lbEMcvZZO/32hxtu+GXMkz pa3iwM15WmA8kDLet+DOiImJ25SI8x+YMuid1sGeYXmklrZuPuHpOMQWmjZARU9Ivfmk o1QA== Return-Path: Received: from G3620.lan (178-78-231-178.customers.ownit.se. [178.78.231.178]) by smtp.gmail.com with ESMTPSA id f20-v6sm1493061ljk.33.2018.12.15.11.36.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Dec 2018 11:36:13 -0800 (PST) Message-ID: Subject: [PATCH] Please define thread_info as struct thread_info (and other stuff) From: Svante Signell Reply-To: svante.signell@gmail.com To: gdb-patches@sourceware.org Date: Sat, 15 Dec 2018 20:36:33 +0100 User-Agent: Evolution 3.30.0-1 Mime-Version: 1.0 Hello, When building gdb version 8.2 on GNU/Hurd several problems arise that need to be solved. One problem is that most files in gdb/ have sloppy definitions of struct thread_info, causing a build stop fore every occurrence. They are excluding the struct part, making the build (and port) on Hurd very cumbersome. Can you please fix all bad references to thread_info upstream? I don't really understand how gcc can let these errors pass on GNU/Linux. Attached are a lot of patches and files fixing these problems, 61 in total. A test build of Debian version gdb-8.2-1 on GNU/Linux with the attached patches (and patched files) applied works fine! Furthermore the script gdbarch.sh needs patching and the resulting files gdbarch.{c,h} are used in the Linux build. They are not included here due to size constraints. The generated file target-delegates.c was also used after patching target.h and generating it with: make-target-delegates target.h > target-delegates.c. Not included here either, also due to size constraints. Attached are also four old patches needed to build the 8.1 version of gdb: gdb_configure.nat.patch gdb-PATH_MAX.patch gnu-nat.c.patch struct-thread_info.patch and a very old Debian PATH_MAX patch: solve_PATH_MAX_issue.patch. Includes is also the original and new Debian 8.2-1 patch file: series. More patches will be needed for a successful port of gdb-8.2 to GNU/hurd, but please fix the above problems upstream first. Thanks! gdb-fortran-main.patch solve_PATH_MAX_issue.patch gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch python-config.patch gdb-glibc-vdso-workaround.patch load-versioned-libcc1.patch gdb_configure.nat.patch gdb-PATH_MAX.patch gnu-nat.c.patch struct-thread_info.patch gdb_gdbarch.sh.patch gdb_regcache.h.patch gdb_dummy-frame.h.patch #gdb_gdbarch.h.patch gdb_breakpoint.h.patch gdb_target.h.patch gdb_gnu-nat.h.patch gdb_gnu-nat.c.patch gdb_ada-lang.h.patch gdb_mi_mi-cmd-var.c.patch gdb_mi_mi-interp.c.patch gdb_mi_mi-main.c.patch gdb_python_python-internal.h.patch gdb_python_py-inferior.c.patch gdb_python_py-record.h.patch gdb_python_py-record.c.patch gdb_python_py-record-btrace.c.patch gdb_python_py-threadevent.c.patch gdb_elfread.c.patch gdb_ada-tasks.c.patch gdb_inline-frame.h.patch gdb_breakpoint.c.patch gdb_btrace.c.patch gdb_corelow.c.patch gdb_dummy-frame.c.patch gdb_frame.c.patch gdb_infcall.c.patch gdb_infcmd.c.patch gdb_inferior.c.patch gdb_infrun.c.patch gdb_inline-frame.c.patch gdb_record-btrace.c.patch gdb_regcache.c.patch gdb_remote.c.patch gdb_target.c.patch gdb_thread.c.patch gdb_top.c.patch gdb_varobj.c.patch gdb_compile_compile-object-load.c.patch gdb_inflow.c.patch gdb_aarch64-linux-tdep.c.patch gdb_arm-linux-tdep.c.patch gdb_amd64-linux-tdep.c.patch gdb_i386-linux-tdep.c.patch gdb_mips-linux-tdep.c.patch gdb_ppc-linux-tdep.c.patch gdb_ravenscar-thread.c.patch gdb_s390-linux-tdep.c.patch gdb_sparc64-linux-tdep.c.patch gdb_sparc-linux-tdep.c.patch gdb_i386-gnu-nat.c.patch gdb-fortran-main.patch solve_PATH_MAX_issue.patch gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch python-config.patch gdb-glibc-vdso-workaround.patch load-versioned-libcc1.patch gdb_configure.nat.patch gdb-PATH_MAX.patch gnu-nat.c.patch struct-thread_info.patch Index: gdb/gdb/thread.c =================================================================== --- gdb.orig/gdb/thread.c +++ gdb/gdb/thread.c @@ -68,21 +68,21 @@ static int thread_alive (struct thread_i class scoped_inc_dec_ref { public: - explicit scoped_inc_dec_ref (const std::vector &thrds) + explicit scoped_inc_dec_ref (const std::vector &thrds) : m_thrds (thrds) { - for (thread_info *thr : m_thrds) + for (struct thread_info *thr : m_thrds) thr->incref (); } ~scoped_inc_dec_ref () { - for (thread_info *thr : m_thrds) + for (struct thread_info *thr : m_thrds) thr->decref (); } private: - const std::vector &m_thrds; + const std::vector &m_thrds; }; @@ -199,7 +199,7 @@ clear_thread_inferior_resources (struct /* Set the TP's state as exited. */ static void -set_thread_exited (thread_info *tp, int silent) +set_thread_exited (struct thread_info *tp, int silent) { /* Dead threads don't need to step-over. Remove from queue. */ if (tp->step_over_next != NULL) @@ -242,7 +242,7 @@ init_thread_list (void) static struct thread_info * new_thread (struct inferior *inf, ptid_t ptid) { - thread_info *tp = new thread_info (inf, ptid); + struct thread_info *tp = new struct thread_info (inf, ptid); if (thread_list == NULL) thread_list = tp; @@ -1567,7 +1567,7 @@ static bool tp_array_compar_ascending; order is determined by TP_ARRAY_COMPAR_ASCENDING. */ static bool -tp_array_compar (const thread_info *a, const thread_info *b) +tp_array_compar (const struct thread_info *a, const struct thread_info *b) { if (a->inf->num != b->inf->num) { @@ -1615,11 +1615,11 @@ thread_apply_all_command (const char *cm thread, in case the command is one that wipes threads. E.g., detach, kill, disconnect, etc., or even normally continuing over an inferior or thread exit. */ - std::vector thr_list_cpy; + std::vector thr_list_cpy; thr_list_cpy.reserve (tc); { - thread_info *tp; + struct thread_info *tp; ALL_NON_EXITED_THREADS (tp) { @@ -1637,7 +1637,7 @@ thread_apply_all_command (const char *cm scoped_restore_current_thread restore_thread; - for (thread_info *thr : thr_list_cpy) + for (struct thread_info *thr : thr_list_cpy) if (thread_alive (thr)) { switch_to_thread (thr); @@ -1868,7 +1868,7 @@ show_print_thread_events (struct ui_file /* See gdbthread.h. */ void -thread_select (const char *tidstr, thread_info *tp) +thread_select (const char *tidstr, struct thread_info *tp) { if (!thread_alive (tp)) error (_("Thread ID %s has terminated."), tidstr); Index: gdb/gdb/breakpoint.c =================================================================== --- gdb.orig/gdb/breakpoint.c +++ gdb/gdb/breakpoint.c @@ -12771,7 +12771,7 @@ momentary_bkpt_print_mention (struct bre longjmp_breakpoint::~longjmp_breakpoint () { - thread_info *tp = find_thread_global_id (this->thread); + struct thread_info *tp = find_thread_global_id (this->thread); if (tp != NULL) tp->initiating_frame = null_frame_id; Index: gdb/gdb/infcmd.c =================================================================== --- gdb.orig/gdb/infcmd.c +++ gdb/gdb/infcmd.c @@ -663,7 +663,7 @@ run_command_1 (const char *args, int fro /* Queue a pending event so that the program stops immediately. */ if (run_how == RUN_STOP_AT_FIRST_INSN) { - thread_info *thr = inferior_thread (); + struct thread_info *thr = inferior_thread (); thr->suspend.waitstatus_pending_p = 1; thr->suspend.waitstatus.kind = TARGET_WAITKIND_STOPPED; thr->suspend.waitstatus.value.sig = GDB_SIGNAL_0; @@ -913,7 +913,7 @@ set_step_frame (void) set_step_info (frame, sal); CORE_ADDR pc = get_frame_pc (frame); - thread_info *tp = inferior_thread (); + struct thread_info *tp = inferior_thread (); tp->control.step_start_function = find_pc_function (pc); } Index: gdb/gdb/progspace-and-thread.c =================================================================== --- gdb.orig/gdb/progspace-and-thread.c +++ gdb/gdb/progspace-and-thread.c @@ -28,7 +28,7 @@ switch_to_program_space_and_thread (prog if (inf != NULL && inf->pid != 0) { - thread_info *tp = any_live_thread_of_inferior (inf); + struct thread_info *tp = any_live_thread_of_inferior (inf); if (tp != NULL) { Index: gdb/gdb/remote.c =================================================================== --- gdb.orig/gdb/remote.c +++ gdb/gdb/remote.c @@ -2373,7 +2373,7 @@ remote_target::remote_add_inferior (int return inf; } -static remote_thread_info *get_remote_thread_info (thread_info *thread); +static remote_thread_info *get_remote_thread_info (struct thread_info *thread); static remote_thread_info *get_remote_thread_info (ptid_t ptid); /* Add thread PTID to GDB's thread list. Tag it as executing/running @@ -2498,7 +2498,7 @@ remote_target::remote_notice_new_inferio /* Return THREAD's private thread data, creating it if necessary. */ static remote_thread_info * -get_remote_thread_info (thread_info *thread) +get_remote_thread_info (struct thread_info *thread) { gdb_assert (thread != NULL); @@ -4315,7 +4315,7 @@ remote_target::add_current_inferior_and_ /* Add the main thread and switch to it. Don't try reading registers yet, since we haven't fetched the target description yet. */ - thread_info *tp = add_thread_silent (curr_ptid); + struct thread_info *tp = add_thread_silent (curr_ptid); switch_to_thread_no_regs (tp); } Index: gdb/gdb/linux-tdep.c =================================================================== --- gdb.orig/gdb/linux-tdep.c +++ gdb/gdb/linux-tdep.c @@ -1652,7 +1652,7 @@ linux_collect_thread_registers (const st buffer. */ static gdb::byte_vector -linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch) +linux_get_siginfo_data (struct thread_info *thread, struct gdbarch *gdbarch) { struct type *siginfo_type; LONGEST bytes_read; Index: gdb/gdb/mi/mi-main.c =================================================================== --- gdb.orig/gdb/mi/mi-main.c +++ gdb/gdb/mi/mi-main.c @@ -554,7 +554,7 @@ mi_cmd_thread_select (const char *comman error (_("-thread-select: USAGE: threadnum.")); int num = value_as_long (parse_and_eval (argv[0])); - thread_info *thr = find_thread_global_id (num); + struct thread_info *thr = find_thread_global_id (num); if (thr == NULL) error (_("Thread ID %d not known."), num); Index: gdb/gdb/python/py-record-btrace.c =================================================================== --- gdb.orig/gdb/python/py-record-btrace.c +++ gdb/gdb/python/py-record-btrace.c @@ -72,7 +72,7 @@ btrace_insn_from_recpy_insn (const PyObj { const btrace_insn *insn; const recpy_element_object *obj; - thread_info *tinfo; + struct thread_info *tinfo; btrace_insn_iterator iter; if (Py_TYPE (pyobject) != &recpy_insn_type) @@ -115,7 +115,7 @@ btrace_func_from_recpy_func (const PyObj { const btrace_function *func; const recpy_element_object *obj; - thread_info *tinfo; + struct thread_info *tinfo; btrace_call_iterator iter; if (Py_TYPE (pyobject) != &recpy_func_type) @@ -153,7 +153,7 @@ btrace_func_from_recpy_func (const PyObj gdb.RecordInstruction or gdb.RecordGap object for it accordingly. */ static PyObject * -btpy_insn_or_gap_new (thread_info *tinfo, Py_ssize_t number) +btpy_insn_or_gap_new (struct thread_info *tinfo, Py_ssize_t number) { btrace_insn_iterator iter; int err_code; @@ -339,7 +339,7 @@ PyObject * recpy_bt_func_level (PyObject *self, void *closure) { const btrace_function * const func = btrace_func_from_recpy_func (self); - thread_info *tinfo; + struct thread_info *tinfo; if (func == NULL) return NULL;