[Cs-dev] Getting variable values
Date | 2014-04-08 23:23 |
From | Andres Cabrera |
Subject | [Cs-dev] Getting variable values |
Attachments | None None |
Hi, I've been working again on the csound debugger, and it's now back to working (if you want to have a look see the csdebugger branch), but one of things I want to do is show (and allow modification of) variable values. I can get the variable pool from the CSOUND struct, and the names and variables are right, but it seems that the actual memBlock pointer where data should be is always NULL. I'm wondering what's wrong...https://sourceforge.net/p/qutecsound/code/ci/master/tree/src/csoundengine.cpp#l1249 csoundDebugInstrument() is here: https://github.com/csound/csound/blob/csdebugger/Top/csdebug.c#L179 And the instrument pointer is set within the kperf function when a breakpoint is reached: https://github.com/csound/csound/blob/csdebugger/Top/csound.c#L1711 if (bp_node->instr == ip->p1) {
if (bp_node->count == 0) {
data->debug_instr_ptr = ip;
data->bkpt_cb(csound, 0, ip->p1, data->cb_data);
data->status = CSDEBUG_STATUS_STOPPED;
bp_node->count = bp_node->skip;
return 0; }
And this is within the loop that goes through active instances of instruments. ip = csound->actanchor.nxtact; [....]
Any idea what I might be doing wrong? Cheers, Andrés |
Date | 2014-04-09 03:50 |
From | Steven Yi |
Subject | Re: [Cs-dev] Getting variable values |
Hi Andres, CS_VARIABLES are used in two different ways within the system: * For global vars, the memblock actually holds the memory for the variable's data * for instrument local vars, the memBlockIndex describes how much to index into the INSDS instrument instance to get to the variable's memory. The rationale behind this is: * Moving from CS5 to CS6, it seemed to make sense to introduce the type system without changing how instrument instances are allocated. So the type system used the indexes and memBlockSize as info to use for allocation and wiring up the instances var memory to opcode arg locations. * Global vars are unique globally, while local vars are used per instance. So we used memblock to actually hold the global var's mem. This allowed easy adding of new global vars if new ones were added during multiple parses of orchestra code (i.e. live coding). I think you should be able to access the var for an instrument instance by using something like: MYFLT *varmem = ip->lclbas + var->memBlockIndex; You can then cast the varmem to other things depending on the var's type. Let me know if you have further questions! steven On Tue, Apr 8, 2014 at 6:23 PM, Andres Cabrera |
Date | 2014-04-09 05:19 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Getting variable values |
Attachments | None None |
Great, thanks, that works. Cheers,Andrés On Tue, Apr 8, 2014 at 7:50 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Andres, |
Date | 2014-04-10 20:47 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Getting variable values |
Attachments | None None |
Hi Steven, Should this be the procedure for string variables too?char *varmem = (char *) (insds->lclbas + vp->memBlockIndex); Cheers, Andrés On Tue, Apr 8, 2014 at 9:19 PM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2014-04-10 22:54 |
From | Steven Yi |
Subject | Re: [Cs-dev] Getting variable values |
Attachments | None None |
Hi Andres, I think you should cast the pointer to a STRINGDAT* instead of char*. You could then read the size and data from there. Let me know how that goes! On Apr 10, 2014 3:47 PM, "Andres Cabrera" <mantaraya36@gmail.com> wrote:
|
Date | 2014-04-10 23:07 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Getting variable values |
Attachments | None None |
Thanks, that worked perfectly. Cheers, Andrés On Thu, Apr 10, 2014 at 2:54 PM, Steven Yi <stevenyi@gmail.com> wrote:
|