cmp $0x27,%ecx
I am currently looking for to see what is the value of $0x27 and %ecx. What is the command I can see to find this.
In gdb you can display the value of the ecx register with p $ecx (note gdb uses a $ instead of % since it treats $ecx like one of its internal variables). You can also use info registers to see the contents of all registers.
There's nothing "inside" $0x27 - it's a literal immediate value, not a memory address. It's like C compare_into_flags(ecx, 0x27);
For example, I want to know how many bytes are alloted for certain instructions without running the output file.
start:
movl $0,%eax;movl $0,%ebx
end:
.print end-start
Is there a way to skip over lines of code while debugging with lldb without having to recompile?
UPDATE
In addition to the original answer below, the jump/j aliases can be used for skipping a number of lines or skipping to a specific line number:
To skip two lines ahead:
(lldb) jump +2
To skip to line 102:
(lldb) jump 102
See help jump for more info.
ORIGINAL
This can be achieved using the thread jump command by giving the --by/-b flag. Example:
(lldb) thread jump --by 2
(lldb) th j -b 2
Alternatively, instead of a relative move an absolute line number can be specific with --line/-l.
(lldb) thread jump --line 102
(lldb) th j -l 102
Note that these both move the program counter, and that could put the program into a broken state and lead to crashes.
I'd like to jump to a specific line in a file, line 33866. If the third number in this line is within the range -10 and +10 then I'd like to print the entire next line, 33867, to a file and stop.
If it isn't then it should look at line 67893 (difference of +34027), now if its in the range - print the next line and stop.
This should continue, next looking at line 101920 (difference of +34027) and so on until it finds a value in that range or reaches the end of the file.
Now regardless of whether or not that printed anything I need it to repeat the process but at a new starting line, this time the new start line is 33869 (difference 3), to print line 33870 to the same file.
Ideally, it would repeat n times, n being a read value input by the user when the script is ran.
Please stop me right there if this is too much to ask and I'll go back to banging my head against the wall and searching around the net for how to make this work on my own. Also let me know if I'm going about this the wrong way by trying to jump to a specific line and should search for the line by another means.
Any input greatly appreciated!
Edit:
Here is an example of the two lines being handled:
17.33051021 18.02125499 30.40520932
1.776579372 -23.74037576 12.48448432
with the first number starting in column 6, the second number starting in 26 and third in 46. (if minus is ignored I don't think it will matter)
reading your question, I guess your file could be pretty big. Also I assume "the 3rd number" is 3rd field. so I come up with this one-liner:
awk -v l=33866 -v d=34027 'NR==l&&$3>=-10&&$3<=10{p=1;next}p{print;exit}{l+=d}' file
you just need to change the two arguments (l (first line No. you need to check) and d (difference)).
After found the right line to print, awk stops processing further lines in your file.
didn't test, if there were typoes, sorry, but it shows my idea
you should give some example input etc. i.e. the 3rd number, what is that? the 3rd field? or like aa bb 2 dfd 3 asf 555, the 555?
another one, actually you should show what you have done for your problem
Since we don't have any input to test with, I am giving you an answer without testing.
tl=$(wc -l input)
awk '{
for (i=33866; i<tl; i+=34027) {
if (NR==i && $3 >= -10 && $3 <= 10) {
getline;
print;
exit;
}
}
}' input
I am pretty new to KornShell (ksh). I have a project that needs to be done with ksh. The question is:
Please write a ksh script which will run the ‘bonnie’ benchmark
utility and parse the output to grab the values for block write, block
read and random seeks/s. Also consider how you might use these values
to compare to the results from previous tests. For the purpose of
this test, please limit yourself to standard GNU utilities (sed, awk,
grep, cut, etc.).
Here is the output from the ‘bonnie’ utility:
# bonnie -s 50M -d /tmp
File '/tmp/Bonnie.2001096837', size: 52428800
Writing with putc()...done
Rewriting...done
Writing intelligently...done
Reading with getc()...done
Reading intelligently...done
Seeker 1.S.e.eker 2.S.e.eker 3...start 'em...done...done...done...
-------Sequential Output-------- ---Sequential Input-- --Random--
-Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
50.0 36112 34.1 138026 1.9 179048 7.0 51361 51.1 312242 4.3 15211.4 10.3
Any suggestion of how to write this script would be really appreciate.
Thanks for reading!
Here's a simple solution to experiment with, that assumes the last line will always contain the data you want:
# -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
# Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
# 50.0 36112 34.1 138026 1.9 179048 7.0 51361 51.1 312242 4.3 15211.4 10.3
# block write, block read and random seeks/s
bonnie++ \
| awk '
{line=$0}
END{
# print "#dbg:last_line=" $line
split(line, lineArr)
printf ("blkWrt=%s\tblkRd=%s\tRandSks=%s\n", lineArr[4], lineArr[8], lineArr[12])
}' # > bonnieOutput
# ------^^ remove # to write output to file
(Note that the \ char after bonnie++ must be the last character on the line, NO SPACES OR TABS allowed!!! (It will blow up otherwise!) ;-) )
Awk reads all lines of input passed thru a pipe. When you're in the END{} block of awk, you put the last line read into the lineArr[], and then print out just the elements you want from that line, using the index number of the field in your data, so lineArr[4] is going to return the 4th field in that last line of data, lineArr[12], the 12th, etc. You may have to adjust what index number you use to get the data you want to display. (You'll have to figure that out! ;-)
To save the data to a file, use the shell redirection by uncommenting (removing the # char between }' and > bonnieOutput. Leave the # char in place until you get the output you need, THEN you can redirect it to a file.
Needless to say the labels that I've used in the printf like blkWrt= are mostly for debugging. Once you are sure about what data you need to capture, and that it reliably appears in the same location each time, then you can remove those labels and then you'll have a nice clean datafile that can process with other programs.
Keep in mind that almost all Unix toolbox utilities are line oriented, that is they expect to process 1 line of data at a time and there are often tricks to see what is being processed. Note the #dbg line I've included at the top of the END{} block. You'll have to remove the '#' to uncomment it to see the debug output.
There's a lot more than can be done, but if you want to learn ksh/unix toolbox with awk, you'll have to spend the time understanding what the features are. If you've read the chapter that included the question you're working with and don't understand how to even start solving this problem, maybe you better read the chapter again, OK? ;-)
Edit
Note that in awk, the variable $0 contains all text in the current line (as defined by the RS variable value, usually the Unix line ending char, \n). Other numbered values, i.e. $1, $2, indicate the first, or second "field" on the current line ($0).
Based on my new understand from you comment below, you want to extract values from lines that contain the text "Latency". This is even easier to process. The basic pattern will be
bonnie++ \
| awk '
/Latency/{
# print "#dbg:latency_line=" $0
printf ("blkWrt=%s\tblkRd=%s\tRandSks=%s\n", $4, $8, $12)
}' # > bonnieOutput
So this code says, read all output from bonnie++ into awk, through the pipe, and when you find a line containing the text "Latency", print the values found in the 4th, 8th, and 12th fields, using the printf format string that contains self-describing tags like blkWrt, etc.
You'll have to change the $4, etc to correctly match the number in the current line for each element of data. I.E. maybe it $5, $9, $13, or $3, $9, $24? OK?
Note that /Latency/ is case sensitive, and if there are other places in the output where the word appears, then we'll have to revise the reg-exp "rule" used to filter the output.
As a learning exercise, and as a very basic tool that any Unix person uses every day, skip awk, and just see what bonnie++| grep 'Latency' gets you.
IHTH
Just got the answer by the help from Shellter!
bonnie++\
| awk '/Machine/ {f=1;next}f{
print "#dbg: line_needed=" $0
printf("blkWrt=%s\t blkRd=%s\t RandSks=%s\n", $4, $8, $12);exit
}'