On 18 June 2015 at 05:58, Valery Ushakov <u...@stderr.spb.ru> wrote:
> On Wed, Jun 17, 2015 at 09:55:31 -0400, Andrew Cagney wrote:
>
>> pulling stuff like memory into Lua has proven relatively painless
>> (which reminds me, how do I silently detect that db_read_bytes
>> failed).
>
> Do you mean "detecting" - detecting the fault, and/or "silently" - not
> printing "Faulted in DDB..."?

Both :-)

- get some sort of status indication that a memory read was invalid

- not have the error message printed

my code looks like:

    uint8_t byte;
    //printf("%zx/%zu", addr, addr);
    db_read_bytes(addr, sizeof(byte), &byte);
    //printf(" %02x/%u\n", byte, byte);
    lua_pushinteger(L, byte);
    return 1;

if the address is invalid, something inside of db_read_bytes prints a
message but still returns.  Not exactly correct :-)

> ISTR, we always print "Faulted in DDB".  To detect the fault you
> probably need to use setjmp/db_recover around the access.

Ah, I'll dig further :-)

> -uwe

Reply via email to