From patchwork Thu Nov 23 15:37:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rudo X-Patchwork-Id: 24469 Received: (qmail 32843 invoked by alias); 23 Nov 2017 15:38:17 -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 32807 invoked by uid 89); 23 Nov 2017 15:38:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=m31 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Nov 2017 15:38:14 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vANFc2D7100560 for ; Thu, 23 Nov 2017 10:38:12 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ee0v3gs76-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 23 Nov 2017 10:38:08 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Nov 2017 15:37:40 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 23 Nov 2017 15:37:37 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vANFbar826148952; Thu, 23 Nov 2017 15:37:36 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05C8AAE04D; Thu, 23 Nov 2017 15:30:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C5A4EAE045; Thu, 23 Nov 2017 15:30:50 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 23 Nov 2017 15:30:50 +0000 (GMT) From: Philipp Rudo To: gdb-patches@sourceware.org Cc: Andreas Arnez , Ulrich Weigand Subject: [PATCH 2/4] Clean up s390-linux-tdep.c Date: Thu, 23 Nov 2017 16:37:31 +0100 In-Reply-To: <20171123153733.31261-1-prudo@linux.vnet.ibm.com> References: <20171123153733.31261-1-prudo@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17112315-0020-0000-0000-000003CFDA48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112315-0021-0000-0000-0000426530B3 Message-Id: <20171123153733.31261-3-prudo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-23_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711230212 X-IsSubscribed: yes After moving big parts of the code to the new s390-tdep.c file s390-linux-tdep.c now contains many includes it doesn't need any more. Further more the code for record-replay is disrupted by some code that does not belong to the feature. So clean up the include list and move the code disrupting record-replay to places where it makes more sense. Also remove some superfluous newlines. gdb/ChangeLog * s390-linux-tdep.c: Reorder code. Remove unneeded includes and order alphabetically. (s390_linux_gdbarch_init): Adjust. --- gdb/s390-linux-tdep.c | 178 +++++++++++++++++++++----------------------------- 1 file changed, 76 insertions(+), 102 deletions(-) diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 9efc68554c..c27c1f4799 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -21,45 +21,24 @@ along with this program. If not, see . */ #include "defs.h" -#include "arch-utils.h" -#include "frame.h" -#include "inferior.h" -#include "infrun.h" -#include "symtab.h" -#include "target.h" -#include "gdbcore.h" -#include "gdbcmd.h" -#include "objfiles.h" -#include "regcache.h" -#include "trad-frame.h" + +#include "auxv.h" +#include "elf/common.h" #include "frame-base.h" #include "frame-unwind.h" -#include "dwarf2-frame.h" -#include "reggroups.h" -#include "regset.h" -#include "value.h" -#include "dis-asm.h" -#include "solib-svr4.h" -#include "prologue-value.h" +#include "gdbcore.h" +#include "linux-record.h" #include "linux-tdep.h" +#include "objfiles.h" +#include "record-full.h" +#include "regset.h" #include "s390-tdep.h" #include "s390-linux-tdep.h" -#include "linux-record.h" -#include "record-full.h" -#include "auxv.h" +#include "solib-svr4.h" +#include "target.h" +#include "trad-frame.h" #include "xml-syscall.h" -#include "stap-probe.h" -#include "ax.h" -#include "ax-gdb.h" -#include "user-regs.h" -#include "cli/cli-utils.h" -#include -#include "elf/common.h" -#include "elf/s390.h" -#include "elf-bfd.h" -#include - #include "features/s390-linux32.c" #include "features/s390-linux32v1.c" #include "features/s390-linux32v2.c" @@ -81,7 +60,6 @@ #define XML_SYSCALL_FILENAME_S390 "syscalls/s390-linux.xml" #define XML_SYSCALL_FILENAME_S390X "syscalls/s390x-linux.xml" - /* The "guess_tracepoint_registers" gdbarch method. */ static void @@ -351,7 +329,6 @@ s390_trad_frame_prev_register (struct frame_info *this_frame, return s390_unwind_pseudo_register (this_frame, regnum); } - /* Normal stack frames. */ struct s390_unwind_cache { @@ -447,7 +424,6 @@ s390_prologue_frame_unwind_cache (struct frame_info *this_frame, } } - /* OK, we've found valid prologue data. */ size = -sp->k; @@ -672,7 +648,6 @@ static const struct frame_unwind s390_frame_unwind = { default_frame_sniffer }; - /* Code stubs and their stack frames. For things like PLTs and NULL function calls (where there is no true frame and the return address is in the RETADDR register). */ @@ -755,7 +730,6 @@ static const struct frame_unwind s390_stub_frame_unwind = { s390_stub_frame_sniffer }; - /* Signal trampoline stack frames. */ struct s390_sigtramp_unwind_cache { @@ -920,6 +894,33 @@ static const struct frame_unwind s390_sigtramp_frame_unwind = { s390_sigtramp_frame_sniffer }; +/* Frame base handling. */ + +static CORE_ADDR +s390_frame_base_address (struct frame_info *this_frame, void **this_cache) +{ + struct s390_unwind_cache *info + = s390_frame_unwind_cache (this_frame, this_cache); + return info->frame_base; +} + +static CORE_ADDR +s390_local_base_address (struct frame_info *this_frame, void **this_cache) +{ + struct s390_unwind_cache *info + = s390_frame_unwind_cache (this_frame, this_cache); + return info->local_base; +} + +static const struct frame_base s390_frame_base = { + &s390_frame_unwind, + s390_frame_base_address, + s390_local_base_address, + s390_local_base_address +}; + +/* Syscall handling. */ + /* Retrieve the syscall number at a ptrace syscall-stop. Return -1 upon error. */ @@ -1246,67 +1247,6 @@ s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, return 0; } -/* Frame base handling. */ - -static CORE_ADDR -s390_frame_base_address (struct frame_info *this_frame, void **this_cache) -{ - struct s390_unwind_cache *info - = s390_frame_unwind_cache (this_frame, this_cache); - return info->frame_base; -} - -static CORE_ADDR -s390_local_base_address (struct frame_info *this_frame, void **this_cache) -{ - struct s390_unwind_cache *info - = s390_frame_unwind_cache (this_frame, this_cache); - return info->local_base; -} - -static const struct frame_base s390_frame_base = { - &s390_frame_unwind, - s390_frame_base_address, - s390_local_base_address, - s390_local_base_address -}; - - - -/* Implement gdbarch_gcc_target_options. GCC does not know "-m32" or - "-mcmodel=large". */ - -static char * -s390_gcc_target_options (struct gdbarch *gdbarch) -{ - return xstrdup (gdbarch_ptr_bit (gdbarch) == 64 ? "-m64" : "-m31"); -} - -/* Implement gdbarch_gnu_triplet_regexp. Target triplets are "s390-*" - for 31-bit and "s390x-*" for 64-bit, while the BFD arch name is - always "s390". Note that an s390x compiler supports "-m31" as - well. */ - -static const char * -s390_gnu_triplet_regexp (struct gdbarch *gdbarch) -{ - return "s390x?"; -} - -/* Implementation of `gdbarch_stap_is_single_operand', as defined in - gdbarch.h. */ - -static int -s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) -{ - return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement - or indirection. */ - || *s == '%' /* Register access. */ - || isdigit (*s)); /* Literal number. */ -} - -/* Process record and replay helpers. */ - /* Takes the intermediate sum of address calculations and masks off upper bits according to current addressing mode. */ @@ -5478,6 +5418,39 @@ s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep, record_tdep->ioctl_FIOQSIZE = 0x545e; } +/* Miscellaneous. */ + +/* Implement gdbarch_gcc_target_options. GCC does not know "-m32" or + "-mcmodel=large". */ + +static char * +s390_gcc_target_options (struct gdbarch *gdbarch) +{ + return xstrdup (gdbarch_ptr_bit (gdbarch) == 64 ? "-m64" : "-m31"); +} + +/* Implement gdbarch_gnu_triplet_regexp. Target triplets are "s390-*" + for 31-bit and "s390x-*" for 64-bit, while the BFD arch name is + always "s390". Note that an s390x compiler supports "-m31" as + well. */ + +static const char * +s390_gnu_triplet_regexp (struct gdbarch *gdbarch) +{ + return "s390x?"; +} + +/* Implementation of `gdbarch_stap_is_single_operand', as defined in + gdbarch.h. */ + +static int +s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) +{ + return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement + or indirection. */ + || *s == '%' /* Register access. */ + || isdigit (*s)); /* Literal number. */ +} /* Set up GNU/Linux gdbarch. Allocates struct gdbarch if needed. */ @@ -5543,10 +5516,6 @@ s390_linux_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); - set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand); - set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options); - set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp); - /* Support reverse debugging. */ set_gdbarch_process_record (gdbarch, s390_process_record); set_gdbarch_process_record_signal (gdbarch, s390_linux_record_signal); @@ -5554,6 +5523,11 @@ s390_linux_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) s390_init_linux_record_tdep (&s390_linux_record_tdep, ABI_LINUX_S390); s390_init_linux_record_tdep (&s390x_linux_record_tdep, ABI_LINUX_ZSERIES); + /* Miscellaneous. */ + set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand); + set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options); + set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp); + return gdbarch; }