Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POZ : revert avoid double memory allocation for ffdc data #95

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading