Author: cwittich
Date: Mon Sep 22 05:51:36 2008
New Revision: 36399
URL:
http://svn.reactos.org/svn/reactos?rev=36399&view=rev
Log:
-add missing raddr2line.c
-fix some memory leaks
Added:
trunk/tools/sysreg2/raddr2line.c (with props)
Modified:
trunk/tools/sysreg2/options.c
trunk/tools/sysreg2/virt.c
Modified: trunk/tools/sysreg2/options.c
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/options.c?rev=36399&…
==============================================================================
--- trunk/tools/sysreg2/options.c [iso-8859-1] (original)
+++ trunk/tools/sysreg2/options.c [iso-8859-1] Mon Sep 22 05:51:36 2008
@@ -29,6 +29,8 @@
{
strncpy(AppSettings.Filename, obj->stringval, 254);
}
+ if (obj)
+ xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST"string(/settings/@vm)",ctxt);
if ((obj != NULL) && ((obj->type == XPATH_STRING) &&
@@ -36,6 +38,8 @@
{
strncpy(AppSettings.Name, obj->stringval, 79);
}
+ if (obj)
+ xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST"number(/settings/general/timeout/@ms)",ctxt);
if ((obj != NULL) && (obj->type == XPATH_NUMBER))
@@ -44,6 +48,8 @@
* which means infinite */
AppSettings.Timeout = (int)obj->floatval;
}
+ if (obj)
+ xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST"number(/settings/general/hdd/@size)",ctxt);
if ((obj != NULL) && (obj->type == XPATH_NUMBER))
@@ -53,6 +59,8 @@
else
AppSettings.ImageSize = (int)obj->floatval;
}
+ if (obj)
+ xmlXPathFreeObject(obj);
for (Stage=0;Stage<3;Stage++)
{
@@ -65,6 +73,8 @@
{
strncpy(AppSettings.Stage[Stage].BootDevice, obj->stringval, 7);
}
+ if (obj)
+ xmlXPathFreeObject(obj);
strcpy(TempStr, "string(/settings/");
strcat(TempStr, StageNames[Stage]);
strcat(TempStr, "/success/@on)");
@@ -74,6 +84,8 @@
{
strncpy(AppSettings.Stage[Stage].Checkpoint, obj->stringval, 79);
}
+ if (obj)
+ xmlXPathFreeObject(obj);
}
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
@@ -94,6 +106,8 @@
{
strncpy(AppSettings.HardDiskImage, obj->stringval, 254);
}
+ if (obj)
+ xmlXPathFreeObject(obj);
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
Added: trunk/tools/sysreg2/raddr2line.c
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/raddr2line.c?rev=363…
==============================================================================
--- trunk/tools/sysreg2/raddr2line.c (added)
+++ trunk/tools/sysreg2/raddr2line.c [iso-8859-1] Mon Sep 22 05:51:36 2008
@@ -1,0 +1,86 @@
+#include "sysreg.h"
+
+bool GetPackagePath(char* Buffer, int BuffSize, char* Module)
+{
+ char* ptr;
+ FILE* fp;
+ int i;
+
+ fp = fopen("boot/bootdata/packages/reactos.dff", "r");
+ if (fp)
+ {
+ while(fgets(Buffer, BuffSize,fp))
+ {
+ if (strstr(Buffer, Module))
+ {
+ ptr = strchr(Buffer, ' ');
+ if (ptr)
+ *ptr = '\0';
+
+ for (i = 0; i < strlen(Buffer); i++)
+ {
+ if (Buffer[i] == '\\')
+ Buffer[i] = '/';
+ }
+ fclose(fp);
+ return true;
+ }
+ }
+ fclose(fp);
+ }
+ return false;
+}
+
+bool ResolveAddressFromFile(char* Buffer, int BuffSize, char* Data)
+{
+ char* sep;
+ char* sep2;
+ char Module[32];
+ char Addr[20];
+ char Command[256];
+ char PkgData[80];
+ char emptystr[] = "";
+
+ if ((strchr(Data, '>')) && (!strchr(Data, ')')))
+ {
+ sep = strchr(Data, ':');
+ if (sep)
+ {
+ strncpy(Module, Data + 1, (int) (sep - Data) - 1);
+ Module[(int)(sep-Data)-2] = '\0';
+ sep2 = strchr(Data, '>');
+ strncpy(Addr, Data + (sep - Data + 1), (int) (sep2 - sep) -1);
+ Addr[(int)(sep2- sep)-1] = '\0';
+
+ if (GetPackagePath(PkgData, sizeof(PkgData), Module))
+ {
+ const char* outdir = getenv("ROS_OUTPUT");
+ char* ptr;
+ if (!outdir)
+ outdir = emptystr;
+ sprintf(Command, "%s/tools/raddr2line %s/%s %s 2>&1",
+ outdir, outdir, PkgData, Addr);
+ FILE* p = popen(Command, "r");
+ char buf[100] = {'\0'};
+ while(feof(p)==0)
+ {
+ fgets(buf,100,p);
+ if (strstr(buf, "error"))
+ strcpy(buf, "(no debug info)");
+ ptr = strchr(buf, '\n');
+ if (ptr)
+ *ptr = '\0';
+ ptr = strchr(Data, '>');
+ if (ptr)
+ *ptr = '\0';
+ strcpy(Buffer, Data);
+ strcat(Buffer, " ");
+ strcat(Buffer, buf);
+ strcat(Buffer, ">\n");
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
Propchange: trunk/tools/sysreg2/raddr2line.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/tools/sysreg2/virt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/virt.c?rev=36399&…
==============================================================================
--- trunk/tools/sysreg2/virt.c [iso-8859-1] (original)
+++ trunk/tools/sysreg2/virt.c [iso-8859-1] Mon Sep 22 05:51:36 2008
@@ -1,38 +1,41 @@
#include "sysreg.h"
#include <libvirt.h>
-const char* GetConsole(virDomainPtr vDomPtr)
+bool GetConsole(virDomainPtr vDomPtr, char* console)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
char* XmlDoc;
- const char* RetVal = NULL;
+ bool RetVal = false;
XmlDoc = virDomainGetXMLDesc(vDomPtr, 0);
if (!XmlDoc)
- return NULL;
+ return false;
xml = xmlReadDoc((const xmlChar *) XmlDoc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
free(XmlDoc);
if (!xml)
- return NULL;
+ return false;
ctxt = xmlXPathNewContext(xml);
if (!ctxt)
{
xmlFreeDoc(xml);
- return NULL;
+ return false;
}
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt);
if ((obj != NULL) && ((obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] !=
0)))
{
- RetVal = (const char*)obj->stringval;
- }
+ strcpy(console, obj->stringval);
+ RetVal = true;
+ }
+ if (obj)
+ xmlXPathFreeObject(obj);
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
@@ -66,11 +69,13 @@
if (strcasecmp(name, domname) == 0)
{
virDomainFree(vDomPtr);
+ free(ids);
return true;
}
virDomainFree(vDomPtr);
}
}
+ free(ids);
return false;
}
@@ -105,12 +110,13 @@
{
xmlSetProp(obj->nodesetval->nodeTab[0], "dev", BootDevice);
}
+ if (obj)
+ xmlXPathFreeObject(obj);
free(buffer);
xmlDocDumpMemory(xml, (xmlChar**) &buffer, &len);
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
- xmlXPathFreeObject(obj);
virDomainPtr vDomPtr = virDomainDefineXML(vConn, buffer);
xmlFree((xmlChar*)buffer);
@@ -146,6 +152,7 @@
FILE* file;
char config[255];
int Ret = EXIT_SUCCESS;
+ char console[50];
if (argc == 2)
strcpy(config, argv[1]);
@@ -193,7 +200,8 @@
printf("\n\n\n");
printf("Running stage %d...\n", Stage + 1);
printf("Domain %s started.\n", virDomainGetName(vDom));
- if (!ProcessDebugData(GetConsole(vDom),
+ GetConsole(vDom, console);
+ if (!ProcessDebugData(console,
AppSettings.Timeout, Stage))
{
Ret = EXIT_FAILURE;