Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDB: "info regs" bring "fetch_registers: unexpected register : vscr" #24

Open
kas1e opened this issue Sep 4, 2024 · 3 comments
Open

Comments

@kas1e
Copy link

kas1e commented Sep 4, 2024

To reproduce: load up simple hello world, set breakpoint on main, run it, and when we breaks type "info regs" and while regs are shown, and the end we have that:

../../gdb/ppc-amigao-nat.c:586: internal-error: fetch_registers: unexpected register: 'vscr'
A problem internal to GDB has been detected,
further debugging may prove unreliable
Quit this debugging session ?(y or n)

That's on x5000.

Older GDB coming with SDK behave correctly in this regards on the same X5000 (so it seems not platform dependant), and print correctly both vscr and vrsave registers.

@migthymax
Copy link
Member

I resolved the reading of Altivec registers, so that it doesn't end gdb with an error. But would be interesting if displayed values are correct. My example doesn't use Altivec, thus are always 0.
How to write and example which uses the AltiVec registers?

@kas1e
Copy link
Author

kas1e commented Sep 10, 2024

@migthymax
Will check today, but for time being you can try this example:

#include <stdio.h>
#include <altivec.h>

void vector_addition(float *a, float *b, float *result, int size) {
    int i;
    // Process 4 floats at a time
    for (i = 0; i < size; i += 4) {
        // Load vectors from input arrays
        vector float va = vec_ld(0, &a[i]);
        vector float vb = vec_ld(0, &b[i]);

        // Perform addition
        vector float vresult = vec_add(va, vb);

        // Store the result back to the result array
        vec_st(vresult, 0, &result[i]);
    }
}

int main() {
    // Example data
    float a[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
    float b[] = {5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0};
    float result[8] = {0};

    // Perform vector addition
    vector_addition(a, b, result, 8);

    // Print the results
    for (int i = 0; i < 8; i++) {
        printf("result[%d] = %f\\n", i, result[i]);
    }

    return 0;
}

And build it with `-maltivec' key. As Qemu emulated peg2 (and so Altivec) you should be able to test it as well. In meantime i will try on real peg2 and on x1000 (which both have Alttivec)

@kas1e
Copy link
Author

kas1e commented Sep 10, 2024

I tried on x5000 firstly (which has no altivec) and with test case which do simple printf (so no altivec in use), and when i hit break on main, and run, then first time it simple didn't works and exit. Then i do reboot, and tried again. This time breakpoint on main works, and typing info reg bring me vscr and vrsave with strange valus such as 0x2c201c and 02c2a4c.

I tested old GDb (from SDK) , and this one show correctly 0x0 for both of these registers.

So something seems broken there and trash the memory (that can explain non working breakpoints at first, and strange values in altivec registers while there is none too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants