AmigaLabs / binutils-gdb

binutils targeted for ppc-amigaos systems (AmigaOS NG like OS4.1).
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
0 stars 0 forks source link

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

Open kas1e opened 2 weeks ago

kas1e commented 2 weeks ago

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 commented 1 week ago

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 commented 1 week ago

@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 commented 1 week ago

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).