Skip to content

Commit 7158b61

Browse files
GustavoLCRwargio
authored andcommitted
Fix pdb.autoload crash (#2729)
1 parent 9a753ea commit 7158b61

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

librz/debug/p/debug_native.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,19 @@ static RzDebugReasonType rz_debug_native_wait(RzDebug *dbg, int pid) {
324324
bool autoload_pdb = dbg->corebind.cfggeti(core, "pdb.autoload");
325325
if (autoload_pdb) {
326326
PLIB_ITEM lib = r->lib;
327-
dbg->corebind.cmdf(core, "\"o \\\"%s\\\" 0x%p\"", lib->Path, lib->BaseOfDll);
328-
char *o_res = dbg->corebind.cmdstrf(core, "o~+%s", lib->Name);
329-
int fd = atoi(o_res);
330-
free(o_res);
331-
if (fd) {
332-
char *pdb_file = dbg->corebind.cmdstr(core, "i~dbg_file");
333-
if (pdb_file && (rz_str_trim(pdb_file), *pdb_file)) {
334-
if (!rz_file_exists(pdb_file + 9)) {
327+
RzBinOptions opts = { 0 };
328+
opts.obj_opts.baseaddr = (uintptr_t)lib->BaseOfDll;
329+
RzBinFile *cur = rz_bin_cur(core->bin);
330+
RzBinFile *bf = rz_bin_open(core->bin, lib->Path, &opts);
331+
if (bf) {
332+
const RzBinInfo *info = rz_bin_object_get_info(bf->o);
333+
if (RZ_STR_ISNOTEMPTY(info->debug_file_name)) {
334+
if (!rz_file_exists(info->debug_file_name)) {
335335
dbg->corebind.cmdf(core, "idpd");
336336
}
337-
dbg->corebind.cmdf(core, "idp");
337+
dbg->corebind.cmd(core, "idp");
338338
}
339-
dbg->corebind.cmdf(core, "o-%d", fd);
339+
rz_bin_file_set_cur_binfile(core->bin, cur);
340340
}
341341
}
342342
} else {

0 commit comments

Comments
 (0)