[Vala] Debugging program xml-rpc-c bindings?



Although I can retrieve the xml-rpc data using pancake's xmlrpc_c bindings the program aborts at the end as it trys to free the memory used I guess? Clutching at straws - wonder if anyone can make sense of this output from gdb - perhaps a bug in xml-rpc-c or the bindings? Same result in vala and genie.


(gdb) run
Starting program: /initrd/mnt/dev_save/my-applications/POSLogic/POSLogic
[New Thread 0xb78deb70 (LWP 9942)]
[Thread 0xb78deb70 (LWP 9942) exited]

An Array of [5] elements

  component [0] of array =
 a string: (AUD)

  component [1] of array =
 a string: (CHF)

  component [2] of array =
 a string: (EUR)

  component [3] of array =
 a string: (GBP)

  component [4] of array =
 a string: (USD)


Program received signal SIGABRT, Aborted.
0xb7cc6607 in raise () from /lib/libc.so.6
(gdb) backtrace
#0  0xb7cc6607 in raise () from /lib/libc.so.6
#1  0xb7cc9ab2 in abort () from /lib/libc.so.6
#2  0xb7c91a2a in xmlrpc_abort_if_array_bad (arrayP=0x80c3110)
    at xmlrpc_array.c:43
#3  0xb7c91a70 in xmlrpc_destroyArrayContents (arrayP=0x80c3110)
    at xmlrpc_array.c:64
#4  0xb7c8efa8 in destroyValue (valueP=0x80c3110) at xmlrpc_data.c:44
#5  xmlrpc_DECREF (valueP=0x80c3110) at xmlrpc_data.c:106
#6  0x08049d92 in update_currencies ()
#7  0x08049927 in _vala_main ()
#8  0x080499c6 in main ()
(gdb)


Extract of the genie program:

def update_currencies(ref SQL:SQLiteO, ref Config: dict of string, string) :void
        
        /*XmlRpc objects required for the xml-rpc session defined */
XClient: XmlRpc.Client /*This is the client object created by the Client Create */
        XEnv: XmlRpc.Env = XmlRpc.Env() /* This is the XmlRpc Env struct */
XServer: XmlRpc.ServerInfo* = new XmlRpc.ServerInfo (XEnv, Config["webERPXmlRpcServer"])
        /*initialise the xml-rpc client session */
        /*variables for the setup of the xml-rpc session */
        ProgramName:string = "POSLogic XML-RPC Update Currencies"
        ProgramVersion:string = "0.00001"
        XmlRpc.Client.init (0, ProgramName, ProgramVersion)
XmlRpc.Client.create (XEnv, 0, ProgramName, ProgramVersion, null, 0, out XClient)
        if XEnv.fault_occurred
print "Setting the properties of the xml-rpc server failed with the message: %s fault code: %d", XEnv.fault_string, XEnv.fault_code
                Thread.exit (null)

        var XQuery = new XmlRpc.Array(XEnv)
    /*XML-RPC call the method
                       weberp.xmlrpc_GetCurrencyList
this method requires 2 strings as parameters - all put into the new XQuery array
                      in sequence 0, 1
                                username
                                password
                                
This method returns a structure containing an array of currency codes:
         key "currcode" (currency codes)
                 */                                                             
        XQuery.append_item (XEnv, XEnv.string_new (Config["webERPUser"]))
        XQuery.append_item (XEnv, XEnv.string_new (Config["webERPPassword"]))
        
        XReturnValue: XmlRpc.Value

        ArraySize: int
        XmlRpcReturnError: int
        i:int = 0
        /* Now do the actual xml-rpc call */    
XClient.call2 (XEnv, XServer, " weberp.xmlrpc_GetCurrencyList", XQuery, out XReturnValue)

        if XEnv.fault_occurred
                print "Oops.. fault happened (%s)\n", XEnv.fault_string
        else
                print_value(XEnv,XReturnValue)





def private print_value(XEnv:XmlRpc.Env, XValue:XmlRpc.Value)

/*a recursive function that prints out the contents of the returned XML-RPC call */

    /*Define all the variables used in the function */
        i:int =0
        XItem:XmlRpc.Value
        XArray:XmlRpc.Array
        ArraySize:int
        XStruct:XmlRpc.Struct
        ReturnedString: string
        ReturnedNumber:int
        XStructValue: XmlRpc.Value
        DataType:XmlRpc.Type = XValue.type ()
        /*How we deal with the data depends on the type of data */
        case (DataType)
                when XmlRpc.Type.ARRAY
                        /* Cast the XValue into an XmlRpc.Array */
                        XArray =  (XmlRpc.Array) XValue
                        ArraySize = XArray.size(XEnv)
                        print "An Array of [%d] elements\n", ArraySize
                        /*for loop would be preferable here but it is not an iterable collection
                          the next item in the array needs to be got with get_item method*/
                        while i < ArraySize
                                XItem = XArray.get_item (XEnv, i)
                                print "  component [%d] of array = ", i
                                /* function calls itself recursively */
                                print_value (XEnv, XItem)
                                i++
                when XmlRpc.Type.INT
                        XEnv.read_int(XValue, out ReturnedNumber)
                        print " an integer: (%d)\n", ReturnedNumber
                when XmlRpc.Type.STRING
                        XEnv.read_string (XValue, out ReturnedString)
                        print " a string: (%s)\n", ReturnedString
                when XmlRpc.Type.STRUCT
                        XStruct = (XmlRpc.Struct) XValue
                        print "Struct size: %d", XStruct.size(XEnv)
                default
                        print "Unknown data type %d\n", DataType



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]