A man accused of drugging his children before murdering his wife with a sledgehammer and knife was beaten and raped as a child, a court has heard.
George Kibuuka, 48, is accused of murdering wife Margaret in Southampton in 2009, after she filed for divorce.
Psychiatrist Dr Jan Vermeulen said events from Mr Kibuuka's childhood in Uganda had helped develop his "personality disorder".
At Winchester Crown Court, Mr Kibuuka admits the killing but denies murder.
His defence is arguing diminished responsibility.
'Abandoned by mother'
After killing 40-year-old Mrs Kibuuka at their home in Shirley, Mr Kibuuka stabbed himself in the abdomen and took organophosphate pesticide, but was found by paramedics and survived.
He is also accused of drugging three of his children by putting sleeping tablets into their food and drink so they would not witness the attack.
Psychiatrist Dr Jan Vermeulen, for the defence, told the court Mr Kibuuka's mother gave birth to him when she was 14 years old, then abandoned him.
As a child, Mr Kibuuka was always very anti-social, getting into fights, and he was seen by a local healer or witch doctor and given herbs, Dr Vermeulen said.
His father was an alcoholic and beat him, and at the age of eight he was raped by a man and, over the years, was sexually abused by neighbours, the court was told.
Dr Vermeulen said these events had helped to develop the "personality disorder" from which Mr Kibuuka suffered.
He said there were phases when Mr Kibuuka felt spirits were in control and he would enter a "dream-like trance", sometimes flying or fighting animals, or receiving messages from ancestral gods.
The court also heard from psychiatrist Dr Richard Babcock, for the prosecution, who questioned whether Mr Kibuuka's mental state reduced his level of responsibility for the killing.
"For me, there was too much planning, too much care, too much intensity in what he did," Dr Babcock told jurors.
Earlier in the trial, the court heard part-time carer Mrs Kibuuka had filed for divorce, claiming her husband had been violent towards her.
The mother-of-four had complained to police about her husband's violence and emotional abuse in the weeks before her death.
The trial continues.