Author Topic: VAC3.65 / 3.08 inline assembly? How to insert INT 3?  (Read 15215 times)

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« on: December 21, 2017, 05:06:36 pm »
Topic says it all. I do not find any information to insert a breakpoint INT 3 in my C source code which should be compiled with VAC3.65. Sounds simple but obviously I fed the wrong words into the search engine.

Tom

  • Full Member
  • ***
  • Posts: 194
  • Karma: +5/-0
    • View Profile
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #1 on: December 21, 2017, 07:57:08 pm »
Topic says it all. I do not find any information to insert a breakpoint INT 3 in my C source code which should be compiled with VAC3.65. Sounds simple but obviously I fed the wrong words into the search engine.

Insert byte 0xCC for INT 3 (breakpoint)

RickCHodgin

  • Guest
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #2 on: December 21, 2017, 08:13:26 pm »
Topic says it all. I do not find any information to insert a breakpoint INT 3 in my C source code which should be compiled with VAC3.65. Sounds simple but obviously I fed the wrong words into the search engine.

It looks like other IBM compilers use __asm__ int 3 and asm("int 3").  I've never tried in Visual Age.  In fact, I had difficulty using Visual Age.  It does things in a way I could not figure out.

I have used Open Watcom for OS/2 development and it has worked smoothly.

ak120

  • Guest
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #3 on: December 21, 2017, 11:06:41 pm »
The icc from the mentioned VisualAge C++ products simply doesn't support inline assembly. Only later versions for AIX and other systems offered this functionality for C. https://www.ibm.com/support/knowledgecenter/SSAE4W_9.0.0/com.ibm.xlcpp111.aix.doc/language_ref/asm.html

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #4 on: December 21, 2017, 11:15:14 pm »
Need a little bit of assembly. Write yourself an assembly function. And while you are at it, make it a library so that you can reuse it.
Use ALP for assembly. It's still good enough for not too advanced assembly code (goes up to XMM, supports all protected system instruction).

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 331
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #5 on: December 22, 2017, 12:19:33 am »
<RTFM>

#include <builtin.h>
void _interrupt(const unsigned int intnum);

Language Level: Extension

_interrupt calls the interrupt procedure specified by intnum using the INT machine instruction. The integer intnum must have a value within the range 0 to 255 inclusive.

Note: _interrupt is a built-in function, which means it is implemented as an inline instruction and has no backing code in the library. For this reason:

You cannot take the address of _interrupt.
You cannot parenthesize a call to _interrupt. (Parentheses specify a call to the function's backing code, and _interrupt has none.)

Return Value
There is no return value, and _interrupt does not set errno.

</RTFM>

RickCHodgin

  • Guest
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #6 on: December 22, 2017, 12:28:17 am »
<RT..M>

Do you really talk to people with such disdain, Rich?  Are people of such low value that you can assault them anonymously across the Internet in this rude way?

If you have information to help people then help them.  Don't belittle them.

Ian Manners

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 464
  • Karma: +10/-0
  • I am the computer, it is me.
    • View Profile
    • ComKal Networks Australia
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #7 on: December 22, 2017, 08:32:10 am »
Quote
Do you really talk to people with such disdain, Rich?  Are people of such low value that you can assault them anonymously across the Internet in this rude way?

If you have information to help people then help them.  Don't belittle them.

RTFM is part of modern language, it's not going away and is simply a saying. Rich is not assaulting or belittling anyone, unless they wish to change the interpretation of what is said. This is simply a quick method of saying the answer is in the manual, and many of us do not actually read manuals, though we should :)
Cheers
Ian B Manners

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #8 on: December 22, 2017, 10:01:01 am »
Thanks to all.

I searched the manuals, toolkit headers and samples back and forth for INT, INT3, INT 3, ... tried a lot of code I found in the net and got the feeling it must be something very simple. That's the reason I asked here. Now I do not understand why I missed the _interrupt section. One culprit was #include <builtin.h> and I concentrated on code examples and the toolkit instead the compiler helpers. Thanks again.

RickCHodgin

  • Guest
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #9 on: December 22, 2017, 12:26:18 pm »
Quote
Do you really talk to people with such disdain, Rich?  Are people of such low value that you can assault them anonymously across the Internet in this rude way?

If you have information to help people then help them.  Don't belittle them.

RT..M is part of modern language...

Yes, profane things have made their way in to everyday speech, as has rudeness and hate.  Peoole treat each other like dogs firing off one mean thing after another.  It shouldn't be like that, and we can choose to be nice and helpful to one another.  We don't have to go the way of modern hateful society with its general view of disposable people.  We are valuable creations, and we should do our best to help one another, and not in modern society's mocking way.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #10 on: December 23, 2017, 11:57:22 pm »
Here is my smart ass answer to "_interrupt":

_interrupt(3) will very likely encode an "int 3" instruction as a 2 Byte opcode (0xCD 0x03).
The "real" int3 however is a 1 Byte opcode (0xCC). These two instructions are close but not the same and might confuse a normal debugger that expects 0xCC opcode for int3 (if you intend to execute the application under Debugger control and intend to stop it on the int3).

RickCHodgin

  • Guest
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #11 on: December 24, 2017, 12:28:41 am »
Here is my smart ass answer to "_interrupt":

Everything in your reply was helpful except this line.  Couldn't resist, could you?  That is the way of this world, Lars, and it has no future.

Quote
_interrupt(3) will very likely encode an "int 3" instruction as a 2 Byte opcode (0xCD 0x03).
The "real" int3 however is a 1 Byte opcode (0xCC). These two instructions are close but not the same and might confuse a normal debugger that expects 0xCC opcode for int3 (if you intend to execute the application under Debugger control and intend to stop it on the int3).

They could examine builtin.h to see what other functions it has.  Maybe there's an _int3() or _debug_break() function.

Ian Manners

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 464
  • Karma: +10/-0
  • I am the computer, it is me.
    • View Profile
    • ComKal Networks Australia
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #12 on: December 24, 2017, 12:37:30 pm »
Rick,

Words have more than one meaning, context matters as does the way the meanings of words changes with time and population generation, so does respecting others and not intruding on/in there/their space or beliefs.

This forum is not here for you to complain about how others talk or differences in culture, it is for all OS/2 and derivative operating system users to talk together, seek information, help, and exchange ideas no matter what religion or culture they are from. Take the words as they are said in context, if you don't like something then simply ignore it. Complaining about others in a fashion that I see as meaningless does no more than generate noise and serves no purpose. It is not helpful to you, to others, nor to whichever deity you may believe in.

We are all different and the measure of a person is how well they take these differences and work with them, not complain about or change others because they are not like you.

Now smile, go do something different and have a happy Christmas when it arrives in your part of the world :)
Cheers
Ian B Manners

Andi B.

  • Hero Member
  • *****
  • Posts: 811
  • Karma: +11/-2
    • View Profile
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #13 on: December 24, 2017, 02:35:21 pm »
_interrupt(3) will very likely encode an "int 3" instruction as a 2 Byte opcode (0xCD 0x03).
Just verified with a test sample and it decodes correctly to 0xCC. This is with VAC3.65 and icc /Ti. Idebug stops and the popup says 'A program-generated breakpoint was encountered'.

RobertMauro

  • Guest
Re: VAC3.65 / 3.08 inline assembly? How to insert INT 3?
« Reply #14 on: December 24, 2017, 10:23:11 pm »
Bans may last for eternity too...

...and now back to our regularly scheduled program.