Skip to content

Commit

Permalink
-Add symbols and encoding mappings. WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-gomez-windhover committed Aug 30, 2024
1 parent cbfad85 commit c724902
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
2 changes: 2 additions & 0 deletions juicer.files
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ src/ElfFile.cpp
src/ElfFile.h
src/ElfSection.cpp
src/ElfSection.h
src/Encoding.cpp
src/Encoding.h
src/Enumeration.cpp
src/Enumeration.h
src/Field.cpp
Expand Down
5 changes: 5 additions & 0 deletions src/Encoding.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "Encoding.h"

Encoding::Encoding(std::string name) : name{name} {}

Encoding::Encoding() {}
17 changes: 17 additions & 0 deletions src/Encoding.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef ENCODING_H
#define ENCODING_H

#include <string>

class Encoding
{
public:
Encoding(std::string name);
Encoding();

private:
std::string name;
int id;
};

#endif // ENCODING_H
40 changes: 39 additions & 1 deletion src/SQLiteDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,22 @@ int SQLiteDB::createSchemas(void)
if (SQLITE_OK == rc)
{
logger.logDebug(
"createElfSectionsSchema() created the variables schema "
"createElfSymbolTableSchema() created the variables schema "
"successfully.");

rc = createEncodingsTableSchema();

if (SQLITE_OK == rc)
{
logger.logDebug(
"createEncodingsTableSchema() created the variables schema "
"successfully.");
}
else
{
logger.logDebug("createEncodingsTableSchema() failed.");
rc = SQLITEDB_ERROR;
}
}
else
{
Expand Down Expand Up @@ -1789,3 +1803,27 @@ int SQLiteDB::createElfSymbolTableSchema(void)

return rc;
}

int SQLiteDB::createEncodingsTableSchema(void)
{
std::string createEncodingsTableQuery{CREATE_ENCODINGS_TABLE};

int rc = SQLITE_OK;

/*@todo The last argument for sqlite3_exec is an error handler that is not
* necessary to pass in, but I really think we should for better error
* logging.*/
rc = sqlite3_exec(database, createEncodingsTableQuery.c_str(), NULL, NULL, NULL);

if (SQLITE_OK == rc)
{
logger.logDebug("Created table \"artifacts\" with OK status");
}
else
{
logger.logError("Failed to create the artifacts table. '%s'", sqlite3_errmsg(database));
rc = SQLITEDB_ERROR;
}

return rc;
}
7 changes: 7 additions & 0 deletions src/SQLiteDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
FOREIGN KEY (elf) REFERENCES elfs(id),\
UNIQUE (name, type, elf));"

#define CREATE_ENCODINGS_TABLE \
"CREATE TABLE IF NOT EXISTS encodings(\
id INTEGER PRIMARY KEY,\
encoding TEXT NOT NULL,\
UNIQUE (encoding));"

//#define CREATE_DATA_OBJECTS_TABLE \
// "CREATE TABLE IF NOT EXISTS data_objects(\
// id INTEGER PRIMARY KEY,\
Expand Down Expand Up @@ -185,6 +191,7 @@ class SQLiteDB : public IDataContainer
int createVariablesSchema(void);
int createElfSectionsSchema(void);
int createElfSymbolTableSchema(void);
int createEncodingsTableSchema(void);
int writeElfToDatabase(ElfFile &inModule);
int writeMacrosToDatabase(ElfFile &inModule);
int writeVariablesToDatabase(ElfFile &inModule);
Expand Down
3 changes: 3 additions & 0 deletions src/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Artifact.h"
#include "DimensionList.h"
#include "ElfFile.h"
#include "Encoding.h"
#include "Enumeration.h"
#include "Field.h"
#include "Logger.h"
Expand Down Expand Up @@ -81,6 +82,8 @@ class Symbol

std::string short_description;
std::string long_description;

Encoding encoding;
};

#endif /* SYMBOL_H_ */

0 comments on commit c724902

Please sign in to comment.