Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
151 user(s) are online (146 user(s) are browsing Forums)

Members: 2
Guests: 149

VooDoo, pvanni, more...

Support us!

Headlines

 
  Register To Post  

(1) 2 »
break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@All

I am in need to debug one app that didn't crash but instead stuck at some point. The usual printf way didn't help much, so I want to do as people do with GDB: they load up a binary, waiting till the necessary moment, press "ctrl+c" and then type "backtrace" and they see the current stack trace.

Now, with our GDB it can works if only our current GCC didn't produce Dwarf4 debug based binaries (as it now what all the ppls use in whole worlds), but our GDB is too old, and can only handle Dwarf2 binaries. So I need to rebuild adtools the apply the necessary patch so it will build Dwarf2 based bins. Not sure though if there also will be no needs to rebuild all link libraries too :(

So, I tried DB101: while it loads up fine, etc, etc it just didn't have the functionality to broke the process when I need and to see stack trace (at least I can't see).

Then I tried SpotLess: that one even didn't work. It runs, i can load up binary, but when I hit "start" nothing happens.


Now, question: maybe we have some debug-app, just to watch stack-trace at the time we need to give app? Maybe just some tool, which we run like "stack watch binary", and then it handles some key-combo, which when we press, just open up a window with a stack trace?




Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
@kas1e

The problem is the ancient version of binutils in adtools. It needs some love, from someone with a lot of patience. It's a very hairy patchset for a very hairy piece of code.

Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
@kas1e

What I was trying to say was that I think it's a better idea to try to update GDB than to patch GCC

Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@sTix
Yeah, I know :) That need to deal with the issue somehow now, not tomorrow :)

Dunno, maybe it needs to be written just some simple thing that will do exactly that: attach to the process, wait for the key combo, and then dump stack trace of a process once the combo is recieved.

I just think it is somewhere written already, just can't remember what/where.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@sTix
Quote:

What I was trying to say was that I think it's a better idea to try to update GDB than to patch GCC


Patch GCC it just that: https://github.com/sba1/adtools/pull/7 ... 8face2b0047eadfc5b1c04b01

So only (i hope) need to rebuild my gcc and it will produce dwarf2 bins and i will be able to do that in our ancient gcc. At least, that it more realistic than new GDB port which no one able to do in latest 15 years :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
@kas1e
Quote:
Yeah, I know :) That need to deal with the issue somehow now, not tomorrow :)

Dunno, maybe it needs to be written just some simple thing that will do exactly that: attach to the process, wait for the key combo, and then dump stack trace of a process once the combo is recieved.

I just think it is somewhere written already, just can't remember what/where.


I understand. I don't think we can find anyone that can / want to update binutils before midnight so I'm afraid you need to resort to something more creative

How close can you get with printfs?

Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@sTix
Quote:

How close can you get with printfs?


Nothing I can understand :) I then just ask the authors about it, and they say that they need stack trace on the moment the game stuck. So, fighting with that piece of shit. I hope that once I get the backtrace and send it to them, they, as authors, will help out to fix it.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
@kas1e
Quote:
Patch GCC it just that: https://github.com/sba1/adtools/pull/7 ... 8face2b0047eadfc5b1c04b01

So only (i hope) need to rebuild my gcc and it will produce dwarf2 bins and i will be able to do that in our ancient gcc. At least, that it more realistic than new GDB port which no one able to do in latest 15 years :)


Ah, it's that simple. Sounds like a stop gap solution if it works.

Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
@kas1e
Quote:
Nothing I can understand :) I then just ask the authors about it, and they say that they need stack trace on the moment the game stuck. So, fighting with that piece of shit. I hope that once I get the backtrace and send it to them, they, as authors, will help out to fix it.


Ah, yes if the authors are willing to take a look I can understand that they want more than just printf output.

I'm working on your namespace problems BTW. It was a bit more work than I antecipated, lots of things missing in clib2.

Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@sTix
Quote:

I'm working on your namespace problems BTW. It was a bit more work than I antecipated, lots of things missing in clib2.

clib2 is loooong road. If things at least will works with newlib at the start that will be good too.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
@kas1e
Quote:
clib2 is loooong road. If things at least will works with newlib at the start that will be good too.


Yep, the road is long, but it's not blocked by concrete slabs and dragons (and there's food along the way).

Go to top
Re: break an app at need it time to see current stack trace of it.
Just can't stay away
Just can't stay away


See User information
@kas1e

To get a stack trace from a specific point in a program you can just insert in the source code a:

IExec->SuspendTask(NULL, STF_CRASHED)

there and it should bring up the grim reaper.

Or you could just do something like:

*(char *)0 = 0;

which will trigger a DSI and bring up the grim reaper as well.

Using Ranger you can also get a stack trace from any running program by selecting it from the process list and clicking the button next to "Stack:".

Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@kas1e

A program can’t stack trace itself,
you need start a process that can do it,
next you need suspend main program process,
run stack trace on main program process,
unsuspend main program, and exit debug process.
continue program.
something like that anyway.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@salas00
Quote:


To get a stack trace from a specific point in a program you can just insert in the source code a:

IExec->SuspendTask(NULL, STF_CRASHED)

there and it should bring up the grim reaper.

Or you could just do something like:

*(char *)0 = 0;


A problem that I didn't know where I stuck in the code (because of too much for's loops, ifs, and elses) So I want to grab stack trace when I see issue visually without knowing where the issue in code is.

Quote:

Using Ranger you can also get a stack trace from any running program by selecting it from the process list and clicking the button next to "Stack:".


Yeah, thanks! While it didn't resolve symbols in the app itself, I still can get addresses and via addr2line got the necessary ones.

Through, what is interesting, when I run the game and go to the menu, and click on that "stack" button, it shows me many addresses as expected in the stack trace (and kernel, and graphics libs, and many addresses from my binary). Then once I run it and game stuck on loading md5 mesh, then in the stack trace of ranger all I have is 2 lines:

0x7ee4fe88 0x1EDE70 game
9x91a628e9 0x87e8 newlib.library.kmod

Where all the functions went which call that one ?:)

Anyway, seems that this is for real the function where i stuck! And it looks like this:

template<int BPP> static void shifttexture(uchar RESTRICT srcuint swuint shuint strideuchar RESTRICT dstuint dwuint dh)
{
    
    
    
uint wfrac sw/dwhfrac sh/dhwshift 0hshift 0;

    while(
dw<<wshift sw) {
        
wshift++;
    }


And this "while" never ends.


Edited by kas1e on 2021/1/31 6:40:58
Edited by kas1e on 2021/1/31 6:54:01
Edited by kas1e on 2021/1/31 6:54:34
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just popping in
Just popping in


See User information
Use simple printf and assure to avoid division by zero and all other values are as expected.

Anyway it could be an endian issue ..are you sure << operator have to shift values on left and not instead on right for big endian platforms?

Memento audere semper!
Go to top
Re: break an app at need it time to see current stack trace of it.
Just can't stay away
Just can't stay away


See User information
@kas1e

IIRC result of shift operation is undefined when wshift >= (sizeof(dw)*8).

Try changing the loop to:

while (wshift < (sizeof(dw)*8) && (dw << wshift) < sw) {
wshift++;
}

Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@Salas00

Tried like this:

template<int BPP> static void shifttexture(uchar RESTRICT srcuint swuint shuint strideuchar RESTRICT dstuint dwuint dh)
{
    
uint wfrac sw/dwhfrac sh/dhwshift 0hshift 0;
    
//while(dw<<wshift < sw) wshift++;
    
    
while (wshift < (sizeof(dw)*8) && (dw << wshift) < sw) {
        
wshift++;
    }

    while(
dh<<hshift shhshift++;

    
uint tshift wshift hshift;
    for(
uchar *yend = &src[sh*stride]; src yend;)
    {
        for(
uchar *xend = &src[sw*BPP], *xsrc srcxsrc xendxsrc += wfrac*BPPdst += BPP)
        {
            
uint t[BPP] = {0};
            for(
uchar *ycur xsrc, *xend = &ycur[wfrac*BPP], *yend = &src[hfrac*stride];
                
ycur yend;
                
ycur += stridexend += stride)
            {
                for(
uchar *xcur ycurxcur xendxcur += BPP)
                    
loopi(BPPt[i] += xcur[i];
            }
            
loopi(BPPdst[i] = t[i] >> tshift;
        }
        
src += hfrac*stride;
    }
}


Same stuck, and ranger show address which is that "wshift++;" in the while.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just can't stay away
Just can't stay away


See User information
@kas1e

Probably the same problem with the next loop.

Addr2line is not that accurate so it can be off by a few lines/statements.

Go to top
Re: break an app at need it time to see current stack trace of it.
Home away from home
Home away from home


See User information
@salas00

Yeah, tried like this:

template<int BPP> static void shifttexture(uchar RESTRICT srcuint swuint shuint strideuchar RESTRICT dstuint dwuint dh)
{
    
uint wfrac sw/dwhfrac sh/dhwshift 0hshift 0;

    
//while(dw<<wshift < sw) wshift++;
    
while (wshift < (sizeof(dw)*8) && (dw << wshift) < sw) {
        
wshift++;
    }

    
//while(dh<<hshift < sh) hshift++;
    
while (hshift < (sizeof(dh)*8) && (dh << hshift) < sh) {
        
hshift++;
    }

    
uint tshift wshift hshift;
    for(
uchar *yend = &src[sh*stride]; src yend;)
    {
        for(
uchar *xend = &src[sw*BPP], *xsrc srcxsrc xendxsrc += wfrac*BPPdst += BPP)
        {
            
uint t[BPP] = {0};
            for(
uchar *ycur xsrc, *xend = &ycur[wfrac*BPP], *yend = &src[hfrac*stride];
                
ycur yend;
                
ycur += stridexend += stride)
            {
                for(
uchar *xcur ycurxcur xendxcur += BPP)
                    
loopi(BPPt[i] += xcur[i];
            }
            
loopi(BPPdst[i] = t[i] >> tshift;
        }
        
src += hfrac*stride;
    }
}


And this time not stuck, but crash instead on "loopi(BPP) dst[i] = t[i] >> tshift;"

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: break an app at need it time to see current stack trace of it.
Just can't stay away
Just can't stay away


See User information
@kas1e

Try changing to:

loopi(BPP) dst[i] = (tshift < (sizeof(t[i])*8)) ? (t[i] >> tshift) : 0;

If t[i] is signed it should be:

loopi(BPP) dst[i] = (tshift < (sizeof(t[i])*8)) ? (t[i] >> tshift) : ((t[i] < 0) ? -1 : 0);

If there is a lot of this type of code you may want to consider using macros like this (from newlib 3.1.0 libm source code):
/* Macros to avoid undefined behaviour that can arise if the amount
   of a shift is exactly equal to the size of the shifted operand.  */

#define SAFE_LEFT_SHIFT(op,amt)                    \
  
(((amt) < sizeof(op)) ? ((op) << (amt)) : 0)

#define SAFE_RIGHT_SHIFT(op,amt)                \
  
(((amt) < sizeof(op)) ? ((op) >> (amt)) : 0)


Note that the SAFE_RIGHT_SHIFT needs to be modified if it's to work with signed values (where sign bit should be copied into new bits that are shifted in from the left).

Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project