Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.embedded > #529
| Date | 2011-02-09 16:44 +0100 |
|---|---|
| From | David Brown <david@westcontrol.removethisbit.com> |
| Newsgroups | comp.os.linux.embedded |
| Subject | Re: Reading power PC MPC 8260 program counter (Next Instruction address) |
| References | <OcadnWOytc0SFczQ4p2dnAA@giganews.com> <Irg4p.74811$be.20670@newsfe05.iad> <5O-dnRBA-e3rFM_QnZ2dnUVZ8vudnZ2d@lyse.net> <7429c9ef-5603-45fc-a1db-abf32c436f6e@k38g2000vbn.googlegroups.com> <3e6d7636-a6d5-4a8e-8983-4ae72fa02473@g10g2000vbv.googlegroups.com> |
| Message-ID | <OfednQaFWbLGK8_QnZ2dnUVZ7tOdnZ2d@lyse.net> (permalink) |
On 09/02/2011 16:01, Lew Pitcher wrote:
> On Feb 9, 9:16 am, Lew Pitcher<lpitc...@teksavvy.com> wrote:
>> On Feb 9, 7:32 am, David Brown<da...@westcontrol.removethisbit.com>
>> wrote:
>>
>>
>>
>>> On 08/02/2011 20:03, Lew Pitcher wrote:
>>
>>>> On February 8, 2011 13:16, in comp.os.linux.embedded, raje...@domain-xyz.in
>>>> wrote:
>>
>>>>> Hello,
>>
>>>>> Please can somebody let me know how to read power PC 8260 program counter
>>>>> using C program (Using asm directive).
>>
>>>> That seems to me to be a "fools errand". By the time you've read the program
>>>> counter, the program counter has changed. Each instruction executed changes
>>>> the program counter, and in a multi-processing architecture like Linux,
>>>> each context switch changes the program counter as well. By the time your
>>>> code has retrieved the counter, the counter has changed.
>>
>>>> Anyway, it's a trivial thing to get the PC (or reasonable facsimile) in C
>>>> code:
>>
>>>> void dummy(void)
>>>> {
>>>> void (*pc)() =&dummy; /* got the PC on entry to the function */
>>>> /*
>>>> ...
>>>> */
>>>> }
>>
>>> I've had occasion to want to read the current PC from within a program.
>>> I've used it as a simple way to distinguish between running from flash
>>> after startup, or running from ram via a debugger. I'm sure there are
>>> other uses too, perhaps involving debugging or testing, or diagnostic
>>> output s on error.
>>
>> I see. You really don't care about the program counter; you just want
>> to know where your program was loaded.
>
> FWIW, it would be better to just look at the contents of /proc/<pid>/
> maps for the pid of the process in question. That'll show you exactly
> where each loadable element of your process is placed in memory.
>
Ops, I hadn't noticed that this is comp.os.linux.embedded - I had
assumed I was still in comp.arch.embedded. My system was bare-bones.
Sorry for any confusion.
Back to comp.os.linux.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Reading power PC MPC 8260 program counter (Next Instruction address) David Brown <david@westcontrol.removethisbit.com> - 2011-02-09 13:32 +0100
Re: Reading power PC MPC 8260 program counter (Next Instruction address) Lew Pitcher <lpitcher@teksavvy.com> - 2011-02-09 07:01 -0800
Re: Reading power PC MPC 8260 program counter (Next Instruction address) David Brown <david@westcontrol.removethisbit.com> - 2011-02-09 16:44 +0100
Re: Reading power PC MPC 8260 program counter (Next Instruction address) Lew Pitcher <lpitcher@teksavvy.com> - 2011-02-09 06:16 -0800
Re: Reading power PC MPC 8260 program counter (Next Instruction address) David Brown <david@westcontrol.removethisbit.com> - 2011-02-09 16:42 +0100
Re: Reading power PC MPC 8260 program counter (Next Instruction address) Niklas Holsti <niklas.holsti@tidorum.invalid> - 2011-02-12 09:35 +0100
Re: Reading power PC MPC 8260 program counter (Next Instruction address) Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2011-02-12 10:06 +0200
Re: Reading power PC MPC 8260 program counter (Next Instruction address) jeffj@panix.com (Jeff Jonas) - 2011-02-11 03:31 -0500
csiph-web