Skip to content

Commit

Permalink
Merge pull request #95 from devenrao/core
Browse files Browse the repository at this point in the history
POZ : revert avoid double memory allocation for ffdc data
  • Loading branch information
aravynd authored Apr 24, 2024
2 parents 928eee5 + c37fac5 commit 8288f4c
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions libpdbg/sbe_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,14 @@ int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock,
}

int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc,
uint32_t *ffdc_len)
uint32_t *ffdc_len)
{
if(!is_ody_ocmb_chip(target)) {
struct chipop *chipop = pib_to_chipop(target);
struct chipop *chipop;
const uint8_t *data = NULL;
uint32_t len = 0;

chipop = pib_to_chipop(target);
if (!chipop)
return -1;

Expand All @@ -225,10 +229,23 @@ int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc,
return -1;
}

*status = chipop->ffdc_get(chipop, (const uint8_t**)ffdc, ffdc_len);
*status = chipop->ffdc_get(chipop, &data, &len);
if (data && len > 0) {
*ffdc = malloc(len);
assert(*ffdc);
memcpy(*ffdc, data, len);
*ffdc_len = len;
} else {
*ffdc = NULL;
*ffdc_len = 0;
}
} else {
struct chipop_ody *chipop;
const uint8_t *data = NULL;
uint32_t len = 0;

struct pdbg_target *co_target = get_ody_chipop_target(target);
struct chipop_ody *chipop = target_to_chipop_ody(co_target);
chipop = target_to_chipop_ody(co_target);
if (!chipop) {
PR_ERROR("chipop target not found for ody ocmb chip\n");
return -1;
Expand All @@ -237,14 +254,21 @@ int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc,
PR_ERROR("ffdc_get() not implemented for the target\n");
return -1;
}

struct pdbg_target *fsi = get_ody_fsi_target(target);

if (!fsi) {
PR_ERROR("fsi target not found for ody ocmb chip\n");
return -1;
}
*status = chipop->ffdc_get(chipop, fsi, (const uint8_t**)ffdc, ffdc_len);
*status = chipop->ffdc_get(chipop, fsi, &data, &len);
if (data && len > 0) {
*ffdc = malloc(len);
assert(*ffdc);
memcpy(*ffdc, data, len);
*ffdc_len = len;
} else {
*ffdc = NULL;
*ffdc_len = 0;
}
}
return 0;
}
Expand Down

0 comments on commit 8288f4c

Please sign in to comment.