My backtrace includes this line:
#2 z_swap (key=..., lock=0x2000ab90 <lock>) at /zephyr/kernel/include/kswap.h:145
#3 z_pend_curr (lock=lock#entry=0x2000ab90 <lock>, key=key#entry=..., wait_q=wait_q#entry=0x20017ff0 <spi_3_data+28>, timeout=timeout#entry=-1)
What does key=... and key=key#entry=... mean here?
One thing ... could mean is that those arguments are not scalars.
'set print frame-arguments VALUE'
This command allows to control how the values of arguments are
printed when the debugger prints a frame (*note Frames::). The
possible values are:
'all'
The values of all arguments are printed.
'scalars'
Print the value of an argument only if it is a scalar. The
value of more complex arguments such as arrays, structures,
unions, etc, is replaced by '...'. This is the default. Here
is an example where only scalar arguments are shown:
#1 0x08048361 in call_me (i=3, s=..., ss=0xbf8d508c, u=..., e=green)
at frame-args.c:23
'none'
None of the argument values are printed. Instead, the value
of each argument is replaced by '...'. In this case, the
example above now becomes:
#1 0x08048361 in call_me (i=..., s=..., ss=..., u=..., e=...)
at frame-args.c:23
Related
I was wondering if we have any TACL experts out there can can help me answer probably a very basic question.
How do you inject multiple arguments into you routine.
This is what I have currently so far
[#CASE [#ARGUMENT / VALUE job_id/number /minimum [min_job], maximum [max_job]/
otherwise]
|1|#output Job Number = [job_id]
|otherwise|
#output Bad number - Must be a number between [min_job] & [max_job]
#return
]
I have been told you need to use a second #ARGUMENT statement to get it to work but I have had no such luck getting it to work. And the PDF guides don't help to much.
Any ideas/answers would be great
Thanks.
The #CASE statement isn't required if your arguments are positional and of one type (i.e. you know what you are getting and in what order). In that case you can just use a sequence of #ARGUMENT statements to get the arguments.
In your example #ARGUMENT accepts either a number in a range or anything else - the OTHERWISE bit. The #CASE statement then tells you which of those two you got, 1 or 2.
#ARGUMENT can do data validation for you (you may recognize the output from some of the TACL routines that come with the operating system).
So you can write something like this:
SINK [#ARGUMENT / VALUE job_id/number /minimum [min_job], maximum [max_job]/]
The SINK just tosses away the expansion of the #ARGUMENT, you don't need it since you only accept a number and fail otherwise.
I figured out a way but idk if it is the best way to do it.
It seems that for one an Argument statement needs to always be in a #CASE statement so all I basically did was mirror the above and just altered it for text rather than use integer.
If you know of any other/better ways let me know :)
It find it best to use CASE when you have multiple types of argument
input to process. Kind of mocked up how I would see multiple argument
types being used in the context that you shared with the CASE
expression:
?TACL ROUTINE
#FRAME
#PUSH JOB_ID MIN_JOB MAX_JOB
#SETMANY MIN_JOB MAX_JOB , 1 3
[#DEF VALID_KEYWORDS TEXT |BODY| THISJOB THATJOB SOMEOTHERJOB]
[#CASE
[#ARGUMENT/VALUE JOB_ID/
NUMBER/MINIMUM [MIN_JOB],MAXIMUM [MAX_JOB]/
KEYWORD/WORDLIST [VALID_KEYWORDS]/
STRING
OTHERWISE
]
| 1 |
#OUTPUT VALID JOB NUMBER = [JOB_ID]
| 2 |
#OUTPUT VALID KEYWORD = [JOB_ID]
| 3 |
#OUTPUT VALID STRING = [JOB_ID]
| OTHERWISE |
#OUTPUT NOT A NUMBER, KEYWORD, OR A STRING
#OUTPUT MUST BE ONE OF:
#OUTPUT A NUMBER IN THE RANGE OF: [MIN_JOB] TO [MAX_JOB]
#OUTPUT A KEYWORD IN THIS LIST: [VALID_KEYWORDS]
#OUTPUT OR A STRING OF CHARACTERS
#RETURN
]
#OUTPUT
#OUTPUT NOW WE ARE USING ARGUMENT [JOB_ID] !!!
TIME
#UNFRAME
I am new to VSCode. Thinking about code snippets, I looked around for a way to kind of script inside the snippet. I mean to do more than just fill or transform a variable. For example...
This is a simple snippet. I am going to type rci for the class initializer. When I enter the method arguments I would like the assignment and documentation + some other things to happen.
rci<tab> and then def initialize(a, b)) to result in something like this...
attr_reader :a
attr_reader :b
# #param a [...] ...
# #param b [...] ...
def initialize(a, b)
#a = a
#b = b
end
Is it possible? How can it be achieved? There could be any number of arguments. And each argument would trigger another line of the class initializer.
"Class Initializer": {
"prefix": "rci",
"body": [
"${1/([^,]+)([,\\s]*|)/attr_reader :$1\n/g}",
"${1/([^,]+)([,\\s]*|)/# #param $1 [...]${2:+\n}/g}",
"def initialize($1)",
"${1/([^,]+)((,\\s*)|)/\t#$1 = $1${2:+\n}/g}",
"end"
],
"description": "Initialize Class"
}
The key to get it to work for any number of method arguments is to get them into the same regex capture group.
Then, with the global flag set, each capture group will trigger the replacement text. So for instance, /attr_reader :$1\n/g will get triggered 3 times if you have 3 method arguments.
You will see this ${2:+\n} in the transforms above. That means if there is a capture group 2, add a newline. The regex is designed so that there is only a capture group 2 if there is another , between arguments. So a final ) after the last argument will not trigger another newline - so the output exactly matches your desired output as to newlines (but you could easily add or remove newlines).
Your input must be in the correct form:
v1, v2, v3
Here is a demo:
So again the necessary form is just v1 v2 v3. There doesn't need to be a space between the arguments but then you would get def initialize(v1,v2,v3) without spaces either.
Hit Tab after the final argument to trigger completion.
It turns out snippets are pretty powerful!!
For a similar question about using multiple arguments, see VSCode snippet: add multiple objects to a class constructor
Is it possible to set a complex breakpoint which has condition which involves check on the argument passed to the outer function(frame).
eg.
1 #0 sample::_processMessage (this=0xa5c8c0, data=0x7fffe5ae31db "\027w\270߸\023\032\212\v", line=0x7fffe4799db8 "224.4.2.197:60200", should_process=true) a sample.cpp:426
2 #1 0x00007ffff682f05d in sample::_process (this=0xa5c8c0, should_process=true, line=0x7fffe4799db8 "224.4.2.197:60200", data=0x7fffe5ae31db "\027w\270߸\023\032\212\v", sn=31824) a sample.cpp:390
3 #2 0x00007ffff6836744 in sample::drain (this=0xa5c8c0, force=true) at sample.cpp:2284
4 #3 0x00007ffff682ed81 in sample::process (this=0xa5c8c0, mdData=0x7fffe67914e0) at sample.cpp:354
Here I want to set a break point on sample.cpp:356,which is on in the function process-frame#3,
if the _process or frame #1 at the time hitting breakpoint has sn == 31824
so actually break point is at function _process but I want pause the execution in the function process
Thanks in advance
I don't know if it's possible to create conditional breakpoints that reference an outer frame, but you could use breakpoint commands to achieve a similar result.
Here's an example gdb session:
(gdb) break some-location
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>silent
>up
>if (sn != 31824)
>continue
>end
>end
Now every time gdb hits the breakpoint it will automatically move up a frame, check sn and continue if the value is not correct. This will not be any (or much) slower than a conditional breakpoint, and the only real downside is that it will print out a line each time the breakpoint is hit, even if gdb then continues.
The silent in the command list cuts down on some of the normal output that is produced when a breakpoint is hit, this can be removed to get a more verbose experience.
This can be accomplished with a gdb convenience function implemented in python:
import gdb
class CallerVar(gdb.Function):
"""Return the value of a calling function's variable.
Usage: $_caller_var (NAME [, NUMBER-OF-FRAMES [, DEFAULT-VALUE]])
Arguments:
NAME: The name of the variable.
NUMBER-OF-FRAMES: How many stack frames to traverse back from the currently
selected frame to compare with.
The default is 1.
DEFAULT-VALUE: Return value if the variable can't be found.
The default is 0.
Returns:
The value of the variable in the specified frame, DEFAULT-VALUE if the
variable can't be found."""
def __init__(self):
super(CallerVar, self).__init__("_caller_var")
def invoke(self, name, nframes=1, defvalue=0):
if nframes < 0:
raise ValueError("nframes must be >= 0")
frame = gdb.selected_frame()
while nframes > 0:
frame = frame.older()
if frame is None:
return defvalue
nframes = nframes - 1
try:
return frame.read_var(name.string())
except:
return defvalue
CallerVar()
It can be used like:
(gdb) b sample.cpp:356 if $_caller_var("sn",2)==31824
I face a problem below.When I run another function related to this 'if',type error is "int() argument must be a string or a number, not 'Vec2D' ",then I cut off the int(),and the type error changes to "slice indices must be integers or None or have an index method ",wtf,waiting for someone's brilliant help.
def singleOrder(argument):
global position
global direction
if argument==']':
lastPosition=position[len(position)-1]
lastDirection=direction[len(direction)-1]
turtle.setposition(lastPosition)
turtle.setheading(lastDirection)
position=position[:int(lastPosition)]
direction=direction[:int(lastDirection)]
Removing the last element of a list is easy:
del L[-1]
How can I check multiple expressions in one Matcher fragment?
For example:
class Foo extends Specification {
"Retrieving open issues" should {
"return expected properties with expected data" in {
val issue = Bar.openIssues.head
issue must not beNull
issue.number must beEqualTo(1)
issue.state must beEqualTo("open")
issue.title must beEqualTo("first issue")
}
}
}
Gives error
[error] type mismatch;
[error] found : Int
[error] required: org.specs2.matcher.Matcher[Issue]
[error] issue.number must beEqualTo(1)
Eric references a "classical" type inference issue in this comment, but couldn't find an answer.
The problem lies in this line:
issue must not beNull
Because it is written in operator notation the compiler must infer dots and parentheses at the right position. Following the rule that obj meth arg is the same as obj.meth(arg) this line is interpreted as:
issue.must(not).beNull<missing_arg>
beNull is a member called on the returned value of issue.must(not). The compiler follows the rules of operator notation and treats it as meth while issue.must(not) is treated as obj. Because operator notation always requires that a call must have the form obj meth arg, in the above example the compiler is hold to throw an error because of invalid syntax. But it doesn't do it since there are two further rules:
The white space that separates the identifiers in operator notation must not only contain spaces or tabs, it can also contain a single(!) new line sign.
If no arg can be found an empty argument list is inserted implicitly.
Because of (1), the compiler treats the next line as arg:
issue.must(not).beNull(
issue.number).must(beEqualTo(1))
This is not how the code should be interpreted. To solve the problem it is possible to enclose the whole expression in parentheses:
(issue must not beNull)
or to separate the lines by an empty line:
issue must not beNull
issue.number must beEqualTo(1)
Both solutions work because of (2) the compiler can insert an empty argument list.
Note: If (2) must be applied this is also called a postfix operator. In 2.10 they treat a warning because - as one can see with this question - they can lead to tricky behavior.