Skip to content

Commit

Permalink
xtest: stats: rely on exported PTA API header file
Browse files Browse the repository at this point in the history
Rely on pta_stats.h header file for the statistics PTA API definition
rather than using a local definition.

Reviewed-by: Jerome Forissier <[email protected]>
Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Dec 5, 2023
1 parent 1033462 commit 8b74e85
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions host/xtest/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <errno.h>
#include <fnmatch.h>
#include <inttypes.h>
#include <pta_stats.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Expand All @@ -21,33 +22,6 @@
#include "xtest_test.h"
#include "stats.h"

#define STATS_UUID { 0xd96a5b40, 0xe2c7, 0xb1af, \
{ 0x87, 0x94, 0x10, 0x02, 0xa5, 0xd5, 0xc6, 0x1b } }

#define STATS_CMD_PAGER_STATS 0
#define STATS_CMD_ALLOC_STATS 1
#define STATS_CMD_MEMLEAK_STATS 2
#define STATS_CMD_TA_STATS 3
#define STATS_CMD_GET_TIME 4

#define TEE_ALLOCATOR_DESC_LENGTH 32
struct malloc_stats {
char desc[TEE_ALLOCATOR_DESC_LENGTH];
uint32_t allocated; /* Bytes currently allocated */
uint32_t max_allocated; /* Tracks max value of allocated */
uint32_t size; /* Total size for this allocator */
uint32_t num_alloc_fail; /* Number of failed alloc requests */
uint32_t biggest_alloc_fail; /* Size of biggest failed alloc */
uint32_t biggest_alloc_fail_used; /* Alloc bytes when above occurred */
};

struct ta_dump_stats {
TEEC_UUID uuid;
uint32_t panicked; /* True if TA has panicked */
uint32_t sess_count; /* Number of opened session */
struct malloc_stats heap;
};

static int usage(void)
{
fprintf(stderr, "Usage: %s --stats [OPTION]\n", xtest_progname);
Expand Down Expand Up @@ -130,7 +104,7 @@ static int stat_alloc(int argc, char *argv[])
TEEC_Result res = TEEC_ERROR_GENERIC;
uint32_t eo = 0;
TEEC_Operation op = { };
struct malloc_stats *stats = NULL;
struct pta_stats_alloc *stats = NULL;
size_t stats_size_bytes = 0;
size_t n = 0;

Expand Down Expand Up @@ -226,7 +200,7 @@ static int stat_loaded_ta(int argc, char *argv[])
uint32_t eo = 0;
TEEC_Operation op = { };
void *buff = NULL;
struct ta_dump_stats *stats = NULL;
struct pta_stats_ta *stats = NULL;
size_t stats_size_bytes = 0;
size_t n = 0;
uint32_t retry_count = 10;
Expand Down Expand Up @@ -293,7 +267,7 @@ static int stat_loaded_ta(int argc, char *argv[])
stats[n].uuid.clockSeqAndNode[7]);
printf("\tpanicked(%"PRId32") -- True if TA has panicked\n",
stats[n].panicked);
printf("\tsession number(%"PRId32")\n", stats[n].sess_count);
printf("\tsession number(%"PRId32")\n", stats[n].sess_num);
printf("\tHeap Status:\n");
printf("\t\tBytes allocated: %"PRId32"\n",
stats[n].heap.allocated);
Expand Down

0 comments on commit 8b74e85

Please sign in to comment.