Crestez Dan Leonard
2017-05-26 15:54:37 UTC
---
** [tickets:#153] "$target mem2array" broken**
**Status:** new
**Milestone:** 0.9.0
**Created:** Fri May 26, 2017 03:54 PM UTC by Crestez Dan Leonard
**Last Updated:** Fri May 26, 2017 03:54 PM UTC
**Owner:** nobody
The manual claims that "$target mem2array ..." should be equivalent to "targets $target; mem2array ...". Unfortunately only the latter works, the former does not actually update the array.
I asked on IRC and was told it's a known issue but did not find any bug logged for it.
I did some debugging and it seems to be a TCL scoping issue. It can be made to work with the following hack:
~~~
diff --git a/src/target/target.c b/src/target/target.c
index 49cf12a..6b96cf8 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5024,6 +5024,22 @@ static int jim_target_mem2array(Jim_Interp *interp,
int argc, Jim_Obj *const *argv)
{
struct target *target = Jim_CmdPrivData(interp);
+ Jim_CallFrame *targetCallFrame;
+ Jim_Obj *uplevelObjPtr;
+
+ uplevelObjPtr = Jim_NewIntObj(interp, 2);
+ if (!uplevelObjPtr)
+ return JIM_ERR;
+
+ Jim_IncrRefCount(uplevelObjPtr);
+ targetCallFrame = Jim_GetCallFrameByLevel(interp, uplevelObjPtr);
+ Jim_DecrRefCount(interp, uplevelObjPtr);
+ if (!targetCallFrame)
+ return JIM_ERR;
+
+ if (Jim_SetVariableLink(interp, argv[1], argv[1], targetCallFrame) != JIM_OK)
+ return JIM_ERR;
+
return target_mem2array(interp, target, argc - 1, argv + 1);
}
~~~
I mostly just guessed at the fix and it's probably wrong.
---
Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
** [tickets:#153] "$target mem2array" broken**
**Status:** new
**Milestone:** 0.9.0
**Created:** Fri May 26, 2017 03:54 PM UTC by Crestez Dan Leonard
**Last Updated:** Fri May 26, 2017 03:54 PM UTC
**Owner:** nobody
The manual claims that "$target mem2array ..." should be equivalent to "targets $target; mem2array ...". Unfortunately only the latter works, the former does not actually update the array.
I asked on IRC and was told it's a known issue but did not find any bug logged for it.
I did some debugging and it seems to be a TCL scoping issue. It can be made to work with the following hack:
~~~
diff --git a/src/target/target.c b/src/target/target.c
index 49cf12a..6b96cf8 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5024,6 +5024,22 @@ static int jim_target_mem2array(Jim_Interp *interp,
int argc, Jim_Obj *const *argv)
{
struct target *target = Jim_CmdPrivData(interp);
+ Jim_CallFrame *targetCallFrame;
+ Jim_Obj *uplevelObjPtr;
+
+ uplevelObjPtr = Jim_NewIntObj(interp, 2);
+ if (!uplevelObjPtr)
+ return JIM_ERR;
+
+ Jim_IncrRefCount(uplevelObjPtr);
+ targetCallFrame = Jim_GetCallFrameByLevel(interp, uplevelObjPtr);
+ Jim_DecrRefCount(interp, uplevelObjPtr);
+ if (!targetCallFrame)
+ return JIM_ERR;
+
+ if (Jim_SetVariableLink(interp, argv[1], argv[1], targetCallFrame) != JIM_OK)
+ return JIM_ERR;
+
return target_mem2array(interp, target, argc - 1, argv + 1);
}
~~~
I mostly just guessed at the fix and it's probably wrong.
---
Sent from sourceforge.net because openocd-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.