From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 267033858284 for ; Mon, 18 Jul 2022 14:05:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 267033858284 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-x4MrZS59PxmPUAEqldYsbg-1; Mon, 18 Jul 2022 10:04:58 -0400 X-MC-Unique: x4MrZS59PxmPUAEqldYsbg-1 Received: by mail-wm1-f70.google.com with SMTP id a6-20020a05600c348600b003a2d72b7a15so8733262wmq.9 for ; Mon, 18 Jul 2022 07:04:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=zCtE2JoOyPOoTJDV8bZPEMGfPWZ5HcD7ewMdUBKmHpQ=; b=NxsBAee2NUbldLxKLhcMkm5+W7DJBL6kA6aaZby1CIV7poWIGpBAUtwht90kF3DgSy X13vAzc+8QEOfjRRV61pMMkJssNYbRm06X4rWF4sxG7hplc00F3WczJVCQ9Dt4XqVXHP dMy9xcuXEd/rCxKwpA2y2+rJDso27T8f0VqWhDDvjjybafU4Q/yQ3O68xCcD08KUib8r nku/k4a/ddfXqyK7BVzToFUy1daMglnUYg3ZcwkKANwZRc2Kc/9pRG+2xf72er/n9NIF tQGI6Y/XahBHdY87RbXCZDXtkKhyFplYz2nLzMCdb1ff4EZiRwwVOiW8sLjXWnxergTL LBvA== X-Gm-Message-State: AJIora9a1cf4ix9B/MPM+Atrv2ZxkPAxvVkE6chhdr+kadvvl3e2QLdS Gt2366hF79xJuRJgvWz2GrQn1SzZI6MqMIAwwJjd4aYlheWBGmSd3/DRVYpZcdtiOAIQH6+3EY8 FkOKnosf026nob/cSwWCOAg== X-Received: by 2002:adf:979b:0:b0:21d:868a:7f3b with SMTP id s27-20020adf979b000000b0021d868a7f3bmr23070052wrb.451.1658153096605; Mon, 18 Jul 2022 07:04:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEBHzKE/Gk9ss215d2iHs7IVG703xPkxTakOpN8Px+v0/QFXKOyv1VgsSqs5aC/MHicd9CWQ== X-Received: by 2002:adf:979b:0:b0:21d:868a:7f3b with SMTP id s27-20020adf979b000000b0021d868a7f3bmr23070005wrb.451.1658153096038; Mon, 18 Jul 2022 07:04:56 -0700 (PDT) Received: from localhost (15.72.115.87.dyn.plus.net. [87.115.72.15]) by smtp.gmail.com with ESMTPSA id be9-20020a05600c1e8900b003a30cfb859asm14446879wmb.5.2022.07.18.07.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 07:04:55 -0700 (PDT) From: Andrew Burgess To: Tiezhu Yang , gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] gdb: LoongArch: Fix code style issues In-Reply-To: <1657972545-28608-1-git-send-email-yangtiezhu@loongson.cn> References: <1657972545-28608-1-git-send-email-yangtiezhu@loongson.cn> Date: Mon, 18 Jul 2022 15:04:54 +0100 Message-ID: <87wncaqzy1.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2022 14:05:10 -0000 Tiezhu Yang writes: > Fix some code style issues suggested by Tom Tromey, thank you. > > (1) Put an introductory comment to explain the purpose for some functions. > > (2) Modify the the attribute code to make it portable. > > (3) Remove globals and pass pointers to locals. > > (4) Remove "*" in the subsequent comment lines. > > Signed-off-by: Tiezhu Yang > --- > gdb/loongarch-tdep.c | 313 +++++++++++++++++++++++++++------------------------ > 1 file changed, 165 insertions(+), 148 deletions(-) > > diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c > index 41422f0..9fc426e 100644 > --- a/gdb/loongarch-tdep.c > +++ b/gdb/loongarch-tdep.c > @@ -452,6 +452,9 @@ static const struct frame_unwind loongarch_frame_unwind = { > /*.prev_arch =*/nullptr, > }; > > +/* Pass a value in a sequence of consecutive general-purpose argument registers. > + The caller is responsible for ensuring sufficient registers are available. */ > + Is the "... a sequence of ..." part correct? I know there are some parts of GDB that allow values to flow from one register to the next, but I thought at the regcache level we dealt with individual registers, and the code in this function doesn't seem to do any "... a sequence of ...." behaviour. Also, the comments are an opportunity to explain the arguments, especially anything that might not be immediately obvious. In this case there is (what I would consider) a non-obvious mapping between GAR and which register is written to. Your comment can explain this: /* Write the contents of buffer VAL into the general purpose argument register defined by GAR in REGCACHE. GAR should be a value in the range 0 to LOONGARCH_ARG_REGNUM, which correspond to registers A7 and A0 respectively. */ Please feel free to improve the wording. I think most of the new function comments added in this commit would benefit from a similar rewrite. Thanks, Andrew > static void > pass_in_gar (struct regcache *regcache, unsigned int gar, const gdb_byte *val) > { > @@ -459,6 +462,9 @@ pass_in_gar (struct regcache *regcache, unsigned int gar, const gdb_byte *val) > regcache->cooked_write (regnum, val); > } > > +/* Pass a value in a sequence of consecutive floating-point argument registers. > + The caller is responsible for ensuring sufficient registers are available. */ > + > static void > pass_in_far (struct regcache *regcache, unsigned int far, const gdb_byte *val) > { > @@ -466,29 +472,30 @@ pass_in_far (struct regcache *regcache, unsigned int far, const gdb_byte *val) > regcache->cooked_write (regnum, val); > } > > -static __attribute__((aligned(16))) gdb_byte buf[1024] = { 0 }; > -static gdb_byte *addr = buf; > +/* Pass a value on the stack. */ > > static void > -pass_on_stack (struct regcache *regcache, const gdb_byte *val, size_t len, int align) > +pass_on_stack (struct regcache *regcache, const gdb_byte *val, > + size_t len, int align, gdb_byte **addr) > { > align = align_up (align, 8); > if (align > 16) > align = 16; > > - CORE_ADDR align_addr = (CORE_ADDR) addr; > + CORE_ADDR align_addr = (CORE_ADDR) (*addr); > align_addr = align_up (align_addr, align); > - addr = (gdb_byte *) align_addr; > - memcpy (addr, val, len); > - addr += len; > + *addr = (gdb_byte *) align_addr; > + memcpy (*addr, val, len); > + *addr += len; > } > > -static unsigned int fixed_point_members = 0; > -static unsigned int floating_point_members = 0; > -static bool first_member_is_fixed_point = false; > +/* Compute the numbers of struct member */ > > static void > -compute_struct_member (struct type *type) > +compute_struct_member (struct type *type, > + unsigned int *fixed_point_members, > + unsigned int *floating_point_members, > + bool *first_member_is_fixed_point) > { > for (int i = 0; i < type->num_fields (); i++) > { > @@ -501,17 +508,20 @@ compute_struct_member (struct type *type) > || field_type->code () == TYPE_CODE_ENUM > || field_type->code () == TYPE_CODE_PTR) > { > - fixed_point_members++; > + (*fixed_point_members)++; > > - if (floating_point_members == 0) > - first_member_is_fixed_point = true; > + if (*floating_point_members == 0) > + *first_member_is_fixed_point = true; > } > else if (field_type->code () == TYPE_CODE_FLT) > - floating_point_members++; > + (*floating_point_members)++; > else if (field_type->code () == TYPE_CODE_STRUCT) > - compute_struct_member (field_type); > + compute_struct_member (field_type, > + fixed_point_members, > + floating_point_members, > + first_member_is_fixed_point); > else if (field_type->code () == TYPE_CODE_COMPLEX) > - floating_point_members += 2; > + (*floating_point_members) += 2; > } > } > > @@ -531,11 +541,15 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > int regsize = register_size (gdbarch, 0); > unsigned int gar = LOONGARCH_ARG_REGNUM; > unsigned int far = LOONGARCH_ARG_REGNUM; > + unsigned int fixed_point_members; > + unsigned int floating_point_members; > + bool first_member_is_fixed_point; > + gdb_byte buf[1024] = { 0 }; > + gdb_byte *addr = buf; > > if (return_method != return_method_normal) > pass_in_gar (regcache, gar--, (gdb_byte *) &struct_addr); > > - addr = buf; > for (int i = 0; i < nargs; i++) > { > struct value *arg = args[i]; > @@ -555,17 +569,17 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > case TYPE_CODE_PTR: > { > /* integer or pointer type is passed in GAR. > - * If no GAR is available, it's passed on the stack. > - * When passed in registers or on the stack, > - * the unsigned integer scalars are zero-extended to GRLEN bits, > - * and the signed integer scalars are sign-extended. */ > + If no GAR is available, it's passed on the stack. > + When passed in registers or on the stack, > + the unsigned integer scalars are zero-extended to GRLEN bits, > + and the signed integer scalars are sign-extended. */ > if (type->is_unsigned ()) > { > ULONGEST data = extract_unsigned_integer (val, len, BFD_ENDIAN_LITTLE); > if (gar > 0) > pass_in_gar (regcache, gar--, (gdb_byte *) &data); > else > - pass_on_stack (regcache, (gdb_byte *) &data, len, align); > + pass_on_stack (regcache, (gdb_byte *) &data, len, align, &addr); > } > else > { > @@ -573,7 +587,7 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (gar > 0) > pass_in_gar (regcache, gar--, (gdb_byte *) &data); > else > - pass_on_stack (regcache, (gdb_byte *) &data, len, align); > + pass_on_stack (regcache, (gdb_byte *) &data, len, align, &addr); > } > } > break; > @@ -581,12 +595,12 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (len == 2 * regsize) > { > /* long double type is passed in a pair of GAR, > - * with the low-order GRLEN bits in the lower-numbered register > - * and the high-order GRLEN bits in the higher-numbered register. > - * If exactly one register is available, > - * the low-order GRLEN bits are passed in the register > - * and the high-order GRLEN bits are passed on the stack. > - * If no GAR is available, it's passed on the stack. */ > + with the low-order GRLEN bits in the lower-numbered register > + and the high-order GRLEN bits in the higher-numbered register. > + If exactly one register is available, > + the low-order GRLEN bits are passed in the register > + and the high-order GRLEN bits are passed on the stack. > + If no GAR is available, it's passed on the stack. */ > if (gar >= 2) > { > pass_in_gar (regcache, gar--, val); > @@ -595,24 +609,24 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > else > { > /* The other floating-point type is passed in FAR. > - * If no FAR is available, it's passed in GAR. > - * If no GAR is available, it's passed on the stack. */ > + If no FAR is available, it's passed in GAR. > + If no GAR is available, it's passed on the stack. */ > if (far > 0) > pass_in_far (regcache, far--, val); > else if (gar > 0) > pass_in_gar (regcache, gar--, val); > else > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > break; > case TYPE_CODE_STRUCT: > @@ -620,7 +634,10 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > fixed_point_members = 0; > floating_point_members = 0; > first_member_is_fixed_point = false; > - compute_struct_member (type); > + compute_struct_member (type, > + &fixed_point_members, > + &floating_point_members, > + &first_member_is_fixed_point); > > if (len > 0 && len <= regsize) > { > @@ -628,20 +645,20 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (fixed_point_members > 0 && floating_point_members == 0) > { > /* If there is an available GAR, > - * the structure is passed through the GAR by value passing; > - * If no GAR is available, it's passed on the stack. */ > + the structure is passed through the GAR by value passing; > + If no GAR is available, it's passed on the stack. */ > if (gar > 0) > pass_in_gar (regcache, gar--, val); > else > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > /* The structure has only floating-point members. */ > else if (fixed_point_members == 0 && floating_point_members > 0) > { > /* One floating-point member. > - * The argument is passed in a FAR. > - * If no FAR is available, the value is passed in a GAR. > - * if no GAR is available, the value is passed on the stack. */ > + The argument is passed in a FAR. > + If no FAR is available, the value is passed in a GAR. > + if no GAR is available, the value is passed on the stack. */ > if (floating_point_members == 1) > { > if (far > 0) > @@ -649,14 +666,14 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar > 0) > pass_in_gar (regcache, gar--, val); > else > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > /* Two floating-point members. > - * The argument is passed in a pair of available FAR, > - * with the low-order float member bits in the lower-numbered FAR > - * and the high-order float member bits in the higher-numbered FAR. > - * If the number of available FAR is less than 2, it's passed in a GAR, > - * and passed on the stack if no GAR is available. */ > + The argument is passed in a pair of available FAR, > + with the low-order float member bits in the lower-numbered FAR > + and the high-order float member bits in the higher-numbered FAR. > + If the number of available FAR is less than 2, it's passed in a GAR, > + and passed on the stack if no GAR is available. */ > else if (floating_point_members == 2) > { > if (far >= 2) > @@ -670,7 +687,7 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > } > @@ -678,21 +695,21 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (fixed_point_members > 0 && floating_point_members > 0) > { > /* One float member and multiple fixed-point members. > - * If there are available GAR, the structure is passed in a GAR, > - * and passed on the stack if no GAR is available. */ > + If there are available GAR, the structure is passed in a GAR, > + and passed on the stack if no GAR is available. */ > if (floating_point_members == 1 && fixed_point_members > 1) > { > if (gar > 0) > pass_in_gar (regcache, gar--, val); > else > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > /* One float member and only one fixed-point member. > - * If one FAR and one GAR are available, > - * the floating-point member of the structure is passed in the FAR, > - * and the fixed-point member of the structure is passed in the GAR. > - * If no floating-point register but one GAR is available, it's passed in GAR; > - * If no GAR is available, it's passed on the stack. */ > + If one FAR and one GAR are available, > + the floating-point member of the structure is passed in the FAR, > + and the fixed-point member of the structure is passed in the GAR. > + If no floating-point register but one GAR is available, it's passed in GAR; > + If no GAR is available, it's passed on the stack. */ > else if (floating_point_members == 1 && fixed_point_members == 1) > { > if (far > 0 && gar > 0) > @@ -713,7 +730,7 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (gar > 0) > pass_in_gar (regcache, gar--, val); > else > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > } > @@ -724,12 +741,12 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (fixed_point_members > 0 && floating_point_members == 0) > { > /* The argument is passed in a pair of available GAR, > - * with the low-order bits in the lower-numbered GAR > - * and the high-order bits in the higher-numbered GAR. > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on the stack, > - * and passed on the stack if no GAR is available. */ > + with the low-order bits in the lower-numbered GAR > + and the high-order bits in the higher-numbered GAR. > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on the stack, > + and passed on the stack if no GAR is available. */ > if (gar >= 2) > { > pass_in_gar (regcache, gar--, val); > @@ -738,26 +755,26 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > /* Only floating-point members. */ > else if (fixed_point_members == 0 && floating_point_members > 0) > { > /* The structure has one long double member > - * or one double member and two adjacent float members > - * or 3-4 float members. > - * The argument is passed in a pair of available GAR, > - * with the low-order bits in the lower-numbered GAR > - * and the high-order bits in the higher-numbered GAR. > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on the stack, > - * and passed on the stack if no GAR is available. */ > + or one double member and two adjacent float members > + or 3-4 float members. > + The argument is passed in a pair of available GAR, > + with the low-order bits in the lower-numbered GAR > + and the high-order bits in the higher-numbered GAR. > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on the stack, > + and passed on the stack if no GAR is available. */ > if ((len == 16 && floating_point_members == 1) > || (len == 16 && floating_point_members == 3) > || (len == 12 && floating_point_members == 3) > @@ -771,26 +788,26 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > /* The structure with two double members > - * is passed in a pair of available FAR, > - * with the low-order bits in the lower-numbered FAR > - * and the high-order bits in the higher-numbered FAR. > - * If no a pair of available FAR, > - * it's passed in a pair of available GAR, > - * with the low-order bits in the lower-numbered GAR > - * and the high-order bits in the higher-numbered GAR. > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on stack, > - * and passed on the stack if no GAR is available. > - * A structure with one double member and one float member is same. */ > + is passed in a pair of available FAR, > + with the low-order bits in the lower-numbered FAR > + and the high-order bits in the higher-numbered FAR. > + If no a pair of available FAR, > + it's passed in a pair of available GAR, > + with the low-order bits in the lower-numbered GAR > + and the high-order bits in the higher-numbered GAR. > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on stack, > + and passed on the stack if no GAR is available. > + A structure with one double member and one float member is same. */ > else if ((len == 16 && floating_point_members == 2) > || (len == 12 && floating_point_members == 2)) > { > @@ -807,11 +824,11 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > } > @@ -822,14 +839,14 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (floating_point_members == 1 && fixed_point_members == 1) > { > /* If one FAR and one GAR are available, > - * the floating-point member of the structure is passed in the FAR, > - * and the fixed-point member of the structure is passed in the GAR; > - * If no floating-point registers but two GARs are available, > - * it's passed in the two GARs; > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on the stack; > - * And it's passed on the stack if no GAR is available. */ > + the floating-point member of the structure is passed in the FAR, > + and the fixed-point member of the structure is passed in the GAR; > + If no floating-point registers but two GARs are available, > + it's passed in the two GARs; > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on the stack; > + And it's passed on the stack if no GAR is available. */ > if (far > 0 && gar > 0) > { > if (first_member_is_fixed_point == false) > @@ -851,22 +868,22 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (far == 0 && gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else if (far == 0 && gar == 0) > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > else > { > /* The argument is passed in a pair of available GAR, > - * with the low-order bits in the lower-numbered GAR > - * and the high-order bits in the higher-numbered GAR. > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on the stack, > - * and passed on the stack if no GAR is available. */ > + with the low-order bits in the lower-numbered GAR > + and the high-order bits in the higher-numbered GAR. > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on the stack, > + and passed on the stack if no GAR is available. */ > if (gar >= 2) > { > pass_in_gar (regcache, gar--, val); > @@ -875,11 +892,11 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > } > @@ -887,15 +904,15 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (len > 2 * regsize) > { > /* It's passed by reference and are replaced in the argument list with the address. > - * If there is an available GAR, the reference is passed in the GAR, > - * and passed on the stack if no GAR is available. */ > + If there is an available GAR, the reference is passed in the GAR, > + and passed on the stack if no GAR is available. */ > sp = align_down (sp - len, 16); > write_memory (sp, val, len); > > if (gar > 0) > pass_in_gar (regcache, gar--, (const gdb_byte *) &sp); > else > - pass_on_stack (regcache, (const gdb_byte*) &sp, len, regsize); > + pass_on_stack (regcache, (const gdb_byte*) &sp, len, regsize, &addr); > } > } > break; > @@ -904,21 +921,21 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (len > 0 && len <= regsize) > { > /* The argument is passed in a GAR, > - * or on the stack by value if no GAR is available. */ > + or on the stack by value if no GAR is available. */ > if (gar > 0) > pass_in_gar (regcache, gar--, val); > else > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > else if (len > regsize && len <= 2 * regsize) > { > /* The argument is passed in a pair of available GAR, > - * with the low-order bits in the lower-numbered GAR > - * and the high-order bits in the higher-numbered GAR. > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on the stack. > - * The arguments are passed on the stack when no GAR is available. */ > + with the low-order bits in the lower-numbered GAR > + and the high-order bits in the higher-numbered GAR. > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on the stack. > + The arguments are passed on the stack when no GAR is available. */ > if (gar >= 2) > { > pass_in_gar (regcache, gar--, val); > @@ -927,25 +944,25 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + regsize, len - regsize, align); > + pass_on_stack (regcache, val + regsize, len - regsize, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > else if (len > 2 * regsize) > { > /* It's passed by reference and are replaced in the argument list with the address. > - * If there is an available GAR, the reference is passed in the GAR, > - * and passed on the stack if no GAR is available. */ > + If there is an available GAR, the reference is passed in the GAR, > + and passed on the stack if no GAR is available. */ > sp = align_down (sp - len, 16); > write_memory (sp, val, len); > > if (gar > 0) > pass_in_gar (regcache, gar--, (const gdb_byte *) &sp); > else > - pass_on_stack (regcache, (const gdb_byte*) &sp, len, regsize); > + pass_on_stack (regcache, (const gdb_byte*) &sp, len, regsize, &addr); > } > break; > case TYPE_CODE_COMPLEX: > @@ -956,11 +973,11 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > if (target_len < regsize) > { > /* The complex with two float members > - * is passed in a pair of available FAR, > - * with the low-order float member bits in the lower-numbered FAR > - * and the high-order float member bits in the higher-numbered FAR. > - * If the number of available FAR is less than 2, it's passed in a GAR, > - * and passed on the stack if no GAR is available. */ > + is passed in a pair of available FAR, > + with the low-order float member bits in the lower-numbered FAR > + and the high-order float member bits in the higher-numbered FAR. > + If the number of available FAR is less than 2, it's passed in a GAR, > + and passed on the stack if no GAR is available. */ > if (far >= 2) > { > pass_in_far (regcache, far--, val); > @@ -972,23 +989,23 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > else if (target_len == regsize) > { > /* The complex with two double members > - * is passed in a pair of available FAR, > - * with the low-order bits in the lower-numbered FAR > - * and the high-order bits in the higher-numbered FAR. > - * If no a pair of available FAR, > - * it's passed in a pair of available GAR, > - * with the low-order bits in the lower-numbered GAR > - * and the high-order bits in the higher-numbered GAR. > - * If only one GAR is available, > - * the low-order bits are in the GAR > - * and the high-order bits are on stack, > - * and passed on the stack if no GAR is available. */ > + is passed in a pair of available FAR, > + with the low-order bits in the lower-numbered FAR > + and the high-order bits in the higher-numbered FAR. > + If no a pair of available FAR, > + it's passed in a pair of available GAR, > + with the low-order bits in the lower-numbered GAR > + and the high-order bits in the higher-numbered GAR. > + If only one GAR is available, > + the low-order bits are in the GAR > + and the high-order bits are on stack, > + and passed on the stack if no GAR is available. */ > { > if (far >= 2) > { > @@ -1003,27 +1020,27 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, > else if (gar == 1) > { > pass_in_gar (regcache, gar--, val); > - pass_on_stack (regcache, val + align, len - align, align); > + pass_on_stack (regcache, val + align, len - align, align, &addr); > } > else > { > - pass_on_stack (regcache, val, len, align); > + pass_on_stack (regcache, val, len, align, &addr); > } > } > } > else if (target_len == 2 * regsize) > { > /* The complex with two long double members > - * is passed by reference and are replaced in the argument list with the address. > - * If there is an available GAR, the reference is passed in the GAR, > - * and passed on the stack if no GAR is available. */ > + is passed by reference and are replaced in the argument list with the address. > + If there is an available GAR, the reference is passed in the GAR, > + and passed on the stack if no GAR is available. */ > sp = align_down (sp - len, 16); > write_memory (sp, val, len); > > if (gar > 0) > pass_in_gar (regcache, gar--, (const gdb_byte *) &sp); > else > - pass_on_stack (regcache, (const gdb_byte*) &sp, regsize, regsize); > + pass_on_stack (regcache, (const gdb_byte*) &sp, regsize, regsize, &addr); > } > } > break; > -- > 2.1.0