Print value of GDB setting - gdb

How to print the value of GDB setting? For example if I use the command
set width 5
Later on I want to know the value of width, how to do that? I tried
print width
print &width
set width?
but none of these printed the value 5. Any help will be appreciated.

Use show width.
For example:
(gdb) set width 100
(gdb) show width
Number of characters gdb thinks are in a line is 100.

Related

Get terminal size (using ANSI escape codes)

I'm trying to get the terminal size using ANSI escape codes.
I found some help in How do I determine size of ANSI terminal?
but I cannot understand how to get the response from DSR6 to get the row / column of the bottom right corner.
I need this because I'm trying to align some text in the middle of the terminal.
I don't have a solution using ansi escape codes, but this solution here gives you the terminal size in both Windows and Linux: https://stackoverflow.com/a/62485211/9178992

Trace32: Way to set number of rows displayed on a data.dump

For a data.dump, you can set the number of columns of the window displayed with the /columns option, but is there a way to set the number of rows displayed?
If I dump out only 4 addresses, the window is quite large.
If you want to limit the size of any window in TRACE32 use the command WinPOS.
E.g. if you want to have a Data.dump window at address D:0x100 with a hight of only two lines (one for the header and one for the content) use the following two commands:
WinPOS ,,,2.
Data.dump D:0x100
To skip also the header line use:
WinPOS ,,,1,,0
Data.dump D:0x100
You can also size the window like you like with the mouse, and then get the command to open the window exactly like that in you clipboard by using the command ClipSTOre WinTOP
If you want to have a limited dump of addresses use the command Data.dump with an address range as a parameter.
E.g. if you want to see four 32-bit values starting at the address D:0x100 use the command
Data.dump D:0x100--0x10F
or
Data.dump D:0x100++15.
The second from means: Start address and the following number of bytes. (The dot after the 15 in my example indicates that 15 is a decimal number. Without the dot it will probably interpenetrated as a hexadecimal value.)

How to make GDB format half-word memory as hex?

I'm working with an algorithm that uses uint16_t as the datatype. There are 4 half words in the array so I am trying to display the four half words in hex. I have not done anything other than x/4h:
(gdb) x/4h master_key
0x7fffffffd330: u"Āईᄐᤘ桷"
0x7fffffffd33c: u"桷敥\xbe0#"
0x7fffffffd346: u""
0x7fffffffd348: u"ꆋ翿"
According to the GDB | Memory:
f, the display format
The display format is one of the formats used by print (‘x’, ‘d’, ‘u’, ‘o’, ‘t’, ‘a’, ‘c’, ‘f’, ‘s’), and in addition ‘i’ (for machine
instructions). The default is ‘x’ (hexadecimal) initially. The default
changes each time you use either x or print.
I'm not sure why x is trying to print strings but I would like it to print the half words in hex.
GDB does not seem to be following the manual. I think I need to change the behavior of x and make it persistent. How do I tell GDB to print the half words in hex?
The following in in my .gdbinit but it looks like GDB is ignoring it (not a surprise).
(gdb) shell cat ~/.gdbinit
set output-radix 16
set history save on
set history size 256
set logging on
set logging overwrite on

Best way to show blank cell if value if zero

=COUNTIFS(Orders!$T:$T,$B4)
is a code that gives 0 or a +ve result
I use this across 1500 cells which makes the sheet gets filled with 0s
I'd like to remove the Zeros by using the following formula
if(COUNTIFS(Orders!$T:$T,$B3,Orders!$F:$F,""&P$1&"*")=0,
"",
COUNTIFS(Orders!$T:$T,$B3,Orders!$F:$F,""&P$1&"*"))
This calculates every formula twice and increases the calculation time.
How can we do this in 1 formula where if the value is 0 - keep empty - otherwise display the answer
I suggest this cell-function:
=IFERROR(1/(1/COUNTIFS(Orders!$T:$T,$B4)))
EDIT:
I'm not sure what to add as explanation. Basically to replace the result of a complex calculation with blank cells if it results in 0, you can wrap the complex function in
IFERROR(1/(1/ ComplexFunction() ))
It works by twice taking the inverse (1/X) of the result, thus returning the original result in all cases except 0 where a DIV0 error is generated. This error is then caught by IFERROR to result in a blank cell.
The advantage of this method is that it doesn't need to calculate the complex function twice, so can give a significant speed/readability increase, and doesn't fool the output like a custom number format which can be important if this cell is used in further functions.
You only need to set the number format for your range of cells.
Go to the menu Format-->Number-->More Formats-->Custom Number Format...
In the entry area at the top, enter the following: #;-#;""
The "format" of the format string is
(positive value format) ; (negative value format) ; (zero value format)
You can apply colors or commas or anything else. See this link for details
instead of your =COUNTIFS(Orders!$T:$T,$B4) use:
=REGEXREPLACE(""&COUNTIFS(Orders!$T:$T,$B4), "^0$", )
also, to speed up things you should avoid "per row formulae" and use ArrayFormulas

OpenOffice-Calc How to set a maximum value for a column

I'm trying to set the maximum number of a column to 50, so any number greater than 50 should show up as 50 in the spreadsheet. I'm not sure if using find and replace is the way to go. I can't seem to find a way to make find and replace look for numbers greater than 50.
Thanks
Never mind found an easy way to do it with an if statement. Ended up using
=IF(B1>50;50;B1)