On 9/5/22 10:55, Milica Lazarevic wrote:
> Since there's no support for exception handling in C, the try-catch
> blocks have been deleted, and throw clauses are replaced. When a runtime
> error happens, we're printing out the error message. Disassembling of
> the current instruction interrupts. This behavior is achieved by adding
> sigsetjmp() to discard further disassembling after the error message
> prints and by adding the siglongjmp() function to imitate throwing an
> error. The goal was to maintain the same output as it was.
>
> Signed-off-by: Milica Lazarevic <milica.lazare...@syrmia.com>
> ---
>   disas/nanomips.cpp | 126 ++++++++++++++++++++++-----------------------
>   1 file changed, 61 insertions(+), 65 deletions(-)
>
> diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp
> index 5142f307fc..a8295ebfa8 100644
> --- a/disas/nanomips.cpp
> +++ b/disas/nanomips.cpp
> @@ -31,7 +31,6 @@

> +                        disassembly_function dis_fn = table[i].disassembly;
> +                        if (dis_fn == 0) {
> +                            strcpy(dis,
> +                            "disassembler failure - bad table entry");
> +                            return -6;
> +                        }
> +                        type = table[i].type;
> +                        g_autofree char *dis_str = dis_fn(op_code, info);
> +                        strcpy(dis, dis_str);
> +                        return table[i].instructions_size;
> +                    } else {
> +                        strcpy(dis, "reserved instruction");
> +                        return -2;

Ought these errors use the same error path?


r~

I'm not sure if I understood the question correctly. The difference between 
these errors and the errors covered by the patch is that, in the case of the 
latter, the disassembling of one part of the instruction has already happened. 
For example, if we have an irregular GPR register index, the output of the 
assembler will look something like this:
...
0x80200622:  86ad 9018      Invalid GPR register index 33
...
On the other hand, if we have some error like "disassembler failure - bad table 
entry" - that string would be the only output regarding the instruction we're 
trying to disassemble. The disassembling process, in this case, hasn't begun, 
so there's no need for an interruption like in the previous example.

But yes, in both cases after printing the error message, the disassembling of 
the particular instruction is not continuing.

Reply via email to