new error code

updated reader for new section
added 2 new functs to VM API

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4052
This commit is contained in:
Borja Ferrer 2006-08-01 23:40:32 +00:00
parent c23a23fb34
commit 3696dade01
3 changed files with 34 additions and 21 deletions

View File

@ -16,6 +16,7 @@ typedef int32_t cell_t;
#define SP_ERR_PARAM 4 /* Invalid parameter */
#define SP_ERR_INVALID_ADDRESS 5 /* A memory address was not valid */
#define SP_ERR_NOT_FOUND 6 /* The object in question was not found */
#define SP_ERR_INDEX 7 /* Invalid index parameter */
/**********************************************
*** The following structures are reference structures.

View File

@ -39,10 +39,6 @@ sp_plugin_t *_ReadPlugin(sp_file_hdr_t *hdr, uint8_t *base, sp_plugin_t *plugin,
plugin->data_size = dat->datasize;
plugin->memory = dat->memsize;
}
else if (!(plugin->info->stringbase) && !strcmp(nameptr, ".names"))
{
plugin->info->stringbase = base + secptr->dataoffs;
}
else if (!(plugin->info->publics) && !strcmp(nameptr, ".publics"))
{
plugin->info->publics_num = secptr->size / sizeof(sp_file_publics_t);
@ -58,25 +54,34 @@ sp_plugin_t *_ReadPlugin(sp_file_hdr_t *hdr, uint8_t *base, sp_plugin_t *plugin,
plugin->info->natives_num = secptr->size / sizeof(sp_file_natives_t);
plugin->info->natives = (sp_file_natives_t *)(base + secptr->dataoffs);
}
else if (!(plugin->info->stringbase) && !strcmp(nameptr, ".names"))
{
plugin->info->stringbase = base + secptr->dataoffs;
}
else if (!(plugin->debug->files) && !strcmp(nameptr, ".dbg.files"))
{
plugin->debug->files_num = secptr->size / sizeof(sp_fdbg_file_t);
plugin->debug->files = (sp_fdbg_file_t *)(base + secptr->dataoffs);
}
else if (!(plugin->debug->lines) && !strcmp(nameptr, ".dbg.lines"))
{
plugin->debug->lines = (sp_fdbg_line_t *)(base + secptr->dataoffs);
}
else if (!(plugin->debug->symbols) && !strcmp(nameptr, ".dbg.symbols"))
{
plugin->debug->symbols = (sp_fdbg_symbol_t *)(base + secptr->dataoffs);
}
else if (!(plugin->debug->lines_num) && !strcmp(nameptr, ".dbg.info"))
{
sp_fdbg_info_t *inf = (sp_fdbg_info_t *)(base + secptr->dataoffs);
plugin->debug->files_num = inf->num_files;
plugin->debug->lines_num = inf->num_lines;
plugin->debug->syms_num = inf->num_syms;
}
else if (!(plugin->debug->stringbase) && !strcmp(nameptr, ".dbg.strings"))
{
plugin->debug->stringbase = base + secptr->dataoffs;
}
else if (!(plugin->debug->lines) && !strcmp(nameptr, ".dbg.lines"))
{
plugin->debug->lines_num = secptr->size / sizeof(sp_fdbg_line_t);
plugin->debug->lines = (sp_fdbg_line_t *)(base + secptr->dataoffs);
}
else if (!(plugin->debug->symbols) && !strcmp(nameptr, ".dbg.symbols"))
{
plugin->debug->syms_num = secptr->size / sizeof(sp_fdbg_symbol_t);
plugin->debug->symbols = (sp_fdbg_symbol_t *)(base + secptr->dataoffs);
}
secptr++;
sectnum++;
}

View File

@ -146,11 +146,18 @@ int SP_GetPubvarByIndex(sp_context_t *ctx, uint32_t index, sp_pubvar_t **pubvar)
* @param local_addr Optionally filled with local address offset.
* @param phys_addr Optionally filled with relocated physical address.
*/
int SP_FindPubvarByName(sp_context_t *ctx,
const char *name,
uint32_t *index,
cell_t *local_addr,
cell_t **phys_addr);
int SP_FindPubvarByName(sp_context_t *ctx, const char *name, uint32_t *index);
//:TODO: fill in the info of this function, hi
int SP_GetPubvarAddrs(sp_context_t *ctx, uint32_t index, cell_t *local_addr, cell_t **phys_addr);
/**
* Gets the number of public variables.
*
* @param ctx Context pointer.
* @param num Filled with the number of public variables.
*/
int SP_GetPubVarsNum(sp_context_t *ctx, uint32_t *num);
/**
* Round-about method of converting a plugin reference to a physical address
@ -162,7 +169,7 @@ int SP_FindPubvarByName(sp_context_t *ctx,
int SP_LocalToPhysAddr(sp_context_t *ctx, cell_t local_addr, cell_t **phys_addr);
/**
* Convers a local address to a physical string.
* Converts a local address to a physical string.
* Note that SourcePawn does not support packed strings, as such this function is
* 'cell to char' only.
*