Skip to content

Commit 0f80ad4

Browse files
smowtonDaniel Kroening
authored and
Daniel Kroening
committed
Parse the exception table
1 parent 704ed4f commit 0f80ad4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ class java_bytecode_parse_treet
8282
return instructions.back();
8383
}
8484

85-
class exceptiont
85+
struct exceptiont
8686
{
87+
std::size_t start_pc;
88+
std::size_t end_pc;
89+
std::size_t handler_pc;
90+
symbol_typet catch_type;
8791
};
8892

8993
typedef std::vector<exceptiont> exception_tablet;

src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,13 +968,20 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
968968
rbytecode(method.instructions);
969969

970970
u2 exception_table_length=read_u2();
971+
method.exception_table.resize(exception_table_length);
971972

972973
for(std::size_t e=0; e<exception_table_length; e++)
973974
{
974-
u2 UNUSED start_pc=read_u2();
975-
u2 UNUSED end_pc=read_u2();
976-
u2 UNUSED handler_pc=read_u2();
977-
u2 UNUSED catch_type=read_u2();
975+
u2 start_pc=read_u2();
976+
u2 end_pc=read_u2();
977+
u2 handler_pc=read_u2();
978+
u2 catch_type=read_u2();
979+
method.exception_table[e].start_pc=start_pc;
980+
method.exception_table[e].end_pc=end_pc;
981+
method.exception_table[e].handler_pc=handler_pc;
982+
if(catch_type!=0)
983+
method.exception_table[e].catch_type=
984+
to_symbol_type(pool_entry(catch_type).expr.type());
978985
}
979986

980987
u2 attributes_count=read_u2();

0 commit comments

Comments
 (0)