public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Aditya Kamath1 <Aditya.Kamath1@ibm.com>
To: Tom Tromey <tom@tromey.com>,
	Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: RE: [PATCH] Modify align-c/align-c++ test case for AIX
Date: Mon, 13 Mar 2023 13:04:45 +0000	[thread overview]
Message-ID: <CH2PR15MB35446440EE3483060CF8A2C8D6B99@CH2PR15MB3544.namprd15.prod.outlook.com> (raw)
In-Reply-To: <87edpwmzpz.fsf@tromey.com>

[-- Attachment #1: Type: text/plain, Size: 3304 bytes --]

Hi Tom, Ulrich and community,

>> In AIX, we have observed around 1500 failures in align-c/align-c++
>> testcase. The reason being this testcase shows the alignment outputs
>> of global variables that are unused in the main (). In AIX we need to
>> use atleast one global variable to access the same.

> Could you say why this is needed?

Consider the code:-
#include <stdio.h>
int global_variable = 1;
int main(){
        int local_variable = 1;
        printf ("Simple print statement \n");
        return 0;
}

When we debug with gdb and try to print global_variable this is what happens:-
(gdb) b main
Breakpoint 1 at 0x1000052c: file /home/aditya/gdb_tests/simple_test.c, line 4.
(gdb) r
Starting program: /home/aditya/gdb_tests/simple_test
Breakpoint 1, main () at /home/aditya/gdb_tests/simple_test.c:4
4               int local_variable = 1;
(gdb) p global_variable
ret = -1
ret = -1
Cannot access memory at address 0xffffffff

This ret = -1 is a printf(“ret = %d\n”, ret) statement I have used within my rs6000-aix-nat.c code to check what my ptrace call returns..

So what happens is ptrace call in AIX is not allowed to access any variable or rather say memory or  a segment which is not used in the user/debuggee code. Hence ptrace returned -1 and therefore the address 0xffffffff is used which we will not be able to access anyway.

Now Consider the code where we use it:-
#include <stdio.h>
int global_variable = 1;
int main(){
        int local_variable = 1;
        global_variable++;
        printf ("Simple print statement \n");
        return 0;
}

(gdb) b main
Breakpoint 1 at 0x1000052c: file /home/aditya/gdb_tests/simple_test.c, line 4.
(gdb) r
Starting program: /home/aditya/gdb_tests/simple_test
Breakpoint 1, main () at /home/aditya/gdb_tests/simple_test.c:4
4               int local_variable = 1;

(gdb) p global_variable
ret = 1
$1 = 1
(gdb)

This is because now we have the main () using the global_variable and hence ptrace got the access for the same and could return the correct memory address.

The key thing is user functions need to use global variables to get access. Otherwise the ptrace calls will return -1 and hence in our align-c/align-c++ all the testcases failed without the patch and the moment I used one global variable ptrace calls got access and the test cases passed.

Kindly let me know if you and the community think the patch in the previous email was therefore the right thing to do.

Have a nice day ahead.

Thanks and regards,
Aditya.

From: Tom Tromey <tom@tromey.com>
Date: Friday, 10 March 2023 at 8:18 PM
To: Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: [EXTERNAL] Re: [PATCH] Modify align-c/align-c++ test case for AIX
>>>>> Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org> writes:

> In AIX, we have observed around 1500 failures in align-c/align-c++
> testcase. The reason being this testcase shows the alignment outputs
> of global variables that are unused in the main (). In AIX we need to
> use atleast one global variable to access the same.

Could you say why this is needed?

Tom

  reply	other threads:[~2023-03-13 13:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  8:57 Aditya Kamath1
2023-03-10 14:46 ` Tom Tromey
2023-03-13 13:04   ` Aditya Kamath1 [this message]
2023-03-13 14:10     ` Ulrich Weigand
2023-03-15 11:52       ` Aditya Kamath1
2023-03-15 12:45         ` Tom Tromey
2023-03-16  7:01           ` Aditya Kamath1
2023-03-17 17:06             ` Ulrich Weigand
2023-03-17 22:03             ` Tom Tromey
2023-03-21  7:01               ` Aditya Kamath1
2023-03-21  7:41                 ` Ulrich Weigand
2023-03-21 11:05                   ` Pedro Alves
2023-03-21 14:17                   ` Tom Tromey
2023-03-21 14:26                     ` Ulrich Weigand
2023-03-29 11:28                       ` Aditya Kamath1
2023-03-29 13:36                         ` Pedro Alves
2023-03-31 12:29                           ` Aditya Kamath1
2023-04-04 13:24                             ` Aditya Kamath1
2023-04-05 16:33                             ` Pedro Alves
2023-04-06 13:15                               ` Aditya Kamath1
2023-04-06 16:18                                 ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2023-03-10  8:56 Aditya Kamath1
2023-03-10 10:08 ` Aditya Kamath1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH2PR15MB35446440EE3483060CF8A2C8D6B99@CH2PR15MB3544.namprd15.prod.outlook.com \
    --to=aditya.kamath1@ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).