@@ -10,7 +10,7 @@ use binaryninja::debuginfo::{
10
10
11
11
use idb_rs:: id0:: { ID0Section , IDBParam1 , IDBParam2 } ;
12
12
use idb_rs:: til:: section:: TILSection ;
13
- use idb_rs:: til:: Type as TILType ;
13
+ use idb_rs:: til:: TypeVariant as TILTypeVariant ;
14
14
15
15
use log:: { error, trace, warn, LevelFilter } ;
16
16
@@ -92,9 +92,7 @@ impl std::io::Seek for BinaryViewReader<'_> {
92
92
fn seek ( & mut self , pos : std:: io:: SeekFrom ) -> std:: io:: Result < u64 > {
93
93
let new_offset = match pos {
94
94
std:: io:: SeekFrom :: Start ( offset) => Some ( offset) ,
95
- std:: io:: SeekFrom :: End ( end) => u64:: try_from ( self . bv . len ( ) )
96
- . unwrap ( )
97
- . checked_add_signed ( end) ,
95
+ std:: io:: SeekFrom :: End ( end) => self . bv . len ( ) . checked_add_signed ( end) ,
98
96
std:: io:: SeekFrom :: Current ( next) => self . offset . checked_add_signed ( next) ,
99
97
} ;
100
98
let new_offset =
@@ -148,9 +146,9 @@ fn parse_til_info(
148
146
bv : debug_file,
149
147
offset : 0 ,
150
148
} ;
151
- let file = std:: io:: BufReader :: new ( file) ;
149
+ let mut file = std:: io:: BufReader :: new ( file) ;
152
150
trace ! ( "Parsing the TIL section" ) ;
153
- let til = TILSection :: parse ( file) ?;
151
+ let til = TILSection :: read ( & mut file, idb_rs :: IDBSectionCompression :: None ) ?;
154
152
import_til_section ( debug_info, debug_file, & til, progress)
155
153
}
156
154
@@ -168,26 +166,26 @@ pub fn import_til_section(
168
166
TranslateTypeResult :: NotYet => {
169
167
panic ! (
170
168
"type could not be processed `{}`: {:#?}" ,
171
- & String :: from_utf8_lossy ( & ty. name) ,
169
+ ty. name. as_utf8_lossy ( ) ,
172
170
& ty. og_ty
173
171
) ;
174
172
}
175
173
TranslateTypeResult :: Error ( error) => {
176
174
error ! (
177
175
"Unable to parse type `{}`: {error}" ,
178
- & String :: from_utf8_lossy ( & ty. name)
176
+ ty. name. as_utf8_lossy ( ) ,
179
177
) ;
180
178
}
181
179
TranslateTypeResult :: PartiallyTranslated ( _, error) => {
182
180
if let Some ( error) = error {
183
181
error ! (
184
182
"Unable to parse type `{}` correctly: {error}" ,
185
- & String :: from_utf8_lossy ( & ty. name)
183
+ ty. name. as_utf8_lossy ( ) ,
186
184
) ;
187
185
} else {
188
186
warn ! (
189
187
"Type `{}` maybe not be fully translated" ,
190
- & String :: from_utf8_lossy ( & ty. name)
188
+ ty. name. as_utf8_lossy ( ) ,
191
189
) ;
192
190
}
193
191
}
@@ -200,11 +198,8 @@ pub fn import_til_section(
200
198
if let TranslateTypeResult :: Translated ( bn_ty)
201
199
| TranslateTypeResult :: PartiallyTranslated ( bn_ty, _) = & ty. ty
202
200
{
203
- if !debug_info. add_type ( String :: from_utf8_lossy ( & ty. name ) , bn_ty, & [ /* TODO */ ] ) {
204
- error ! (
205
- "Unable to add type `{}`" ,
206
- & String :: from_utf8_lossy( & ty. name)
207
- )
201
+ if !debug_info. add_type ( ty. name . as_utf8_lossy ( ) , bn_ty, & [ /* TODO */ ] ) {
202
+ error ! ( "Unable to add type `{}`" , ty. name. as_utf8_lossy( ) )
208
203
}
209
204
}
210
205
}
@@ -214,11 +209,8 @@ pub fn import_til_section(
214
209
if let TranslateTypeResult :: Translated ( bn_ty)
215
210
| TranslateTypeResult :: PartiallyTranslated ( bn_ty, _) = & ty. ty
216
211
{
217
- if !debug_info. add_type ( String :: from_utf8_lossy ( & ty. name ) , bn_ty, & [ /* TODO */ ] ) {
218
- error ! (
219
- "Unable to fix type `{}`" ,
220
- & String :: from_utf8_lossy( & ty. name)
221
- )
212
+ if !debug_info. add_type ( ty. name . as_utf8_lossy ( ) , bn_ty, & [ /* TODO */ ] ) {
213
+ error ! ( "Unable to fix type `{}`" , ty. name. as_utf8_lossy( ) )
222
214
}
223
215
}
224
216
}
@@ -273,7 +265,7 @@ fn parse_id0_section_info(
273
265
} ) ;
274
266
275
267
match ( label, & ty, bnty) {
276
- ( _, Some ( TILType :: Function ( _) ) , bnty ) => {
268
+ ( _, Some ( ty ) , bnty ) if matches ! ( & ty . type_variant , TILTypeVariant :: Function ( _) ) => {
277
269
if bnty. is_none ( ) {
278
270
error ! ( "Unable to convert the function type at {addr:#x}" , )
279
271
}
0 commit comments