util: remove function to_hex (#22792)
parent
1aebe6ff6e
commit
ff33ca3413
|
@ -194,22 +194,13 @@ float getenv(const char* key, float default_val) {
|
|||
return val ? atof(val) : default_val;
|
||||
}
|
||||
|
||||
std::string tohex(const uint8_t *buf, size_t buf_size) {
|
||||
std::unique_ptr<char[]> hexbuf(new char[buf_size * 2 + 1]);
|
||||
for (size_t i = 0; i < buf_size; i++) {
|
||||
sprintf(&hexbuf[i * 2], "%02x", buf[i]);
|
||||
std::string hexdump(const uint8_t* in, const size_t size) {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << std::setfill('0');
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
ss << std::setw(2) << static_cast<unsigned int>(in[i]);
|
||||
}
|
||||
hexbuf[buf_size * 2] = 0;
|
||||
return std::string(hexbuf.get(), hexbuf.get() + buf_size * 2);
|
||||
}
|
||||
|
||||
std::string hexdump(const std::string& in) {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << std::setfill('0');
|
||||
for (size_t i = 0; i < in.size(); i++) {
|
||||
ss << std::setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(in[i]));
|
||||
}
|
||||
return ss.str();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string dir_name(std::string const &path) {
|
||||
|
|
|
@ -66,8 +66,7 @@ std::string getenv(const char* key, const char* default_val = "");
|
|||
int getenv(const char* key, int default_val);
|
||||
float getenv(const char* key, float default_val);
|
||||
|
||||
std::string tohex(const uint8_t* buf, size_t buf_size);
|
||||
std::string hexdump(const std::string& in);
|
||||
std::string hexdump(const uint8_t* in, const size_t size);
|
||||
std::string dir_name(std::string const& path);
|
||||
|
||||
// **** file fhelpers *****
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "selfdrive/common/clutil.h"
|
||||
#include "selfdrive/common/timing.h"
|
||||
|
||||
#include "selfdrive/common/util.h"
|
||||
//#define RUN_DISASSEMBLER
|
||||
//#define RUN_OPTIMIZER
|
||||
|
||||
|
@ -21,14 +21,10 @@ map<pair<cl_kernel, int>, string> g_args;
|
|||
map<pair<cl_kernel, int>, int> g_args_size;
|
||||
map<cl_program, string> g_program_source;
|
||||
|
||||
void hexdump(uint32_t *d, int len) {
|
||||
void hexdump(uint8_t *d, int len) {
|
||||
assert((len%4) == 0);
|
||||
printf(" dumping %p len 0x%x\n", d, len);
|
||||
for (int i = 0; i < len/4; i++) {
|
||||
if (i != 0 && (i%0x10) == 0) printf("\n");
|
||||
printf("%8x ", d[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("%s\n", util::hexdump(d, len).c_str());
|
||||
}
|
||||
|
||||
// *********** ioctl interceptor ***********
|
||||
|
@ -94,10 +90,10 @@ int ioctl(int filedes, unsigned long request, void *argp) {
|
|||
struct kgsl_device_getproperty *prop = (struct kgsl_device_getproperty *)argp;
|
||||
printf("IOCTL_KGSL_SETPROPERTY: 0x%x sizebytes:%zu\n", prop->type, prop->sizebytes);
|
||||
if (thneed->record & THNEED_VERBOSE_DEBUG) {
|
||||
hexdump((uint32_t *)prop->value, prop->sizebytes);
|
||||
hexdump((uint8_t *)prop->value, prop->sizebytes);
|
||||
if (prop->type == KGSL_PROP_PWR_CONSTRAINT) {
|
||||
struct kgsl_device_constraint *constraint = (struct kgsl_device_constraint *)prop->value;
|
||||
hexdump((uint32_t *)constraint->data, constraint->size);
|
||||
hexdump((uint8_t *)constraint->data, constraint->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
#include "selfdrive/common/timing.h"
|
||||
#include "selfdrive/common/util.h"
|
||||
|
@ -216,9 +215,5 @@ std::string sha256(const std::string &str) {
|
|||
SHA256_Init(&sha256);
|
||||
SHA256_Update(&sha256, str.c_str(), str.size());
|
||||
SHA256_Final(hash, &sha256);
|
||||
std::stringstream ss;
|
||||
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
|
||||
}
|
||||
return ss.str();
|
||||
return util::hexdump(hash, SHA256_DIGEST_LENGTH);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue