[PIC] MPLABX | XC8 - watching variables in multiple modules

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PIC] MPLABX | XC8 - watching variables in multiple modules

K S-7
Hello list.

I am debugging an XC8 program with lots of modules in MPLABX 5.35.

Various modules have variables that have the same name. For example I
have a SCI1 and SCI2 module, both containing a variable called rx_buf.
These variables are global within the module but not within the whole
project (declared as "static type name"). The program compiles and
functions properly.

However during debug I cannot watch these variables properly. Only one
variable is properly shown within any watch window, the other will
show as "undefined" or as a copy of the other one. When debugging
within a module I would expect the variable in scope to show up in a
watch or when hovered over, but this is not the case.

Has anyone encountered this? And found any workaround?

TIA. Cheers all.
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Jim
Reply | Threaded
Open this post in threaded view
|

RE: [PIC] MPLABX | XC8 - watching variables in multiple modules

Jim

Rename the variables with a 1 or 2 so they are seperate and distinct.
And you'll know which module each is working with at a glance.
Regards,

Jim

> -------- Original Message --------
> Subject: [PIC] MPLABX | XC8 - watching variables in multiple modules
> From: K S <[hidden email]>
> Date: Tue, July 07, 2020 2:18 am
> To: "Microcontroller discussion list - Public." <[hidden email]>
>
>
> Hello list.
>
> I am debugging an XC8 program with lots of modules in MPLABX 5.35.
>
> Various modules have variables that have the same name. For example I
> have a SCI1 and SCI2 module, both containing a variable called rx_buf.
> These variables are global within the module but not within the whole
> project (declared as "static type name"). The program compiles and
> functions properly.
>
> However during debug I cannot watch these variables properly. Only one
> variable is properly shown within any watch window, the other will
> show as "undefined" or as a copy of the other one. When debugging
> within a module I would expect the variable in scope to show up in a
> watch or when hovered over, but this is not the case.
>
> Has anyone encountered this? And found any workaround?
>
> TIA. Cheers all.
> --
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist

--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] MPLABX | XC8 - watching variables in multiple modules

Forrest Christian (List Account)
Naming variables to be unique across the system (other than local variables
used in a function) would be helpful (I tend to name things with
MODULENAME_variablename, but then I like having long variables like
SCI1_ReceiveBuffer.     I use the static qualifier to ensure that I don't
have the variable leak outside the module - not to permit name
overloading.     About the only place I reuse variable names are local
variables inside each function, which pretty much always works.

I can understand why the debugger is confused about 'file scope'
variables.  They're going to always be allocated, as opposed to local
variables which are very much context specific.

One option for you is to look at the map file and see if you can see where
they were allocated and then watch that memory address.   I haven't tried
this but I'm about 99% sure that will work...  but not all that convenient.

On Tue, Jul 7, 2020 at 5:20 AM Jim <[hidden email]> wrote:

>
> Rename the variables with a 1 or 2 so they are seperate and distinct.
> And you'll know which module each is working with at a glance.
> Regards,
>
> Jim
>
> > -------- Original Message --------
> > Subject: [PIC] MPLABX | XC8 - watching variables in multiple modules
> > From: K S <[hidden email]>
> > Date: Tue, July 07, 2020 2:18 am
> > To: "Microcontroller discussion list - Public." <[hidden email]>
> >
> >
> > Hello list.
> >
> > I am debugging an XC8 program with lots of modules in MPLABX 5.35.
> >
> > Various modules have variables that have the same name. For example I
> > have a SCI1 and SCI2 module, both containing a variable called rx_buf.
> > These variables are global within the module but not within the whole
> > project (declared as "static type name"). The program compiles and
> > functions properly.
> >
> > However during debug I cannot watch these variables properly. Only one
> > variable is properly shown within any watch window, the other will
> > show as "undefined" or as a copy of the other one. When debugging
> > within a module I would expect the variable in scope to show up in a
> > watch or when hovered over, but this is not the case.
> >
> > Has anyone encountered this? And found any workaround?
> >
> > TIA. Cheers all.
> > --
> > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> > View/change your membership options at
> > http://mailman.mit.edu/mailman/listinfo/piclist
>
> --
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>


--
- Forrest
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Reply | Threaded
Open this post in threaded view
|

Re: [PIC] MPLABX | XC8 - watching variables in multiple modules

K S-7
Thank you.

Points taken, but one of the reasons I am trying to *not* rename each
variable distinctly, such as prefacing with the module name, is
because it quickly bleeds into really long variable names that have no
purpose outside their module scope, and that becomes a bit harder to
maintain. IME the shorter the names, while still containing all
relevant information, the better.

I have actually been looking at the map file for now, but it is a pain
compared to just having a clear view when I need it.

On Tue, Jul 7, 2020 at 9:29 PM Forrest Christian (List Account)
<[hidden email]> wrote:

>
> Naming variables to be unique across the system (other than local variables
> used in a function) would be helpful (I tend to name things with
> MODULENAME_variablename, but then I like having long variables like
> SCI1_ReceiveBuffer.     I use the static qualifier to ensure that I don't
> have the variable leak outside the module - not to permit name
> overloading.     About the only place I reuse variable names are local
> variables inside each function, which pretty much always works.
>
> I can understand why the debugger is confused about 'file scope'
> variables.  They're going to always be allocated, as opposed to local
> variables which are very much context specific.
>
> One option for you is to look at the map file and see if you can see where
> they were allocated and then watch that memory address.   I haven't tried
> this but I'm about 99% sure that will work...  but not all that convenient.
>
> On Tue, Jul 7, 2020 at 5:20 AM Jim <[hidden email]> wrote:
>
> >
> > Rename the variables with a 1 or 2 so they are seperate and distinct.
> > And you'll know which module each is working with at a glance.
> > Regards,
> >
> > Jim
> >
> > > -------- Original Message --------
> > > Subject: [PIC] MPLABX | XC8 - watching variables in multiple modules
> > > From: K S <[hidden email]>
> > > Date: Tue, July 07, 2020 2:18 am
> > > To: "Microcontroller discussion list - Public." <[hidden email]>
> > >
> > >
> > > Hello list.
> > >
> > > I am debugging an XC8 program with lots of modules in MPLABX 5.35.
> > >
> > > Various modules have variables that have the same name. For example I
> > > have a SCI1 and SCI2 module, both containing a variable called rx_buf.
> > > These variables are global within the module but not within the whole
> > > project (declared as "static type name"). The program compiles and
> > > functions properly.
> > >
> > > However during debug I cannot watch these variables properly. Only one
> > > variable is properly shown within any watch window, the other will
> > > show as "undefined" or as a copy of the other one. When debugging
> > > within a module I would expect the variable in scope to show up in a
> > > watch or when hovered over, but this is not the case.
> > >
> > > Has anyone encountered this? And found any workaround?
> > >
> > > TIA. Cheers all.
> > > --
> > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> > > View/change your membership options at
> > > http://mailman.mit.edu/mailman/listinfo/piclist
> >
> > --
> > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> > View/change your membership options at
> > http://mailman.mit.edu/mailman/listinfo/piclist
> >
>
>
> --
> - Forrest
> --
> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist