本文整理汇总了C++中Trace::addSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ Trace::addSegment方法的具体用法?C++ Trace::addSegment怎么用?C++ Trace::addSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trace
的用法示例。
在下文中一共展示了Trace::addSegment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Trace * Trace::load_project_file(const char * filename)
{
XMLBZIP2_reader reader;
xmlDocPtr doc = reader.xmlReadDoc(filename);
if (doc == NULL) {
fprintf(stderr, "Failed to parse %s\n", filename);
return NULL;
}
// Todo - make it actually load the architecture on demand
Trace * t = new Trace(new ARMArchitecture());
xmlNodePtr root_element = xmlDocGetRootElement(doc);
xmlNodePtr memories_n = findChild(root_element, "memblocks");
if (!memories_n)
{
printf("could not find memblocks section, aborting!\n");
return NULL;
}
xmlNodePtr memory_n = findChild(memories_n, "memory");
if (!memory_n)
{
printf("could not load memory, aborting!\n");
return NULL;
}
xmlNodePtr memory_base_n = findChild(memory_n, "base");
if (!memory_base_n)
{
printf("could not find memory base address, aborting!\n");
return NULL;
}
address_t base_addr = strtoul((char *) xmlNodeGetContent(memory_base_n), NULL, 16);
xmlNodePtr memory_data_n = findChild(memory_n, "data");
if (!memory_n)
{
printf("could not find memory data, aborting!\n");
return NULL;
}
char * base64_content = (char*)xmlNodeGetContent(memory_data_n);
int base64_len = strlen(base64_content);
char * code_buf;
size_t code_len;
bool ok = base64_decode_alloc (base64_content, base64_len, &code_buf, &code_len);
xmlFree(base64_content);
if (!ok)
{
printf("could not parse memory data, aborting!\n");
return NULL;
}
MemSegment * m = new MemSegment(base_addr, code_len, code_buf);
t->addSegment(m);
free(code_buf);
xmlNodePtr instructions_n = findChild(root_element, "instructions");
if (instructions_n)
for(xmlNodePtr node_a = instructions_n->children; node_a != NULL; node_a = node_a->next) {
u32 addr;
u32 opcode;
bool good = false;
bool opcodeset = false;
//printf("node %s\n", node_a->name);
for(xmlNodePtr node_b = node_a->children; node_b != NULL; node_b = node_b->next) {
char * content = (char *) xmlNodeGetContent(node_b);
if (!content)
continue;
if (xmlStrcmp(node_b->name, BAD_CAST "addr") == 0)
{
good = true;
addr = strtoul(content, NULL, 16);
}
else if (xmlStrcmp(node_b->name, BAD_CAST "opcode") == 0)
{
opcode = strtoul(content, NULL, 16);
opcodeset = true;
}
xmlFree(content);
}
if (!opcodeset)
opcode = t->ldw(addr);
if (good)
{
// fixme
Instruction * inst = t->m_arch->create_instruction(t, addr);//new Instruction(t, addr, opcode);
t->insert_memlocd(inst);
//.........这里部分代码省略.........