Can XDC script get a list of names of functions in a module? [message #499077] |
Thu, 19 November 2009 13:04  |
Eclipse User |
|
|
|
In CCStudio, you can create a GEL script that can define aliases for long function names:
e.g.
#define Log_write xdc_runtime_Log_write__F
Once CCStudio has loaded this script, you can use the short module name to set breakpoints or to view the code in the disassembly view, memory view or whatever instead of having to type in the fully qualified name with a __F appended to it.
I'd like to create an xs script that auto-generates a GEL file that has #define statements for all of the functions in the package I'm developing, but I haven't been able to find a way to get the function names. Is there a way to access a list of function names from within an .xs script?
Regards,
Brian
|
|
|
|
|
Re: Can XDC script get a list of names of functions in a module? [message #505240 is a reply to message #502473] |
Mon, 28 December 2009 16:03   |
Eclipse User |
|
|
|
comments below
Brian Cruickshank wrote:
> Thanks Dave, that works very well. The attached script function can be
> called from a package.xs file's close() function to generate a GEL file
> that defines short name aliases for functions in a RTSC program. It
> helps make debugging a package's functions in CCS a bit easier.
Cool.
BTW: in your script, the following loop:
while (strLongModName.indexOf('.') > 0) {
strLongModName = strLongModName.replace(".", "_");
}
can be replaced by a single line:
strLongModName = strLongModName.replace(/\./g, "_");
The JavaScript replace() function can take a regular expression and this
regular expression can be applied "globally".
Also, the variable modName is unused.
> Is there a way to determine the type names that have been defined so
> that the GEL script can be extended to define short name aliases for
> types as well?
I don't know what type names would be useful to GEL, but the types
defined for any module are described by the "Module Binary Contract";
see
http://rtsc.eclipse.org/docs-tip/C_Language_Binding#Module_B inary_Contract
Of course, just like getting a module's functions, you can get all of
the types declared by a module via its $spec object. For example:
var Mod = xdc.module("my.fav.Mod");
var decls = Mod.$spec.getDecls().toArray();
for (var i = 0; i < decls.length; i++) {
var decl = decls[i];
if (decl.isMeta()) {
continue; /* skip meta-only decls */
}
var name = decl.getName();
if ("getTypeSig" in decl) {
print(name + ": " + decl.getTypeSig());
}
else if (decl instanceof Packages.xdc.services.spec.Decl.Struct) {
: /* handle structure decl */
}
}
}
>Should I add any __V or whatever suffixes to the long
> names for the types??
>
> e.g. #define Types_Timestamp64 xdc_runtime_Types_Timestamp64 #define
> LoggerBuf_Object xdc_runtime_LoggerBuf_Object
> etc.
>
> Regards,
> Brian
>
|
|
|
Re: Can XDC script get a list of names of functions in a module? [message #505265 is a reply to message #505240] |
Mon, 28 December 2009 16:52  |
Eclipse User |
|
|
|
One more note about the posted script: I notice that you are filtering
declarations based on their names. For example:
strFuncName = f.getName();
if (strFuncName.indexOf("__") < 0) {
strShortDeclName = strShortModName + "_" + strFuncName;
if (strShortDeclName.indexOf("_Module_") < 0) {
:
}
}
You probably mean to use the isSys() method of a Decl instead. For example:
strFuncName = f.getName();
if (!f.isSys()) {
strShortDeclName = strShortModName + "_" + strFuncName;
:
}
On 12/28/2009 1:03 PM, dave russo wrote:
> comments below
>
> Brian Cruickshank wrote:
>> Thanks Dave, that works very well. The attached script function can be
>> called from a package.xs file's close() function to generate a GEL
>> file that defines short name aliases for functions in a RTSC program.
>> It helps make debugging a package's functions in CCS a bit easier.
> Cool.
>
> BTW: in your script, the following loop:
> while (strLongModName.indexOf('.') > 0) {
> strLongModName = strLongModName.replace(".", "_");
> }
>
> can be replaced by a single line:
> strLongModName = strLongModName.replace(/\./g, "_");
>
> The JavaScript replace() function can take a regular expression and this
> regular expression can be applied "globally".
>
> Also, the variable modName is unused.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03850 seconds